| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: Directory Lists and ListOptions</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b>Directory Lists and <code>ListOptions</code></b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | The <code><a href="../modules/mod_ls.html#ListOptions">ListOptions</a></code> |
| 15 | directive of ProFTPD can be used to control how directory listings are |
| 16 | generated. Directory listings are sent in response to the <code>LIST</code> |
| 17 | and <code>NLST</code> FTP commands. |
| 18 | |
| 19 | <p> |
| 20 | The <code>ListOptions</code> directive supports the following options: |
| 21 | <ul> |
| 22 | <li><dt>-1</dt> |
| 23 | <dd>List one file per line</dd> |
| 24 | </li> |
| 25 | |
| 26 | <li><dt>-A</dt> |
| 27 | <dd>List all files except "." and ".."</dd> |
| 28 | </li> |
| 29 | |
| 30 | <li><dt>-a</dt> |
| 31 | <dd>List all files including those whose names start with "."</dd> |
| 32 | </li> |
| 33 | |
| 34 | <li><dt>-B</dt> |
| 35 | <dd>Force printing of non-printable filename characters as \<i>xxx</i>, where <i>xxx</i> is the octal value of the character</dd> |
| 36 | </li> |
| 37 | |
| 38 | <li><dt>-C</dt> |
| 39 | <dd>List entries by columns</dd> |
| 40 | </li> |
| 41 | |
| 42 | <li><dt>-c<dt> |
| 43 | <dd>Sort by file status change time when <code>-t</code> is also used</dd> |
| 44 | </li> |
| 45 | |
| 46 | <li><dt>-d</dt> |
| 47 | <dd>List directory entries instead of directory contents</dd> |
| 48 | </li> |
| 49 | |
| 50 | <li><dt>-F</dt> |
| 51 | <dd>Append file type indicator (one of "*", "/", "=", "@" or "|") to names</dd> |
| 52 | </li> |
| 53 | |
| 54 | <li><dt>-h</dt> |
| 55 | <dd>Print file sizes in human-readable format (<i>e.g.</i> 1K, 234M, 2G)</dd> |
| 56 | </li> |
| 57 | |
| 58 | <li><dt>-L</dt> |
| 59 | <dd>List files pointed to by symlinks</dd> |
| 60 | </li> |
| 61 | |
| 62 | <li><dt>-l</dt> |
| 63 | <dd>Use a long listing format</dd> |
| 64 | </li> |
| 65 | |
| 66 | <li><dt>-n</dt> |
| 67 | <dd>List numeric UIDs/GIDs instead of user/group names</dd> |
| 68 | </li> |
| 69 | |
| 70 | <li><dt>-R</dt> |
| 71 | <dd>List subdirectories recursively</dd> |
| 72 | </li> |
| 73 | |
| 74 | <li><dt>-r</dt> |
| 75 | <dd>Sort filenames in reverse order</dd> |
| 76 | </li> |
| 77 | |
| 78 | <li><dt>-S</dt> |
| 79 | <dd>Sort by file size</dd> |
| 80 | </li> |
| 81 | |
| 82 | <li><dt>-t</dt> |
| 83 | <dd>Sort by file modification time</dd> |
| 84 | </li> |
| 85 | |
| 86 | <li><dt>-U<dt> |
| 87 | <dd>Do not sort; list entries in directory order</dd> |
| 88 | </li> |
| 89 | |
| 90 | <li><dt>-u<dt> |
| 91 | <dd>Sort by file access time when <code>-t</code> is also used</dd> |
| 92 | </li> |
| 93 | </ul> |
| 94 | |
| 95 | <p> |
| 96 | Although not strictly supported by the FTP RFCs, many FTP clients send these |
| 97 | options with the <code>LIST</code> and <code>NLST</code> commands, and many |
| 98 | FTP servers honor them. The <code>ListOptions</code> directive configures |
| 99 | default options to be used, in addition to any sent by the client. For |
| 100 | example, to show all files except the "hidden" files for clients, |
| 101 | you could use: |
| 102 | <pre> |
| 103 | ListOptions -a |
| 104 | </pre> |
| 105 | |
| 106 | <p> |
| 107 | Another use of <code>ListOptions</code> is to <i>prevent</i> certain options |
| 108 | from being used. The <code>-R</code> option, for recursively listing |
| 109 | all subdirectories, can use a lot of system resources, especially on very |
| 110 | large and/or very deep directory structures, as <code>proftpd</code> scans |
| 111 | all of the files. For this reason, some sites may wish to prevent the |
| 112 | <code>-R</code> option from being used. <code>ListOptions</code> supports |
| 113 | this with use of the "+" character. Options are enabled using the |
| 114 | "-" character, thus they are disabled using "+"--think |
| 115 | of the "+" as cancelling out the "-". For example: |
| 116 | <pre> |
| 117 | ListOptions +R strict |
| 118 | </pre> |
| 119 | would disable all use of the <code>-R</code> option. |
| 120 | |
| 121 | <p> |
| 122 | Where did the <code>strict</code> come from in the example above? |
| 123 | <code>ListOptions</code> configures a set of default options, but if a client |
| 124 | sends its own directory options, <code>proftpd</code> will use the client's |
| 125 | options instead. To ignore the client options and use <i>only</i> the |
| 126 | <code>ListOptions</code> configured, one uses the "strict" keyword. |
| 127 | That is why the <code>+R</code> example above required |
| 128 | "strict"--it causes <code>proftpd</code> to ignore any |
| 129 | <code>-R</code> option the client might send. |
| 130 | |
| 131 | <p> |
| 132 | What if you wanted to enable some options and disable others in the same |
| 133 | <code>ListOptions</code> directive? You would surround your options in quotation marks, like so: |
| 134 | <pre> |
| 135 | ListOptions "-a +R" strict |
| 136 | </pre> |
| 137 | |
| 138 | <p> |
| 139 | If you are <b>not</b> using the <code>--enable-nls</code> configure option, |
| 140 | <i>and</i> you want to see non-printable characters in filenames when listing |
| 141 | directories, you should use: |
| 142 | <pre> |
| 143 | ListOptions -B |
| 144 | </pre> |
| 145 | |
| 146 | <p> |
| 147 | The following keywords are supported, in addition to "strict": |
| 148 | <ul> |
| 149 | <li><dt>maxfiles</dt> |
| 150 | <dd>Sets a maximum limit on the number of files listed in one directory listing</dd> |
| 151 | <li><dt>maxdirs</dt> |
| 152 | <dd>Sets a maximum limit on the number of directories listed in one directory listing</dd> |
| 153 | <li><dt>maxdepth</dt> |
| 154 | <dd>Sets a maximum recursion depth, if the <code>-R</code> option is allowed</dd> |
| 155 | <li><dt>LISTOnly</dt> |
| 156 | <dd>Applies the <code>ListOptions</code> only to <code>LIST</code> commands (and not <code>NLST</code> or <code>STAT</code> commands) |
| 157 | <li><dt>NLSTOnly</dt> |
| 158 | <dd>Applies the <code>ListOptions</code> only to <code>NLST</code> commands (and not <code>LIST</code> or <code>STAT</code> commands) |
| 159 | <li><dt>NoErrorIfAbsent</dt> |
| 160 | <dd>Causes a 226 response code to be returned for <code>LIST/NLST</code> commands for files which do not exist, rather than 450 |
| 161 | <li><dt>SortedNLST</dt> |
| 162 | <dd>Causes the <code>NLST</code> results to be sorted by name |
| 163 | </ul> |
| 164 | These keywords were added for finer-grained control over directory listings. |
| 165 | They make it possible to allow recursive listings and yet still apply limits, |
| 166 | to keep the recursion from taking too long: |
| 167 | <pre> |
| 168 | ListOptions -a maxfiles 2000 maxdepth 3 |
| 169 | </pre> |
| 170 | This configures the <code>-a</code> option by default, and limits the maximum |
| 171 | files in the generated listing to 2000. If the client uses the <code>-R</code> |
| 172 | option, <code>proftpd</code> will not recurse into directories more than 3 |
| 173 | levels deep when generating the listing. |
| 174 | |
| 175 | <p> |
| 176 | Or perhaps you want the one-file-per-line format, but only for |
| 177 | <code>NLST</code> commands and <b>not</b> <code>LIST</code> commands. You |
| 178 | would thus use something like: |
| 179 | <pre> |
| 180 | ListOptions "-1" strict NLSTOnly |
| 181 | </pre> |
| 182 | |
| 183 | <p> |
| 184 | Note that <code><a href="Limit.html"><Limit></a></code> sections can be |
| 185 | used to block the <code>LIST</code> and <code>NLST</code> commands altogether. |
| 186 | |
| 187 | <p> |
| 188 | <hr> |
| 189 | <font size=2><b><i> |
| 190 | © Copyright 2017 The ProFTPD Project<br> |
| 191 | All Rights Reserved<br> |
| 192 | </i></b></font> |
| 193 | <hr> |
| 194 | |
| 195 | </body> |
| 196 | </html> |