| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: CreateHome</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b>ProFTPD's <code>CreateHome</code></b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | <b>What is <code>CreateHome</code>?</b><br> |
| 15 | When a site has many user accounts, with users being added and removed |
| 16 | constantly, there is always the associated procedure of creating and removing |
| 17 | those user's home directories. And often, in such situations, the user |
| 18 | account information is stored in a SQL database or an LDAP server. A |
| 19 | <code>proftpd</code> daemon can be configured to authenticate against the |
| 20 | SQL database or the LDAP server; this would still leave the task of creating |
| 21 | the actual home directory for that user to be done.. What would help ease this |
| 22 | particular burden on system administrators, though, is the ability to add the |
| 23 | account information and have the new user's home directory created <i>on |
| 24 | demand</i>. That is, to have a daemon such as <code>proftpd</code> create |
| 25 | the home directory for the user, if that directory did not already exist. |
| 26 | |
| 27 | <p> |
| 28 | Now, <code>proftpd</code> already has some modules, such as <code>mod_sql</code> |
| 29 | and <code>mod_ldap</code> that already support this home-on-demand creation |
| 30 | capability. Each module implements it slightly differently, though. And |
| 31 | other authentication modules, such as <code>mod_radius</code>, do not support |
| 32 | it at all. It was decided then, rather than having authentication modules |
| 33 | have largely duplicated code for this feature, to have home-on-demand |
| 34 | creation in the core <code>daemon</code> itself. And so it is. |
| 35 | As of 1.2.8rc2, <code>proftpd</code> has the |
| 36 | <a href="../modules/mod_auth.html#CreateHome"><code>CreateHome</code></a> |
| 37 | configuration directive. |
| 38 | |
| 39 | <p> |
| 40 | <b>How to use <code>CreateHome</code></b><br> |
| 41 | The description for this configuration directive shows its parameters to be: |
| 42 | <pre> |
| 43 | CreateHome off|on [<mode>] [skel <path>] [dirmode <mode>] [uid <uid>] [gid <gid>] [homegid <gid>] [NoRootPrivs] |
| 44 | </pre> |
| 45 | The first parameter is a simple Boolean, enabling or disabling the |
| 46 | <code>proftpd</code> daemon's run-time support for home directory creation. |
| 47 | The rest of the parameters are optional, and only apply if |
| 48 | <code>CreateHome</code> is <em>on</em>. |
| 49 | |
| 50 | <p> |
| 51 | There is the first <em>mode</em> parameter, used to set the directory mode on |
| 52 | the home directory being created. As described in the documentation, if this |
| 53 | parameter is omitted the mode used will default to 0700. There is also the |
| 54 | <code>dirmode</code> <em>mode</em> parameter, which is slightly different. |
| 55 | The <code>dirmode</code> keyword informs the daemon that the following mode |
| 56 | is to be used on directories that may need to be created in order to create |
| 57 | the home directory. For example, let's assume that a new user, david, is |
| 58 | logging in. User david has been given the home directory |
| 59 | <code>/home/users/d/da/david</code>. Since this is a new user, the |
| 60 | directory does not exist. In fact, <code>/home/users/d</code> does not exist. |
| 61 | When this happens, <code>proftpd</code> will create the <code>d</code>, |
| 62 | <code>da</code>, and <code>david</code> directories. A <code>dirmode</code> |
| 63 | mode would be applied to the <code>d</code> and <code>da</code> directories, |
| 64 | and the <em>mode</em> (no <code>dirmode</code> keyword) would be applied to |
| 65 | the final <code>david</code> directory. To illustrate this, assume that |
| 66 | the following <code>CreateHome</code> configuration is in use: |
| 67 | <pre> |
| 68 | CreateHome on 700 dirmode 711 |
| 69 | </pre> |
| 70 | A directory listing would show only the <code>/home/users</code> directory: |
| 71 | <pre> |
| 72 | drwxr-xr-x 6 root root 4096 Jan 31 13:23 /home/users |
| 73 | </pre> |
| 74 | After user david logs in, a directory listing might show the new directories |
| 75 | that have been created: |
| 76 | <pre> |
| 77 | drwxr-xr-x 6 root root 4096 Jan 31 13:23 /home/users |
| 78 | drwx--x--x 6 root root 4096 Jan 31 13:23 /home/users/d |
| 79 | drwx--x--x 6 root root 4096 Jan 31 13:23 /home/users/d/da |
| 80 | drwx------ 6 david david 4096 Jan 31 13:23 /home/users/d/da/david |
| 81 | </pre> |
| 82 | Notice how <code>/home/users/d</code> and <code>/home/users/d/da</code> have |
| 83 | <code>dirmode</code> mode of 711 (<code>rwx--x--x</code>) while |
| 84 | <code>/home/users/d/da/david</code> has the mode of 700 |
| 85 | (<code>rwx------</code>). |
| 86 | |
| 87 | <p> |
| 88 | As an added feature, <code>CreateHome</code> also supports the ability to |
| 89 | populate these newly created home directories. This is done by configuring |
| 90 | a "skeleton" directory that will contain files (<i>e.g.</i> |
| 91 | shell initialization files, documentation, notices, subdirectories, etc) |
| 92 | that should be in every new user's home directory. This is done using |
| 93 | the <code>skel</code> <em>path</em> parameter. |
| 94 | |
| 95 | <p> |
| 96 | Be sure to read the documentation for the <code>CreateHome</code> directive, |
| 97 | for there are some restrictions and caveats to both the <code>dirmode</code> |
| 98 | and <code>skel</code> parameters. |
| 99 | |
| 100 | <p> |
| 101 | The <code>uid</code> and <code>gid</code> parameters can be used to set the |
| 102 | ownership of the newly created parent directories, up to <b>but not |
| 103 | including</b> the home directory. By default, those created parent directories |
| 104 | are owned by root (UID 0 and GID 0). |
| 105 | |
| 106 | <p> |
| 107 | The <code>homegid</code> parameter can be used to specify the group ownership |
| 108 | of the target home directory itself. By default, this home directory will |
| 109 | be owned by the user's primary GID. |
| 110 | |
| 111 | <p> |
| 112 | The <code>NoRootPrivs</code> parameter can be used to prevent ProFTPD from |
| 113 | using root privileges when creating the home directory and parents. This can be |
| 114 | useful for <i>e.g.</i> the case where home directories are on NFS mounts which |
| 115 | have root squashing enabled. When the <code>NoRootPrivs</code> option is |
| 116 | used, the home directory in question will be <i>created using the identity |
| 117 | of the logging-in user</i>. |
| 118 | |
| 119 | <p> |
| 120 | Here are some examples (from the documentation) to help illustrate how one |
| 121 | might use the <code>CreateHome</code> configuration directive: |
| 122 | <pre> |
| 123 | <font color=green># Use the CreateHome default settings</font> |
| 124 | CreateHome on |
| 125 | |
| 126 | <font color=green># Specify a mode of 711 for the created home directory</font> |
| 127 | CreateHome on 711 |
| 128 | |
| 129 | <font color=green># Specify a mode of 711, and have the parent directories owned by a specific non-root UID/GID</font> |
| 130 | CreateHome on 711 uid 100 gid 100 |
| 131 | |
| 132 | <font color=green># Specify a mode of 711, and have the parent directories owned by the UID/GID of the logging-in user</font> |
| 133 | CreateHome on 711 uid ~ gid ~ |
| 134 | |
| 135 | <font color=green># Specify a skeleton directory</font> |
| 136 | CreateHome on skel /etc/ftpd/skel |
| 137 | |
| 138 | <font color=green># No skeleton, but make sure that intermediate directories have 755 |
| 139 | # permissions.</font> |
| 140 | CreateHome on dirmode 755 |
| 141 | |
| 142 | <font color=green># Skeleton directory, with 700 intermediate directories</font> |
| 143 | CreateHome on skel /etc/ftpd/skel dirmode 700 |
| 144 | |
| 145 | <font color=green># Explicitly configure everything, CreateHome-wise</font> |
| 146 | CreateHome on 711 skel /etc/ftpd/skel dirmode 700 |
| 147 | |
| 148 | <font color=green># Explicitly configure everything, CreateHome-wise. And do NOT use root privileges when |
| 149 | # creating the parent directories.</font> |
| 150 | CreateHome on 711 skel /etc/ftpd/skel dirmode 700 NoRootPrivs |
| 151 | </pre> |
| 152 | |
| 153 | <p> |
| 154 | <b>When to use <code>CreateHome</code></b><br> |
| 155 | "What about the prior configuration directives for <code>mod_sql</code> |
| 156 | and <code>mod_ldap</code>?" one asks. The <code>CreateHome</code> |
| 157 | configuration directive supersedes them. Those previous module-specific |
| 158 | directives may well be deprecated in the future, in favor of |
| 159 | <code>CreateHome</code>. Future authentication modules need not try to |
| 160 | reinvent this particular wheel. <code>CreateHome</code> was designed for |
| 161 | large sites in mind, but can be used any time home-on-demand creation is |
| 162 | desired from the FTP daemon. |
| 163 | |
| 164 | <p><a name="FAQ"></a> |
| 165 | <b>FAQ</b> |
| 166 | |
| 167 | <p> |
| 168 | <font color=red>Question</font>: Is it possible to have different permissions |
| 169 | for the <code>CreateHome</code> <em>mode</em> and <em>dirmode</em> based on the |
| 170 | group of the connecting user?<br> |
| 171 | <font color=blue>Answer</font>: Yes, if you use the <a href="../contrib/mod_ifsession.html"><code>mod_ifsession</code></a> module. |
| 172 | For example: |
| 173 | <pre> |
| 174 | <IfGroup special> |
| 175 | CreateHome on 755 dirmode 755 |
| 176 | </IfGroup> |
| 177 | |
| 178 | <IfGroup !special> |
| 179 | CreateHome on 711 dirmode 711 |
| 180 | </IfGroup> |
| 181 | </pre> |
| 182 | |
| 183 | <p> |
| 184 | <hr> |
| 185 | <font size=2><b><i> |
| 186 | © Copyright 2017 The ProFTPD Project<br> |
| 187 | All Rights Reserved<br> |
| 188 | </i></b></font> |
| 189 | <hr> |
| 190 | |
| 191 | </body> |
| 192 | </html> |