293 useradd/del/mod should be ZFS-aware

Review Request #97 — Created Sept. 19, 2015 and submitted

alp
illumos-gate
general

Modifies useradd, usermod and userdel to support ZFS filesystem creation and deletion.

Syntax is: useradd|usermod -m [-z|-Z] or userdel -r [-z|-Z]. Specifying -z option forces filesystem to be created/removed for user.
Default is set in /etc/default/useradd as CHANGE_ZFS_FS switch (yes enables filesystem creation/deletion logic), default is set to no.

Created new users with "useradd -m [-z|-Z] test" with and without CHANGE_ZFS_FS setting. Modified and deleted created user.

  • 0
  • 0
  • 11
  • 0
  • 11
Description From Last Updated
alp
tsoome
  1. as mentioned on irc, the userdel -z/-Z seem to overcomplicate the behaviour - I would rather think the -r is enough there. Not an blocker by me, but something to think about.
    
    I'm also still not convinced its good idea to fail back silently to mkdir() if the intention was to create zfs dataset for home. At least there should be message about fallback, but I think the error would be more appropriate - afterall the dataset was requested, and if the useradd is unable to provide it, it should give an error.
  2. 
      
alp
tsoome
  1. Ship It!
  2. 
      
trisk
  1. 
      
  2. usr/src/cmd/oamuser/user/Makefile (Diff revision 3)
     
     

    Extra spaces

  3. usr/src/cmd/oamuser/user/funcs.h (Diff revision 3)
     
     
     
     
     

    I'm not sure the meaning of the CHANGE_ZFS_FS option name is obvious, maybe MANAGE_ZFS or simply ENABLE_ZFS. Also looks like the value should be YES.

  4. usr/src/man/man1m/userdel.1m (Diff revision 3)
     
     
     
     
     

    "If the user's home directory is located on a separate ZFS filesystem and the \fB/etc/default/useradd\fR file contains the parameter \fBxxx\fR set to the value \fBYES\fR, the file system will be destroyed.

    If \fB-z\fR option is specified, \fBuserdel\fR will always try to destroy an existing file system for the home directory.
    If \fB-Z\fR option is specified, an existing file system will never be destroyed.

  5. 
      
alp
alp
trisk
  1. 
      
  2. usr/src/cmd/oamuser/user/messages.c (Diff revision 5)
     
     

    "Avoided"

  3. usr/src/man/man1m/useradd.1m (Diff revision 5)
     
     
     
     
     
     
     
     

    "If the parent directory of the user's home directory is located on a separate \fBZFS\fR
    file system and the \fB/etc/default/useradd\fR file contains the parameter
    \fBMANAGE_ZFS\fR set to the value \fBYES\f, a new ZFS filesystem will be created
    for the user.
    If \fB-z\fR option is specified, \fBuseradd\fR will always try to create a new
    file system for the home directory.
    If \fB-Z\fR option is specified, a new file system will never be created."

  4. usr/src/man/man1m/useradd.1m (Diff revision 5)
     
     

    Suggest adding "\fBzfs\fR(1M)" here, as well as to SEE ALSO in the other manpages.

  5. usr/src/man/man1m/userdel.1m (Diff revision 5)
     
     
     
     

    "If the user's home directory is located on a separate ZFS file system and the \fB/etc/default/useradd\fR file contains the parameter \fBMANAGE_ZFS\fR set to the value \fBYES\fR, the file system will be destroyed.

  6. usr/src/man/man1m/userdel.1m (Diff revision 5)
     
     
     
     

    "If the user's home directory is located on a separate \fBZFS\fR file system and the
    \fB/etc/default/useradd\fR file contains the parameter \fBMANAGE_ZFS\fB set to the
    value \fBYES\fB, the file system will be destroyed."

  7. usr/src/man/man1m/userdel.1m (Diff revision 5)
     
     

    Suggest adding "\fBzfs\fR(1M)" to the SEE ALSO list.

  8. usr/src/man/man1m/usermod.1m (Diff revision 5)
     
     

    "If the user's old home directory was located on a separate \fBZFS\fR file system and the
    \fB/etc/default/useradd\fR file contains the parameter \fBMANAGE_ZFS\fR set to the
    value \fBYES\fR, the file system will be destroyed after the home directory is moved.
    If parent directory of the user's new home directory is located on a separate ZFS file system and the \fB/etc/default/useradd\fR file contains the parameter
    \fBMANAGE_ZFS\fR set to the value \fBYES\fR, a new ZFS file system will be created.
    If \fB-z\fR option is specified, \fBusermod\fR will always try to create a new
    file system for the home directory and destroy the old one.
    If \fB-Z\fR option is specified, a new file system will never be created, and old
    one will never be destroyed."

  9. usr/src/man/man1m/usermod.1m (Diff revision 5)
     
     

    Same as others for SEE ALSO.

  10. 
      
alp
trisk
  1. Last set of minor grammar and formatting issues in the manpage. Feel free to leave strncmp if you don't want to change it.

  2. usr/src/cmd/oamuser/user/homedir.c (Diff revision 6)
     
     

    strcmp is appropriate here, as it is guaranteed to terminate after reading at most strlen("/") + 1 characters.

  3. usr/src/cmd/oamuser/user/homedir.c (Diff revision 6)
     
     

    strcmp is also safe here.

  4. usr/src/man/man1m/useradd.1m (Diff revision 6)
     
     

    ```.sp
    If the parent directory of the user's home directory is located on a separate
    \fBZFS\fR file system and the \fB/etc/default/useradd\fR file contains the
    parameter \fBMANAGE_ZFS\fR set to the value \fBYES\fR, a new \fBZFS\fR
    file system will be created for the user.

    If the \fB-z\fR option is specified, \fBuseradd\fR will always try to create a new
    file system for the home directory.
    .sp
    If the \fB-Z\fR option is specified, a new file system will never be created.```

    "If the" and "file system" (to be consistent with rest of man page), and .sp for paragraph separators (please verify the .RS indent is consistent with the previous lines when viewed, my troff is not very good)

  5. usr/src/man/man1m/userdel.1m (Diff revision 6)
     
     

    \fBZFS\fR file system, and .sp between the paragraphs.

  6. usr/src/man/man1m/usermod.1m (Diff revision 6)
     
     

    .sp
    If the user's old home directory was located on a separate \fBZFS\fR file system
    and the \fB/etc/default/useradd\fR file contains the parameter \fBMANAGE_ZFS\fR
    set to the value \fBYES\fR, the file system will be destroyed after the home
    directory is moved. If parent directory of the user's new home directory is
    located on a separate \fBZFS\fR filesystem and the \fB/etc/default/useradd\fR
    file contains the parameter \fBMANAGE_ZFS\fR set to the value \fBYES\fR, a new
    \fBZFS\fR filesystem will be created.
    .sp
    If the \fB-z\fR option is specified, \fBusermod\fR will always try to create a new
    file system for the home directory and destroy the old one.
    .sp
    If the \fB-Z\fR option is specified, a new file system will never be created, and the old
    one will never be destroyed.
    

    (sorry, think this is the last time :)

  7. 
      
alp
trisk
  1. Ship It!
  2. 
      
alp
tsoome
  1. Ship It!
  2. 
      
alp
Review request changed

Status: Closed (submitted)

Loading...