summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorDhanaraj M <Dhanaraj.M@Sun.COM>2009-09-18 21:31:59 -0700
committerDhanaraj M <Dhanaraj.M@Sun.COM>2009-09-18 21:31:59 -0700
commit17e9b2b79f1b6ad823020c5671e72cfa3fc10c7e (patch)
treefb1cf307ce90c1b35833eb9ef0f30c25e0ac8fc1 /usr/src
parentf25619f6cf945650c50a819c0023b568b28ca6d5 (diff)
downloadillumos-gate-17e9b2b79f1b6ad823020c5671e72cfa3fc10c7e.tar.gz
6818386 devfsadm generates error messages inside a native non-global zone
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/autopush/autopush.c17
-rw-r--r--usr/src/cmd/devfsadm/devfsadm.c6
-rw-r--r--usr/src/cmd/devfsadm/message.h3
-rw-r--r--usr/src/cmd/modload/add_drv.c6
-rw-r--r--usr/src/cmd/modload/errmsg.h2
-rw-r--r--usr/src/cmd/modload/modload.c15
-rw-r--r--usr/src/cmd/modload/modunload.c22
-rw-r--r--usr/src/cmd/modload/rem_drv.c6
8 files changed, 55 insertions, 22 deletions
diff --git a/usr/src/cmd/autopush/autopush.c b/usr/src/cmd/autopush/autopush.c
index 00617f7da3..676bbcd13f 100644
--- a/usr/src/cmd/autopush/autopush.c
+++ b/usr/src/cmd/autopush/autopush.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,8 +27,6 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* autopush(1) is the command interface to the STREAMS autopush
* mechanism. The autopush command can be used to configure autopush
@@ -74,6 +71,7 @@
#include <string.h>
#include <locale.h>
#include <sys/stat.h>
+#include <zone.h>
#define OPTIONS "M:f:gm:r" /* command line options for getopt(3C) */
#define COMMENT '#'
@@ -207,6 +205,13 @@ main(int argc, char *argv[])
usage();
exit(1);
}
+
+ if (getzoneid() != GLOBAL_ZONEID) {
+ (void) fprintf(stderr, gettext("autopush "
+ "can only be run from the global zone.\n"));
+ exit(1);
+ }
+
if (fflag)
exitcode = set_info(filenamep);
else if (rflag)
diff --git a/usr/src/cmd/devfsadm/devfsadm.c b/usr/src/cmd/devfsadm/devfsadm.c
index b1baf57b86..9d4a751ea3 100644
--- a/usr/src/cmd/devfsadm/devfsadm.c
+++ b/usr/src/cmd/devfsadm/devfsadm.c
@@ -42,6 +42,7 @@
#include <utime.h>
#include <sys/param.h>
#include <bsm/libbsm.h>
+#include <zone.h>
#include "devfsadm_impl.h"
/* externs from devalloc.c */
@@ -267,6 +268,11 @@ main(int argc, char *argv[])
/*NOTREACHED*/
}
+ if (getzoneid() != GLOBAL_ZONEID) {
+ err_print(MUST_BE_GLOBAL_ZONE);
+ devfsadm_exit(1);
+ }
+
/*
* Close all files except stdin/stdout/stderr
*/
diff --git a/usr/src/cmd/devfsadm/message.h b/usr/src/cmd/devfsadm/message.h
index 1c5b3d8f02..d2feecbe47 100644
--- a/usr/src/cmd/devfsadm/message.h
+++ b/usr/src/cmd/devfsadm/message.h
@@ -255,6 +255,9 @@ major_number ]\n\t\t[ -n ]\n\t\t[ -r rootdir ]\n\t\t[ -v ]\n")
#define ZONE_PATHCHECK \
gettext("cannot manage root path '%s': path is part of zone '%s'\n")
+#define MUST_BE_GLOBAL_ZONE \
+ gettext("can only be run from the global zone\n")
+
#define DEVNAME_CONTACT_FAILED \
gettext("cannot talk to devname fs %s: %s\n")
diff --git a/usr/src/cmd/modload/add_drv.c b/usr/src/cmd/modload/add_drv.c
index 77fc715a78..fdcd90dba3 100644
--- a/usr/src/cmd/modload/add_drv.c
+++ b/usr/src/cmd/modload/add_drv.c
@@ -42,6 +42,7 @@
#include <libdevinfo.h>
#include <sys/sysmacros.h>
#include <fcntl.h>
+#include <zone.h>
#include "addrem.h"
#include "errmsg.h"
#include "plcysubr.h"
@@ -200,6 +201,11 @@ main(int argc, char *argv[])
exit(1);
}
+ if (getzoneid() != GLOBAL_ZONEID) {
+ (void) fprintf(stderr, gettext(ERR_NOT_GLOBAL_ZONE));
+ exit(1);
+ }
+
/*
* Fail if add_drv was invoked with a pathname prepended to the
* driver_name argument.
diff --git a/usr/src/cmd/modload/errmsg.h b/usr/src/cmd/modload/errmsg.h
index db8e931b81..dc51b783f0 100644
--- a/usr/src/cmd/modload/errmsg.h
+++ b/usr/src/cmd/modload/errmsg.h
@@ -63,6 +63,8 @@ extern "C" {
#define ERR_FORK_FAIL "Fork failed; cannot exec : %s\n"
#define ERR_PROG_IN_USE "add_drv/rem_drv currently busy; try later\n"
#define ERR_NOT_ROOT "You must be root to run this program.\n"
+#define ERR_NOT_GLOBAL_ZONE \
+"add_drv/rem_drv can only be run from the global zone.\n"
#define ERR_BAD_LINE "Bad line in file %s : %s\n"
#define ERR_CANNOT_OPEN "Cannot open (%s): %s.\n"
#define ERR_MIS_TOK "Option (%s) : missing token: (%s)\n"
diff --git a/usr/src/cmd/modload/modload.c b/usr/src/cmd/modload/modload.c
index b0147570bc..2d528b3759 100644
--- a/usr/src/cmd/modload/modload.c
+++ b/usr/src/cmd/modload/modload.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 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 <sys/types.h>
#include <sys/wait.h>
#include <sys/param.h>
@@ -37,6 +34,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include <zone.h>
void l_exec_userfile(char *execfile, int id, char **envp);
void l_usage();
@@ -75,6 +73,11 @@ main(int argc, char *argv[], char *envp[])
l_usage();
}
}
+
+ if (getzoneid() != GLOBAL_ZONEID) {
+ fatal("modload can only be run from the global zone\n");
+ }
+
modpath = argv[optind];
if (modpath == NULL) {
diff --git a/usr/src/cmd/modload/modunload.c b/usr/src/cmd/modload/modunload.c
index 2c404f34f1..f57a4b54ff 100644
--- a/usr/src/cmd/modload/modunload.c
+++ b/usr/src/cmd/modload/modunload.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2003 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 <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -36,6 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/modctl.h>
+#include <zone.h>
void usage();
void exec_userfile(char *execfile, int id, char **envp);
@@ -70,6 +68,10 @@ main(int argc, char *argv[], char *envp[])
}
}
+ if (getzoneid() != GLOBAL_ZONEID) {
+ fatal("modunload can only be run from the global zone\n");
+ }
+
if (execfile) {
child = fork();
if (child == -1)
@@ -90,10 +92,10 @@ main(int argc, char *argv[], char *envp[])
* Unload the module.
*/
if (modctl(MODUNLOAD, id) < 0) {
- if (errno == EPERM)
- fatal("Insufficient privileges to unload a module\n");
- else if (id != 0)
- error("can't unload the module");
+ if (errno == EPERM)
+ fatal("Insufficient privileges to unload a module\n");
+ else if (id != 0)
+ error("can't unload the module");
}
return (0); /* success */
diff --git a/usr/src/cmd/modload/rem_drv.c b/usr/src/cmd/modload/rem_drv.c
index 62adb1137b..14b6d45959 100644
--- a/usr/src/cmd/modload/rem_drv.c
+++ b/usr/src/cmd/modload/rem_drv.c
@@ -42,6 +42,7 @@
#include <sys/modctl.h>
#include <sys/instance.h>
#include <libdevinfo.h>
+#include <zone.h>
#include "addrem.h"
#include "errmsg.h"
@@ -120,6 +121,11 @@ main(int argc, char *argv[])
exit(1);
}
+ if (getzoneid() != GLOBAL_ZONEID) {
+ (void) fprintf(stderr, gettext(ERR_NOT_GLOBAL_ZONE));
+ exit(1);
+ }
+
/* set up add_drv filenames */
if ((build_filenames(basedir)) == ERROR) {
exit(1);