aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zfs/zfs_main.c7
-rw-r--r--cmd/zpool/zpool_main.c26
2 files changed, 18 insertions, 15 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 7525afcbf..8bcff2dba 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -610,7 +610,12 @@ zfs_mount_and_share(libzfs_handle_t *hdl, const char *dataset, zfs_type_t type)
*/
if (zfs_prop_valid_for_type(ZFS_PROP_CANMOUNT, type, B_FALSE) &&
zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_ON) {
- if (zfs_mount(zhp, NULL, 0) != 0) {
+ if (geteuid() != 0) {
+ (void) fprintf(stderr, gettext("filesystem "
+ "successfully created, but it may only be "
+ "mounted by root\n"));
+ ret = 1;
+ } else if (zfs_mount(zhp, NULL, 0) != 0) {
(void) fprintf(stderr, gettext("filesystem "
"successfully created, but not mounted\n"));
ret = 1;
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 588af4b69..9041f9c33 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -42,7 +42,6 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
-#include <priv.h>
#include <pwd.h>
#include <zone.h>
#include <zfs_prop.h>
@@ -2331,21 +2330,20 @@ zpool_do_import(int argc, char **argv)
(void) fprintf(stderr, gettext("too many arguments\n"));
usage(B_FALSE);
}
+ }
- /*
- * Check for the SYS_CONFIG privilege. We do this explicitly
- * here because otherwise any attempt to discover pools will
- * silently fail.
- */
- if (argc == 0 && !priv_ineffect(PRIV_SYS_CONFIG)) {
- (void) fprintf(stderr, gettext("cannot "
- "discover pools: permission denied\n"));
- if (searchdirs != NULL)
- free(searchdirs);
+ /*
+ * Check for the effective uid. We do this explicitly here because
+ * otherwise any attempt to discover pools will silently fail.
+ */
+ if (argc == 0 && geteuid() != 0) {
+ (void) fprintf(stderr, gettext("cannot "
+ "discover pools: permission denied\n"));
+ if (searchdirs != NULL)
+ free(searchdirs);
- nvlist_free(policy);
- return (1);
- }
+ nvlist_free(policy);
+ return (1);
}
/*