| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD module mod_auth_file</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b>ProFTPD module <code>mod_auth_file</code></b></h2> |
| 12 | </center> |
| 13 | <hr><br> |
| 14 | |
| 15 | <p> |
| 16 | This module is contained in the <code>mod_auth_file.c</code> file for |
| 17 | ProFTPD 1.3.<i>x</i>, and is compiled by default. |
| 18 | |
| 19 | <h2>Directives</h2> |
| 20 | <ul> |
| 21 | <li><a href="#AuthFileOptions">AuthFileOptions</a> |
| 22 | <li><a href="#AuthGroupFile">AuthGroupFile</a> |
| 23 | <li><a href="#AuthUserFile">AuthUserFile</a> |
| 24 | </ul> |
| 25 | |
| 26 | <hr> |
| 27 | <h3><a name="AuthFileOptions">AuthFileOptions</a></h3> |
| 28 | <strong>Syntax:</strong> AuthFileOptions <em>opt1 ...</em><br> |
| 29 | <strong>Default:</strong> None<br> |
| 30 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 31 | <strong>Module:</strong> mod_auth_file<br> |
| 32 | <strong>Compatibility:</strong> 1.3.7rc1 |
| 33 | |
| 34 | <p> |
| 35 | The <code>AuthFileOptions</code> directive is used to configure various optional |
| 36 | behavior of <code>mod_auth_file</code>. |
| 37 | |
| 38 | <p> |
| 39 | Example: |
| 40 | <pre> |
| 41 | AuthFileOptions InsecurePerms |
| 42 | </pre> |
| 43 | |
| 44 | <p> |
| 45 | The currently implemented options are: |
| 46 | <ul> |
| 47 | <p> |
| 48 | <li><code>InsecurePerms</code><br> |
| 49 | <p> |
| 50 | When this option is used, <code>mod_auth_file</code> will ignore insecure |
| 51 | permissions (<i>i.e.</i> group- or world-readable) on |
| 52 | <code>AuthUserFile</code> and <code>AuthGroupFile</code> files. |
| 53 | |
| 54 | <p> |
| 55 | <b>Note</b> that this option <b>must</b> appear <em>before</em> any |
| 56 | <code>AuthUserFile</code> and <code>AuthGroupFile</code> directives in |
| 57 | order to function properly, for the option changes the behavior of the |
| 58 | <code>mod_auth_file</code> module at <i>parse</i> time. |
| 59 | |
| 60 | <p> |
| 61 | <b>Note</b> that this option first appeared in |
| 62 | <code>proftpd-1.3.7rc1</code>. |
| 63 | </li> |
| 64 | |
| 65 | <p> |
| 66 | <li><code>SyntaxCheck</code><br> |
| 67 | <p> |
| 68 | When this option is used, <code>mod_auth_file</code> will |
| 69 | |
| 70 | When this option is used, <code>mod_auth_file</code> will perform syntax |
| 71 | checks on <code>AuthUserFile</code> and <code>AuthGroupFile</code> files. |
| 72 | If any of the files have syntax errors, <code>mod_auth_file</code> will |
| 73 | cause ProFTPD to fail to start up. |
| 74 | |
| 75 | <p> |
| 76 | <b>Note</b> that this option <b>must</b> appear <em>before</em> any |
| 77 | <code>AuthUserFile</code> and <code>AuthGroupFile</code> directives in |
| 78 | order to function properly, for the option changes the behavior of the |
| 79 | <code>mod_auth_file</code> module at <i>parse</i> time. |
| 80 | |
| 81 | <p> |
| 82 | <b>Note</b> that this option first appeared in |
| 83 | <code>proftpd-1.3.8rc1</code>. |
| 84 | </li> |
| 85 | </ul> |
| 86 | |
| 87 | <p> |
| 88 | <hr> |
| 89 | <h3><a name="AuthGroupFile">AuthGroupFile</a></h3> |
| 90 | <strong>Syntax:</strong> AuthGroupFile <em>path [id min-max] [name regex]</em><br> |
| 91 | <strong>Default:</strong> None<br> |
| 92 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 93 | <strong>Module:</strong> mod_auth_file<br> |
| 94 | <strong>Compatibility:</strong> 1.2.7rc2 |
| 95 | |
| 96 | <p> |
| 97 | The <code>AuthGroupFile</code> directive configures an alternate group file for |
| 98 | providing group membership information; the specified file must have the same |
| 99 | format as the system <code>/etc/group</code> file, and if specified is used |
| 100 | during authentication and group lookups for directory/access control |
| 101 | operations. The <em>path</em> argument should be the full path to the specified |
| 102 | file. This directive can be configured on a per-server basis, so that virtual |
| 103 | FTP servers can each have their own authentication file, often in conjunction |
| 104 | with an <a href="#AuthUserFile"><code>AuthUserFile</code></a>. |
| 105 | |
| 106 | <p> |
| 107 | Note that this file does <i>not</i> need to reside inside a |
| 108 | <code>chroot()</code>ed directory structure for anonymous or |
| 109 | <code>DefaultRoot</code> logins, as it is held open for the duration of a |
| 110 | session. |
| 111 | |
| 112 | <p> |
| 113 | The optional parameters are used to set restrictions on the contents of |
| 114 | the specified file. The <em>id</em> restriction is used to specify a range |
| 115 | of GIDs that may appear in the file; when doing a lookup, if a group entry |
| 116 | has a GID that is less than the minimum or greater than the maximum is |
| 117 | encountered, that entry is ignored. The <em>name</em> restriction is used |
| 118 | to specify a regular expression that is applied to the name of a group |
| 119 | entry. If the group name does not match the regular expression, the group |
| 120 | entry is ignored. A leading <code>!</code> in the regular expression can |
| 121 | be used to negate the given expression. |
| 122 | |
| 123 | <p> |
| 124 | Example: |
| 125 | <pre> |
| 126 | # This makes an AuthGroupFile that can only have GIDs 2000 to 4000, and |
| 127 | # whose groups must start with 'cust' |
| 128 | AuthGroupFile /etc/ftpd/group id 2000-4000 name ^cust |
| 129 | </pre> |
| 130 | |
| 131 | <p> |
| 132 | <b>Note</b>: In order to prevent other users from modifying the |
| 133 | <code>AuthGroupFile</code>, the <code>mod_auth_file</code> module |
| 134 | <b>requires</b> that the permissions on the file <b>not</b> be world-readable |
| 135 | <b>or</b> world-writable, <b>and</b> that the directory containing the |
| 136 | file <b>not</b> be world-writable. In addition, if the file is not a file |
| 137 | (<i>e.g.</i> the path points to a symlink, or a FIFO, <i>etc</i>), a warning |
| 138 | will be logged on server startup/restart. |
| 139 | |
| 140 | <p> |
| 141 | <hr> |
| 142 | <h3><a name="AuthUserFile">AuthUserFile</a></h3> |
| 143 | <strong>Syntax:</strong> AuthUserFile <em>path [id min-max] [home regex] [name regex]</em><br> |
| 144 | <strong>Default:</strong> None<br> |
| 145 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 146 | <strong>Module:</strong> mod_auth_file<br> |
| 147 | <strong>Compatibility:</strong> 1.2.7rc2 |
| 148 | |
| 149 | <p> |
| 150 | The <code>AuthUserFile</code> directive configures an alternate passwd file for |
| 151 | providing user account information; the specified file must have the same |
| 152 | format as the system <code>/etc/passwd</code> file, and if specified is used |
| 153 | during authentication and user lookups for directory/access control operations. |
| 154 | The <em>path</em> argument should be the full path to the specified file. This |
| 155 | directive can be configured on a per-server basis, so that virtual FTP servers |
| 156 | can each have their own authentication file, often in conjunction with an |
| 157 | <a href="#AuthGroupFile"><code>AuthGroupFile</code></a>. |
| 158 | |
| 159 | <p> |
| 160 | Note that this file does <i>not</i> need to reside inside a |
| 161 | <code>chroot()</code>ed directory structure for anonymous or |
| 162 | <code>DefaultRoot</code> logins, as it is held open for the duration of a |
| 163 | session. |
| 164 | |
| 165 | <p> |
| 166 | The optional parameters are used to set restrictions on the contents of |
| 167 | the specified file. The <em>id</em> restriction is used to specify a range |
| 168 | of UIDs that may appear in the file; when doing a lookup, if a user entry |
| 169 | has a UID that is less than the minimum or greater than the maximum is |
| 170 | encountered, that entry is ignored. The <em>home</em> restriction is used |
| 171 | to specify a regular expression that is applied to the home directory of a user |
| 172 | entry. If the home does not match the regular expression, the user entry |
| 173 | is ignored. The <em>name</em> restriction is used to specify a regular |
| 174 | expression that is applied to the name of a user entry. If the user name does |
| 175 | not match the regular expression, the user entry is ignored. A leading |
| 176 | <code>!</code> in these regular expressions can be used to negate the given |
| 177 | expression. |
| 178 | |
| 179 | <p> |
| 180 | Example: |
| 181 | <pre> |
| 182 | # This makes an AuthUserFile whose user names must start with 'ftp', and |
| 183 | # whose homes cannot start with /home. |
| 184 | AuthUserFile /etc/ftpd/passwd name ^ftp home !^/home |
| 185 | </pre> |
| 186 | |
| 187 | <p> |
| 188 | <b>Note</b>: In order to prevent other users from modifying the |
| 189 | <code>AuthUserFile</code>, the <code>mod_auth_file</code> module |
| 190 | <b>requires</b> that the permissions on the file <b>not</b> be world-readable |
| 191 | <b>or</b> world-writable, <b>and</b> that the directory containing the |
| 192 | file <b>not</b> be world-writable. In addition, if the file is not a file |
| 193 | (<i>e.g.</i> the path points to a symlink, or a FIFO, <i>etc</i>), a warning |
| 194 | will be logged on server startup/restart. |
| 195 | |
| 196 | <p> |
| 197 | <hr> |
| 198 | <h2><a name="Installation">Installation</a></h2> |
| 199 | The <code>mod_auth_file</code> module is compiled by default. |
| 200 | |
| 201 | <p> |
| 202 | <b>Logging</b><br> |
| 203 | The <code>mod_auth_file</code> module supports <a href="../howto/Tracing.html">trace logging</a>, via the module-specific log channels: |
| 204 | <ul> |
| 205 | <li>auth.file |
| 206 | </ul> |
| 207 | Thus for trace logging, to aid in debugging, you would use the following in |
| 208 | your <code>proftpd.conf</code>: |
| 209 | <pre> |
| 210 | TraceLog /path/to/ftpd/trace.log |
| 211 | Trace auth.file:20 |
| 212 | </pre> |
| 213 | This trace logging can generate large files; it is intended for debugging use |
| 214 | only, and should be removed from any production configuration. |
| 215 | |
| 216 | <p><a name="FAQ"> |
| 217 | <b>Frequently Asked Questions</b><br> |
| 218 | |
| 219 | <p><a name="Password8Characters"> |
| 220 | <font color=red>Question</font>: I found that only the first 8 characters of |
| 221 | passwords are used! This is a security bug!<br> |
| 222 | <font color=blue>Answer</font>: No, it is not. |
| 223 | |
| 224 | <p> |
| 225 | The default Unix password hashing scheme uses the <a href="http://en.wikipedia.org/wiki/Data_Encryption_Standard">Data Encryption Standard</a> (DES) algorithm. |
| 226 | As per the <code>crypt(3)</code> man page, <b>only the first 8 characters |
| 227 | of the password are used</b>. Thus this 8 character limitation comes from |
| 228 | the underlying system authentication, <b>not</b> from proftpd. The whole |
| 229 | purpose of the PAM system was to enable replacing the use of DES with other |
| 230 | authentication algorithms, which do not have this 8 character limitation. |
| 231 | |
| 232 | <p> |
| 233 | Later, other <code>crypt(3)</code> implementations were made which can also |
| 234 | support algorithms such as MD5, or Blowfish. Some platforms support these |
| 235 | enhanced versions of <code>crypt(3)</code>, some do not. The |
| 236 | <a href="../utils/ftpasswd.html"><code>ftpasswd</code></a> script can generate |
| 237 | <code>AuthUserFiles</code> which use the MD5 algorithm instead of DES. |
| 238 | |
| 239 | <p><a name="AuthFilePermissions"> |
| 240 | <font color=red>Question</font>: Why does <code>mod_auth_file</code> refuse |
| 241 | to use an <code>AuthUserFile</code> (or <code>AuthGroupFile</code>) that is |
| 242 | world-readable/writable? I see messages like the following logged: |
| 243 | <pre> |
| 244 | mod_auth_file/1.0: unable to use world-readable AuthUserFile '/etc/proftpd/ftpd.passwd' |
| 245 | </pre> |
| 246 | or: |
| 247 | <pre> |
| 248 | mod_auth_file/1.0: unable to use world-writable AuthUserFile '/etc/proftpd/ftpd.passwd' |
| 249 | </pre> |
| 250 | <br> |
| 251 | <font color=blue>Answer</font>: If an <code>AuthUserFile</code> or |
| 252 | <code>AuthGroupFile</code> is world-writable, then <b>any user on the system |
| 253 | can edit that file</b>. They can create new users, or change the entries |
| 254 | for existing users such that those users have different privileges, perhaps |
| 255 | even root privileges. In short, having <code>AuthUserFile</code> or |
| 256 | <code>AuthGroupFile</code> with world-writable permissions is an unsafe |
| 257 | configuration, and now <code>mod_auth_file</code> prevents this. |
| 258 | |
| 259 | <p> |
| 260 | If the <code>AuthUserFile</code> is world-readable, then <b>any user on the |
| 261 | system can read that file</b>, including the hashed password. This can allow |
| 262 | for offline dictionary/cracking attempts against those hashes. This is also an |
| 263 | unsafe configuration, and thus <code>mod_auth_file</code> does not allow |
| 264 | world-readable <code>AuthUserFiles</code>. |
| 265 | |
| 266 | <p> |
| 267 | Similarly, <code>mod_auth_file</code> will refuse to use an |
| 268 | <code>AuthUserFile</code> or <code>AuthGroupFile</code> if that file lives |
| 269 | in a directory, and that directory has world-writable permissions (even if |
| 270 | the configured file itself is <b>not</b> world-writable). A world-writable |
| 271 | directory would allow <b>any system user to delete the <code>AuthUserFile</code></b>, and add their own, or to add a symlink, <i>etc</i>. It is another |
| 272 | unsafe configuration against which <code>mod_auth_file</code> now guards. |
| 273 | |
| 274 | <p> |
| 275 | <hr> |
| 276 | <font size=2><b><i> |
| 277 | © Copyright 2002-2021 The ProFTPD Project<br> |
| 278 | All Rights Reserved<br> |
| 279 | </i></b></font> |
| 280 | <hr> |
| 281 | |
| 282 | </body> |
| 283 | </html> |