Print this page
293 useradd/del/mod should be ZFS-aware

*** 48,58 **** #include "users.h" #include "messages.h" #include "funcs.h" /* ! * usermod [-u uid [-o] | -g group | -G group [[,group]...] | -d dir [-m] * | -s shell | -c comment | -l new_logname] * | -f inactive | -e expire ] * [ -A authorization [, authorization ...]] * [ -P profile [, profile ...]] * [ -R role [, role ...]] --- 48,59 ---- #include "users.h" #include "messages.h" #include "funcs.h" /* ! * usermod [-u uid [-o] | -g group | -G group [[,group]...] ! * | -d dir [-m [-z|Z]] * | -s shell | -c comment | -l new_logname] * | -f inactive | -e expire ] * [ -A authorization [, authorization ...]] * [ -P profile [, profile ...]] * [ -R role [, role ...]]
*** 80,90 **** * key=value - One or more -K options each specifying a valid user_attr(4) * attribute. * */ ! extern int **valid_lgroup(), isbusy(); extern int valid_uid(), check_perm(), create_home(), move_dir(); extern int valid_expire(), edit_group(), call_passmgmt(); extern projid_t **valid_lproject(); static uid_t uid; /* new uid */ --- 81,91 ---- * key=value - One or more -K options each specifying a valid user_attr(4) * attribute. * */ ! extern int **valid_lgroup(), isbusy(), get_default_zfs_flags(); extern int valid_uid(), check_perm(), create_home(), move_dir(); extern int valid_expire(), edit_group(), call_passmgmt(); extern projid_t **valid_lproject(); static uid_t uid; /* new uid */
*** 143,154 **** int main(argc, argv) int argc; char **argv; { ! int ch, ret = EX_SUCCESS, call_pass = 0, oflag = 0; ! int tries, mflag = 0, inact, **gidlist, flag = 0; boolean_t fail_if_busy = B_FALSE; char *ptr; struct passwd *pstruct; /* password struct for login */ struct passwd *pw; struct group *g_ptr; /* validated group from -g */ --- 144,155 ---- int main(argc, argv) int argc; char **argv; { ! int ch, ret = EX_SUCCESS, call_pass = 0, oflag = 0, zfs_flags = 0; ! int tries, mflag = 0, inact, **gidlist, flag = 0, zflag = 0, Zflag = 0; boolean_t fail_if_busy = B_FALSE; char *ptr; struct passwd *pstruct; /* password struct for login */ struct passwd *pw; struct group *g_ptr; /* validated group from -g */
*** 174,184 **** opterr = 0; /* no print errors from getopt */ /* get user type based on the program name */ usertype = getusertype(argv[0]); while ((ch = getopt(argc, argv, ! "c:d:e:f:G:g:l:mop:s:u:A:P:R:K:")) != EOF) switch (ch) { case 'c': comment = optarg; flag++; break; --- 175,185 ---- opterr = 0; /* no print errors from getopt */ /* get user type based on the program name */ usertype = getusertype(argv[0]); while ((ch = getopt(argc, argv, ! "c:d:e:f:G:g:l:mzZop:s:u:A:P:R:K:")) != EOF) switch (ch) { case 'c': comment = optarg; flag++; break;
*** 230,239 **** --- 231,246 ---- case 'u': uidstr = optarg; flag++; fail_if_busy = B_TRUE; break; + case 'Z': + Zflag++; + break; + case 'z': + zflag++; + break; case 'A': change_key(USERATTR_AUTHS_KW, optarg); flag++; break; case 'P':
*** 255,264 **** --- 262,281 ---- else errmsg(M_MUSAGE); exit(EX_SYNTAX); } + if (((!mflag) && (zflag || Zflag)) || (zflag && Zflag) || + (mflag > 1 && (zflag || Zflag))) { + if (is_role(usertype)) + errmsg(M_ARUSAGE); + else + errmsg(M_AUSAGE); + exit(EX_SYNTAX); + } + + if (optind != argc - 1 || flag == 0) { if (is_role(usertype)) errmsg(M_MRUSAGE); else errmsg(M_MUSAGE);
*** 488,501 **** pstruct->pw_gid, S_IWOTH|S_IXOTH) != 0) { errmsg(M_NO_PERM, logname, dir); exit(EX_NO_PERM); } ! } else ret = create_home(dir, NULL, uid, gid); if (ret == EX_SUCCESS) ! ret = move_dir(pstruct->pw_dir, dir, logname); if (ret != EX_SUCCESS) exit(ret); } --- 505,526 ---- pstruct->pw_gid, S_IWOTH|S_IXOTH) != 0) { errmsg(M_NO_PERM, logname, dir); exit(EX_NO_PERM); } ! } else { ! zfs_flags = get_default_zfs_flags(); ! if (zflag || mflag > 1) ! zfs_flags |= CHANGE_ZFS_FS; ! else if (Zflag) ! zfs_flags &= ~CHANGE_ZFS_FS; ! ret = create_home(dir, NULL, uid, gid, zfs_flags); ! } if (ret == EX_SUCCESS) ! ret = move_dir(pstruct->pw_dir, dir, ! logname, zfs_flags); if (ret != EX_SUCCESS) exit(ret); }