dshoreman / servidor

A modern web application for managing servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a way of setting home directories

dshoreman opened this issue · comments

Currently there's no way to create/set a home directory for a user when you're adding or updating it.

The field should be optional and, to save adding an extra switch, the respective useradd/usermod flags to enable/create the home directory should only be passed when the field isn't blank.

Relevant flags from the man page:

   -b, --base-dir BASE_DIR
       The default base directory for the system if -d HOME_DIR is not specified.  
		BASE_DIR is concatenated with the account name to define the home directory.  
		If the -m option is not used, BASE_DIR must exist.

   -d, --home-dir HOME_DIR
       The new user will be created using HOME_DIR as the value for the user's login  
		directory. The default is to append the LOGIN name to BASE_DIR and use that  
		as the login directory name. The directory HOME_DIR does not have to exist  
		but will not be created if it is missing.

   -m, --create-home
       Create the user's home directory if it does not exist. The files
        and directories contained in the skeleton directory (which can be
        defined with the -k option) will be copied to the home directory.

       By default, if this option is not specified and CREATE_HOME
        is not enabled, no home directories are created.

   -M, --no-create-home
       Do no create the user's home directory, even if the system wide  
		setting from /etc/login.defs (CREATE_HOME) is set to yes.

   -U, --user-group
       Create a group with the same name as the user, and add the user to this group.

       The default behavior (if the -g, -N, and -U options are not specified)
        is defined by the USERGROUPS_ENAB variable in /etc/login.defs.

   -N, --no-user-group
       Do not create a group with the same name as the user, but add  
		the user to the group specified by the -g option or by the  
		GROUP variable in /etc/default/useradd.

       The default behavior (if the -g, -N, and -U options are not specified)  
		is defined by the USERGROUPS_ENAB variable in /etc/login.defs.

The above flags are specific to useradd. For usermod, only the following flags apply:

   -d, --home HOME_DIR
       The user's new login directory.

       If the -m option is given, the contents of the current home directory
        will be moved to the new home directory, which is created if it does
        not already exist.

   -m, --move-home
       Move the content of the user's home directory to the new location.

       This option is only valid in combination with the -d (or --home) option.

       usermod will try to adapt the ownership of the files and to copy the modes,
        ACL and extended attributes, but manual changes might be needed afterwards.