Skip to content

Commit

Permalink
Allow commands that can succeed without root priv to do so.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovezfs committed May 19, 2014
1 parent 0e0de79 commit 72d8832
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5770,7 +5770,11 @@ main(int argc, char **argv)
if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0)
usage(B_TRUE);

if (getuid()) printf("ZFS requires 'root' user permission to work on OS X.\nPreceed the command with 'sudo' and try again.\n");
#ifdef __OPPLE__
if (getuid())
printf("ZFS requires 'root' user permission to work on OS X.\n"
"Precede the command with 'sudo' and try again.\n");
#endif /* __OPPLE__ */

if ((g_zfs = libzfs_init()) == NULL)
return (1);
Expand Down
15 changes: 14 additions & 1 deletion lib/libspl/include/priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
#define _LIBSPL_PRIV_H

#include <sys/types.h>
#include <unistd.h>
#include <assert.h>

#ifdef __LINUX__
/* Couldn't find this definition in OpenGrok */
#define PRIV_SYS_CONFIG "sys_config"

Expand All @@ -40,7 +43,17 @@ typedef enum priv_op {
PRIV_OFF,
PRIV_SET
} priv_op_t;
#endif /* __LINUX__ */

#define PRIV_SYS_CONFIG 0

static __inline int
priv_ineffect(int priv)
{

assert(priv == PRIV_SYS_CONFIG);
return (geteuid() == 0);
}

static inline boolean_t priv_ineffect(const char *priv) { return B_TRUE; }

#endif
6 changes: 5 additions & 1 deletion module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5714,9 +5714,11 @@ zfsdev_ioctl(dev_t dev, u_long cmd, caddr_t arg, __unused int xflag, struct pro

//printf("ioctl minor %d\n", minor);

#ifdef __OPPLE__
error = proc_suser(p); /* Are we superman? */
if (error)
return (error); /* Nope... */
#endif /* __OPPLE__ */

// If minor > 0 it is an ioctl for zvol!
if (minor != 0 &&
Expand Down Expand Up @@ -5930,9 +5932,11 @@ static struct miscdevice zfs_misc = {
static int
zfsdev_bioctl(dev_t dev, u_long cmd, caddr_t data, __unused int flag, struct proc *p)
{
#ifdef __OPPLE__
int error;
error = proc_suser(p); /* Are we superman? */
if (error) return (error); /* Nope... */
#endif /* __OPPLE__ */
return (zvol_ioctl(dev, cmd, data, 1, NULL, NULL));
}

Expand Down Expand Up @@ -5985,7 +5989,7 @@ mnttab_file_create(void)
int oflags = FCREAT;

if ((error = vn_open(MNTTAB, UIO_SYSSPACE,
oflags, 0644, &vp, CRCREAT, 0)) == 0) {
oflags, 0666, &vp, CRCREAT, 0)) == 0) {
if ((error =VOP_FSYNC(vp, FSYNC, kcred,
NULL)) == 0) {
error = VOP_CLOSE(vp, oflags, 1, 0,
Expand Down

0 comments on commit 72d8832

Please sign in to comment.