| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: Debugging</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b><i>ProFTPD: Debugging Problems</i></b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | Users of ProFTPD will often encounters problems. It happens with all software, |
| 15 | not just ProFTPD. How, then, does the user track down the cause of the |
| 16 | problem, and fix it? This is the art of debugging. When users post these |
| 17 | problems are the mailing lists, it is extremely helpful to include the |
| 18 | following bits of information to help find the answer. Even better is when the |
| 19 | user follows these steps and determines the solution for themselves. |
| 20 | |
| 21 | <p> |
| 22 | Keep in mind that <code>proftpd</code> runs on quite a few different platforms, |
| 23 | including Linux (and its various distributions), Solaris, Mac OSX, various BSDs, |
| 24 | etc. So please, when reporting issues, <b>include as much information as you |
| 25 | can</b>. Saying something like "latest Ubuntu/CentOS/Fedora", or "stable |
| 26 | Debian", or "FreeBSD ports", does not mean that much to those of us who don't |
| 27 | run/use those platforms. |
| 28 | |
| 29 | <p> |
| 30 | We <b>want</b> to help you, but to do that, we need to know as many details as |
| 31 | possible. One goal is for us to be able to reproduce the issue locally. That's |
| 32 | why providing the `proftpd -V' output, and the <code>proftpd.conf</code>, the |
| 33 | debug logging, and a description of the behavior you <b><i>expect</i></b> (as |
| 34 | well as what you actually <b><i>observed</i></b>) is so important. These |
| 35 | things help us to recreate the setup, and the circumstances, locally. And |
| 36 | once we can see the same issue on our machines, we can help that much more |
| 37 | rapidly with the solution. |
| 38 | |
| 39 | <p> |
| 40 | You will hear requests for these details come up quite a bit. It's worth |
| 41 | pointing out why that is. |
| 42 | |
| 43 | <p> |
| 44 | <b>Know the Version</b><br> |
| 45 | Various problems afflict various versions of the code, so when tracking down |
| 46 | problems, it is good to know the version being used: |
| 47 | <pre> |
| 48 | $ proftpd -V |
| 49 | $ proftpd -vv |
| 50 | </pre> |
| 51 | When reporting issues, please include the output from <i>both</i> of these |
| 52 | commands. |
| 53 | |
| 54 | <p> |
| 55 | It is possible that the problem you are encountering is due to some bug |
| 56 | that may already be fixed in a more current version, fixed in the CVS |
| 57 | repository, or has a bug report with an attached patch. Searching |
| 58 | <a href="http://bugs.proftpd.org">http://bugs.proftpd.org</a> will often |
| 59 | yield useful information, depending on the keywords used in the search. |
| 60 | |
| 61 | <p> |
| 62 | <b>Know the Modules</b><br> |
| 63 | System administrators who compile and install the server from the source |
| 64 | code distribution will probably already know this, but administrators who |
| 65 | install using RPMs or other package formats may not know the specifics of |
| 66 | the contained pre-built binary. To list the modules compiled into the |
| 67 | server: |
| 68 | <pre> |
| 69 | $ proftpd -l |
| 70 | </pre> |
| 71 | Knowing the modules helps to pinpoint the source of error messages (<i>e.g.</i> |
| 72 | <code>mod_tls</code> and certificate files). |
| 73 | |
| 74 | <p> |
| 75 | <b>Perform Configuration Check</b><br> |
| 76 | When making changes to the configuration file, it is often helpful to make sure |
| 77 | that your changes are valid. The easiest way to do this is to do an |
| 78 | informative syntax check: |
| 79 | <pre> |
| 80 | $ proftpd -td10 |
| 81 | </pre> |
| 82 | The <code>-t</code> option directs the server to only do a syntax check, to |
| 83 | parse the configuration file but stop before actually starting its operations |
| 84 | as a server. The <code>-d10</code> will cause the server to display debugging |
| 85 | messages during this testing of the configuration file. Another useful |
| 86 | command is: |
| 87 | <pre> |
| 88 | $ proftpd -c <i>/path/to/new/config/file</i> -td10 |
| 89 | </pre> |
| 90 | which lets you test the syntax of some new configuration file before it |
| 91 | is put into production. |
| 92 | |
| 93 | <p> |
| 94 | If you are still having problems, and you have verified that your |
| 95 | <code>proftpd.conf</code> is correct, the next step is see what debugging |
| 96 | messages are generated during an FTP session, as described next. |
| 97 | |
| 98 | <p> |
| 99 | <b>Collect Debug Information</b><br> |
| 100 | <code>proftpd</code> has built-in debug information reporting capabilities - |
| 101 | the trick is in enabling that reporting, and tracking down where it is sent. |
| 102 | The easiest way to get the debugging information is to start the server from |
| 103 | the command line using: |
| 104 | <pre> |
| 105 | $ proftpd -nd10 |
| 106 | </pre> |
| 107 | <b>Note</b>: make sure that no other <code>proftpd</code> instances are |
| 108 | running before using this command, otherwise you will see: |
| 109 | <pre> |
| 110 | Failed binding to 0.0.0.0, port 21: Address already in use |
| 111 | </pre> |
| 112 | This message means that some other program is already bound to the socket |
| 113 | at that address/port. This message will also appear if you attempt the |
| 114 | debugging command with a <code>ServerType</code> of <code>inetd</code>; this |
| 115 | is described below. |
| 116 | |
| 117 | <p> |
| 118 | Once working, the above debugging command will display lots of information on |
| 119 | the connected terminal's screen, both as the server starts up and during the |
| 120 | servicing of any clients. If clients are having trouble logging in or |
| 121 | authenticating, the debug messages reported by the server when a client |
| 122 | connects are much more useful than knowing the messages displayed by the |
| 123 | client, as the client does not know <i>why</i> it cannot log in. If asked to |
| 124 | send debugging information to the mailing list, you can send the relevant |
| 125 | snippets (if you know what the relevant debug messages are), or you can |
| 126 | capture the debug output to a file: |
| 127 | <pre> |
| 128 | $ proftpd -nd10 2>&1 >& /path/to/debug/file |
| 129 | </pre> |
| 130 | and send that file, compressed, along with your post. |
| 131 | |
| 132 | <p> |
| 133 | The above method works if you have <code>ServerType standalone</code> in your |
| 134 | configuration file. If you run the server in <code>inetd</code> mode instead, |
| 135 | and are unable or unwilling to make the changes necessary to run the server |
| 136 | in <code>standalone</code> mode for the sake of debugging, then use of the |
| 137 | <code>SystemLog</code> configuration directive is necessary for capturing the |
| 138 | debug information. Add this directive to your configuration file, and add |
| 139 | <code>-d5</code> to your <code>/etc/inetd.conf</code>'s <code>ftp</code> line, |
| 140 | or to the <code>server_args</code> tag in your <code>xinetd</code> |
| 141 | configuration file for the server. Be sure to restart |
| 142 | <code>inetd/xinetd</code> so that your configuration changes will take effect. |
| 143 | |
| 144 | <p> |
| 145 | Note that use of the <code>SystemLog</code> directive is not necessarily |
| 146 | confined to <code>inetd</code> mode servers. If you are interested in letting |
| 147 | your <code>standalone</code> server run unattended and want to have that |
| 148 | debugging information in the log file, use <code>SystemLog</code> and |
| 149 | add <code>-d5</code> (or whatever your preferred debug level is) to the |
| 150 | server startup script. |
| 151 | |
| 152 | <p> |
| 153 | As of version 1.2.8rc1, ProFTPD supports a |
| 154 | <a href="../modules/mod_core.html#DebugLevel"><code>DebugLevel</code></a> |
| 155 | configuration directive. This lets you set a debugging level in your |
| 156 | <code>proftpd.conf</code> file, without needing to edit <code>inetd.conf</code> |
| 157 | or <code>xinetd</code> configuration file. |
| 158 | |
| 159 | <p> |
| 160 | <b>Locate Log Files</b><br> |
| 161 | A common response on the mailing lists to a posted question is: "What |
| 162 | do your server logs say?" Locating the server's log files can be |
| 163 | troublesome, depending on your configuration. If the |
| 164 | <a href="../modules/mod_log.html#SystemLog"><code>SystemLog</code></a> |
| 165 | configuration directive is in effect, you know exactly where the server's log |
| 166 | file is. If not, then by default the server uses <code>syslog</code> for |
| 167 | logging. The location of <code>syslog</code>'d log files is set in your |
| 168 | system's <code>/etc/syslog.conf</code> file. You may need to read your |
| 169 | system's man pages for <code>syslog.conf</code> or <code>syslogd</code> to |
| 170 | understand the format of that file. Note that the server will log using a |
| 171 | <code>syslog</code> facility of <code>daemon</code> (and level |
| 172 | <code>debug</code> when debugging) for most of its messages; during |
| 173 | authentication, messages are logged using the <code>authpriv</code> facility. |
| 174 | |
| 175 | <p> |
| 176 | <b>Debugging Segfaults</b><br> |
| 177 | If you see a message like the following in your logs: |
| 178 | <pre> |
| 179 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - ProFTPD terminating (signal 11) |
| 180 | </pre> |
| 181 | then you have most likely encountered a segfault. This is a particular |
| 182 | bad error, and can be hard to track down. |
| 183 | |
| 184 | <p> |
| 185 | In version 1.3.1rc1, ProFTPD gained the ability to provide better logging |
| 186 | to help track down these sorts of bugs. To enable this ability, you will |
| 187 | need to configure <code>proftpd</code> with something like: |
| 188 | <pre> |
| 189 | $ ./configure --enable-devel=stacktrace ... |
| 190 | </pre> |
| 191 | and run your <code>proftpd</code> like normal. If a segfault occurs, the logs |
| 192 | should show something like this: |
| 193 | <pre> |
| 194 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - ProFTPD terminating (signal 11) |
| 195 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - FTP session closed. |
| 196 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - -----BEGIN STACK TRACE----- |
| 197 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [0] ./proftpd [0x809b1e1] |
| 198 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [1] ./proftpd(call_module+0x53) [0x8072c63] |
| 199 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [2] ./proftpd(strftime+0x14cf) [0x8051bef] |
| 200 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [3] ./proftpd(pr_cmd_dispatch+0x167) [0x8051f2f] |
| 201 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [4] ./proftpd(strftime+0x1fd3) [0x80526f3] |
| 202 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [5] ./proftpd [0x8053e12] |
| 203 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [6] ./proftpd [0x805484d] |
| 204 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [7] ./proftpd [0x8057975] |
| 205 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [8] ./proftpd(main+0x9d1) [0x8058625] |
| 206 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [9] /lib/i686/libc.so.6(__libc_start_main+0x93) [0x40076507] |
| 207 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - [10] ./proftpd(strcpy+0x31) [0x8051001] |
| 208 | golem.castaglia.org (127.0.0.1[127.0.0.1]) - -----END STACK TRACE----- |
| 209 | </pre> |
| 210 | These stack symbols are generated automatically by glibc, and may or may |
| 211 | not contain the function names. |
| 212 | |
| 213 | <p> |
| 214 | The key here for tracking down the location of the segfault is that |
| 215 | <code>[0]</code> frame, and the memory address: <code>0x809b1e1</code>. Using |
| 216 | that address and a very handy command called <code>addr2line</code>, you can |
| 217 | determine the location of that address in the source code: |
| 218 | <pre> |
| 219 | $ addrline -e ./proftpd 0x809b1e1 |
| 220 | </pre> |
| 221 | In this example, I saw: |
| 222 | <pre> |
| 223 | $ addr2line -e ./proftpd 0x809b1e1 |
| 224 | /home/tj/proftpd/cvs/proftpd/modules/mod_auth.c:1723 |
| 225 | </pre> |
| 226 | which is the location of test code added to trigger the segfault. |
| 227 | |
| 228 | <p> |
| 229 | This feature is specific to glibc systems, so keep that in mind. Other things |
| 230 | to mention about this feature: it disables the changing of the process title |
| 231 | that <code>proftpd</code> normally does. The obtaining of the stack symbols |
| 232 | that glibc does uses the process title, and if this feature did not disable |
| 233 | that process title changing, the output would be much less legible. Also, it |
| 234 | does not work if the process which receives the <code>SIGSEGV</code> signal is |
| 235 | chrooted. (Blame glibc for its bad handling of being chrooted.) To work |
| 236 | around this, I would recommend using the <code>mod_vroot</code> module, just |
| 237 | for a short period of time, in order to get a useful automatic stack trace. |
| 238 | |
| 239 | <p> |
| 240 | <b>Common Problems</b><br> |
| 241 | One common question is: "I changed the configuration file, but the new |
| 242 | configuration is not being seen!" The solution depends on your configured |
| 243 | <a href="ServerType.html"><code>ServerType</code></a>. Almost certainly it |
| 244 | will be <code>standalone</code>, as <code>inetd</code>-mode servers pick up |
| 245 | configuration changes almost instantly (the server is started from the ground |
| 246 | up for each connection). For configuration changes to be seen by a |
| 247 | <code>standalone</code> server, you need to either stop, then start the server |
| 248 | (the hard way), or to send the <code>HUP</code> signal the the daemon process. |
| 249 | |
| 250 | <p> |
| 251 | Another common question involves use of ProFTPD's <code><Limit></code> |
| 252 | directive to restrict certain FTP commands. These limits always function |
| 253 | <b>in addition to</b> the normal filesystem permissions, <b>not</b> instead |
| 254 | of them. If having problems writing, deleting, or updating files, check |
| 255 | your directory and file permissions first. |
| 256 | |
| 257 | <p> |
| 258 | Once you have the debug output and various other information, and are still |
| 259 | in need of help, search the FAQ, Userguide, and mailing list archives for |
| 260 | material related to the problem. If you're unable to find anything helpful |
| 261 | in these sources, post your question to the appropriate mailing list. Be |
| 262 | sure to include the version used, your <code>proftpd.conf</code>, and possibly |
| 263 | any debug information. |
| 264 | |
| 265 | <p> |
| 266 | The following document describes how to ask good questions that are likely to |
| 267 | be answered: |
| 268 | <pre> |
| 269 | <a href="http://www.catb.org/~esr/faqs/smart-questions.html">http://www.catb.org/~esr/faqs/smart-questions.html</a> |
| 270 | </pre> |
| 271 | |
| 272 | <p> |
| 273 | <hr> |
| 274 | <font size=2><b><i> |
| 275 | © Copyright 2017 The ProFTPD Project<br> |
| 276 | All Rights Reserved<br> |
| 277 | </i></b></font> |
| 278 | <hr> |
| 279 | |
| 280 | </body> |
| 281 | </html> |