diff options
| author | Jerry Gilliam <Jerry.Gilliam@Sun.COM> | 2009-01-17 16:54:28 -0800 |
|---|---|---|
| committer | Jerry Gilliam <Jerry.Gilliam@Sun.COM> | 2009-01-17 16:54:28 -0800 |
| commit | 7e48531733326c7034772ff72376656c5b1183ca (patch) | |
| tree | 011c887c0aedc82e582a6edd5c1ed3ddb09cd8bf /usr/src/cmd/modload | |
| parent | 0bd79941b7ad65e3e00dd0843474817f83c54f78 (diff) | |
| download | illumos-joyent-7e48531733326c7034772ff72376656c5b1183ca.tar.gz | |
PSARC/2009/031 update_drv(1M) -n option
6198348 update_drv: needs -n option
6787916 add_drv(1M) checks privileges against running system even when -b is used
Diffstat (limited to 'usr/src/cmd/modload')
| -rw-r--r-- | usr/src/cmd/modload/add_drv.c | 16 | ||||
| -rw-r--r-- | usr/src/cmd/modload/errmsg.h | 11 | ||||
| -rw-r--r-- | usr/src/cmd/modload/rem_drv.c | 17 | ||||
| -rw-r--r-- | usr/src/cmd/modload/update_drv.c | 24 |
4 files changed, 39 insertions, 29 deletions
diff --git a/usr/src/cmd/modload/add_drv.c b/usr/src/cmd/modload/add_drv.c index 62da6d8796..ddd05308d9 100644 --- a/usr/src/cmd/modload/add_drv.c +++ b/usr/src/cmd/modload/add_drv.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <libelf.h> @@ -150,7 +148,7 @@ main(int argc, char *argv[]) aliases = optarg; if (check_space_within_quote(aliases) == ERROR) { (void) fprintf(stderr, gettext(ERR_NO_SPACE), - aliases); + aliases); exit(1); } break; @@ -257,7 +255,9 @@ main(int argc, char *argv[]) err_exit(); } - if (priv != NULL && check_priv_entry(priv, 1) != 0) + /* update kernel unless -b or -n */ + if (noload_flag == 0 && server == 0 && + priv != NULL && check_priv_entry(priv, 1) != 0) err_exit(); if (policy != NULL && @@ -274,7 +274,7 @@ main(int argc, char *argv[]) err_exit(); } - if (!server) { + if (noload_flag == 0 && server == 0) { if (elf_type("/dev/ksyms", &kelf_desc, &kelf_type) == ERROR) { (void) fprintf(stderr, gettext(ERR_KERNEL_ISA)); err_exit(); @@ -406,13 +406,13 @@ main(int argc, char *argv[]) if (policy != NULL) { cleanup_flag |= CLEAN_DEV_POLICY; if (update_device_policy(device_policy, policy, B_FALSE) - == ERROR) { + == ERROR) { remove_entry(cleanup_flag, driver_name); err_exit(); } } - if (server) { + if (noload_flag || server) { (void) fprintf(stderr, gettext(BOOT_CLIENT)); } else { /* diff --git a/usr/src/cmd/modload/errmsg.h b/usr/src/cmd/modload/errmsg.h index 002b7518d1..53f86a8f10 100644 --- a/usr/src/cmd/modload/errmsg.h +++ b/usr/src/cmd/modload/errmsg.h @@ -19,15 +19,13 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _ERRMSG_H #define _ERRMSG_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -122,10 +120,10 @@ extern "C" { /* update_drv messages */ #define UPD_DRV_USAGE \ "Usage:\tupdate_drv [ -f | -v ] <driver_module>\n" \ - "\tupdate_drv [ -b basedir ] [ -f | -v ] -a\n" \ + "\tupdate_drv [ -b basedir ] [ -f | -v | -n ] -a\n" \ "\t\t[-m 'permission'] [-i 'identify_name']\n" \ "\t\t[-P privilege] [-p 'policy'] <driver_module>\n" \ - "\tupdate_drv [ -b basedir ] [ -f | -v ] -d\n" \ + "\tupdate_drv [ -b basedir ] [ -f | -v | -n ] -d\n" \ "\t\t[-m 'permission'] [-i 'identify_name']\n" \ "\t\t[-P privilege] [-p 'policy'] <driver_module>\n\n"\ "NOTE: at least one of m/i/P/p must be specified with -a and -d.\n" @@ -137,7 +135,8 @@ extern "C" { /* remdrv messages */ -#define REM_USAGE1 "Usage:\n\t rem_drv [ -C ] [ -b <basedir> ] driver_name\n" +#define REM_USAGE1 \ + "Usage:\n\t rem_drv [ -C ] [ -b <basedir> ] [ -n ] driver_name\n" #define ERR_NO_MAJ "Cannot get major number for : %s\n" #define ERR_UNLINK "Warning: Cannot remove %s from devfs namespace.\n" #define ERR_PIPE "System error : Cannot create pipe\n" diff --git a/usr/src/cmd/modload/rem_drv.c b/usr/src/cmd/modload/rem_drv.c index 2c872f3372..fe6fe5d5c8 100644 --- a/usr/src/cmd/modload/rem_drv.c +++ b/usr/src/cmd/modload/rem_drv.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -63,6 +61,7 @@ main(int argc, char *argv[]) char maj_num[MAX_STR_MAJOR + 1]; int cleanup = 0; int err; + int n_flag = 0; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ @@ -77,7 +76,7 @@ main(int argc, char *argv[]) exit(1); } - while ((opt = getopt(argc, argv, "b:C")) != -1) { + while ((opt = getopt(argc, argv, "b:Cn")) != -1) { switch (opt) { case 'b' : server = 1; @@ -91,6 +90,9 @@ main(int argc, char *argv[]) case 'C': cleanup = 1; break; + case 'n': + n_flag = 1; + break; case '?' : usage(); exit(1); @@ -143,7 +145,7 @@ main(int argc, char *argv[]) err_exit(); } - if (!server) { + if (n_flag == 0 && !server) { mod_unloaded = 1; /* get the module id for this driver */ @@ -187,7 +189,8 @@ main(int argc, char *argv[]) * If removing the driver from the running system, notify * kernel dynamically to remove minor perm entries. */ - if (basedir == NULL || (strcmp(basedir, "/") == 0)) { + if ((n_flag == 0) && + (basedir == NULL || (strcmp(basedir, "/") == 0))) { err = devfs_rm_minor_perm(driver_name, log_minorperm_error); if (err != 0) { (void) fprintf(stderr, gettext(ERR_UPDATE_PERM), @@ -206,7 +209,7 @@ main(int argc, char *argv[]) * to the system, newly created nodes won't incorrectly * pick up these stale shadow node permissions. */ - if (cleanup) { + if ((n_flag == 0) && cleanup) { if ((basedir == NULL || (strcmp(basedir, "/") == 0))) { err = modctl(MODREMDRVCLEANUP, driver_name, 0, NULL); if (err != 0) { diff --git a/usr/src/cmd/modload/update_drv.c b/usr/src/cmd/modload/update_drv.c index 962499c574..69651e2f2d 100644 --- a/usr/src/cmd/modload/update_drv.c +++ b/usr/src/cmd/modload/update_drv.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -91,6 +91,7 @@ main(int argc, char *argv[]) int i_flag = 0; /* -i option */ int l_flag = 0; /* -l option */ int m_flag = 0; /* -m option */ + int n_flag = 0; /* -n option */ char *perms = NULL; char *aliases = NULL; char *basedir = NULL; @@ -114,7 +115,7 @@ main(int argc, char *argv[]) exit(1); } - while ((opt = getopt(argc, argv, "m:i:b:p:adlfuvP:")) != EOF) { + while ((opt = getopt(argc, argv, "m:ni:b:p:adlfuvP:")) != EOF) { switch (opt) { case 'a': a_flag++; @@ -145,6 +146,10 @@ main(int argc, char *argv[]) m_flag++; perms = optarg; break; + case 'n': + n_flag++; + update_conf = 0; + break; case 'p': policy = optarg; break; @@ -212,7 +217,9 @@ main(int argc, char *argv[]) if ((check_name_to_major(R_OK)) == ERROR) err_exit(); - if (priv != NULL && check_priv_entry(priv, a_flag) != 0) + if ((n_flag == 0) && + (basedir == NULL || (strcmp(basedir, "/") == 0)) && + (priv != NULL) && check_priv_entry(priv, a_flag) != 0) err_exit(); if (policy != NULL && (policy = check_plcy_entry(policy, driver_name, @@ -233,7 +240,6 @@ main(int argc, char *argv[]) if ((error = check_perm_opts(perms)) == ERROR) { if (force_flag == 0) { /* no force flag */ exit_unlock(); - return (error); } } @@ -246,7 +252,6 @@ main(int argc, char *argv[]) (error = update_minor_entry(driver_name, perms))) { if (force_flag == 0) { /* no force flag */ exit_unlock(); - return (error); } } @@ -255,7 +260,8 @@ main(int argc, char *argv[]) /* * Notify running system of minor perm change */ - if (basedir == NULL || (strcmp(basedir, "/") == 0)) { + if ((n_flag == 0) && + (basedir == NULL || (strcmp(basedir, "/") == 0))) { rval = devfs_add_minor_perm(driver_name, log_minorperm_error); if (rval) { @@ -381,7 +387,8 @@ done: * We don't have any ability to do this singly * at this point. */ - if (basedir == NULL || (strcmp(basedir, "/") == 0)) { + if ((n_flag == 0) && + (basedir == NULL || (strcmp(basedir, "/") == 0))) { rval = devfs_rm_minor_perm(driver_name, log_minorperm_error); if (rval) { @@ -400,7 +407,8 @@ done: /* * Notify running system of new minor perm state */ - if (basedir == NULL || (strcmp(basedir, "/") == 0)) { + if ((n_flag == 0) && + (basedir == NULL || (strcmp(basedir, "/") == 0))) { rval = devfs_add_minor_perm(driver_name, log_minorperm_error); if (rval) { |
