Developer Options
OK, so you think you want to use the --enable-devel
configure
option? You must keep in mind that this option is intended only for
development purposes; it is not recommended for use in production
builds or packages. If you are using a proftpd
installed
from a package, try this command:
$ /usr/local/sbin/proftpd -V
if you see "+ Developer support" in the output, it means that your
package provider used the --enable-devel
option when they
should not have. Let the package provider know about this, and point them
to this document.
Still here? If so, you are ready to learn how --enable-devel
is used for development and debugging. The --enable-devel
option, like many of ProFTPD's configure options, takes a colon-delimited
list of option names. The full list of supported developer options is
shown here:
$ ./configure --enable-devel=coredump:nodaemon:nofork:profile:stacktrace ...
You can also use just --enable-devel
by itself, without any
specific option names:
$ ./configure --enable-devel ...
When --enable-devel
is used, the executables that are installed
by the ProFTPD build system will not be stripped of their debugging symbols,
as is usually done in non-developer builds.
Let's look at what each one of these developer options does.
Enabling coredumps using the coredump
option is a bad idea.
ProFTPD goes out of its way to ensure that it does not generate coredump
files. Since the proftpd
server is usually run with root
privileges (in order to use port 21, look up passwords, etc), any
coredump files generated could possibly contain sensitive information (such as
users' passwords). The only people who should be looking at coredump files are
developers, and even then there are better ways of debugging issues.
Note that if the coredump
option is used, proftpd will
not switch the UID/GID to the User
/Group
defined in the config file, nor to that of the logged-in user. Unix kernels
are notoriously picky about generating coredumps for processes that have
changed their effective UID/GID; they won't do it. Thus the ID switching
is disabled in order to make it possible to get a coredump. Again, it is
a bad idea to run a proftpd built with coredump
in
production.
The nodaemon
option makes it such that the proftpd
server cannot daemonize. It cannot detach from the terminal, and
cannot run in the background. This is mostly useful for running
proftpd
under a debugger such as gdb
.
The nofork
option makes a proftpd
that cannot
use the fork(2)
system call to create a new process to handle
the client connection, turning proftpd
into a single-process
server. Like the nodaemon
option, this is useful mainly for
running proftpd
under a debugger.
The profile
option causes a profiling library to be linked into
the compiled proftpd
executable. Running the executable will
then automatically write out profiling information suitable for use by
a profiler such as gprof
.
Finally, there is the stacktrace
option. It is possible, if the
GNU C library is used, to have a program automatically provide a stack trace
showing the function call stack, such as when the SIGSEGV
signal
is received (i.e. the program segfaulted). Often times when debugging
issues like segfaults, the hardest part is pinpointing the exact source
of the segfault, and what functions were called to reach that point. Thus
seeing a stack trace (also called a "backtrace") is quite useful for
developers.
Let's say you configured the build for stacktrace support:
$ ./configure --enable-devel=stacktrace ...
If/when a SIGSEGV occurs, the logs should show something like this:
golem.castaglia.org (127.0.0.1[127.0.0.1]) - ProFTPD terminating (signal 11)
golem.castaglia.org (127.0.0.1[127.0.0.1]) - FTP session closed.
golem.castaglia.org (127.0.0.1[127.0.0.1]) - -----BEGIN STACK TRACE-----
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [0] ./proftpd [0x809b1e1]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [1] ./proftpd(call_module+0x53) [0x8072c63]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [2] ./proftpd(strftime+0x14cf) [0x8051bef]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [3] ./proftpd(pr_cmd_dispatch+0x167) [0x8051f2f]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [4] ./proftpd(strftime+0x1fd3) [0x80526f3]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [5] ./proftpd [0x8053e12]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [6] ./proftpd [0x805484d]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [7] ./proftpd [0x8057975]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [8] ./proftpd(main+0x9d1) [0x8058625]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [9] /lib/i686/libc.so.6(__libc_start_main+0x93) [0x40076507]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - [10] ./proftpd(strcpy+0x31) [0x8051001]
golem.castaglia.org (127.0.0.1[127.0.0.1]) - -----END STACK TRACE-----
These function call symbols or "frames" are generated automatically by the C
library; the hexadecimal numbers are memory addresses.
The key for tracking down the location of the segfault is the first
frame; in this case, "[0] ./proftpd [0x809b1e1]" and the memory address
0x809b1e1. Using the addr2line
command (which you may need to
install separately on your system) and that memory address, you can determine
the location of the segfault source:
$ addr2line -e /usr/local/sbin/proftpd 0x809b1e1
In this particular case, I saw:
$ addr2line -e /usr/local/sbin/proftpd 0x809b1e1
/home/tj/proftpd/cvs/proftpd/modules/mod_auth.c:1723
which is the location of test code I added to deliberately trigger a segfault.
There are some other noteworthy requirements for this automatic stacktrace
support. First, each proftpd
binary can be subtly different,
depending on the exact configure command, shared modules loaded, etc.
Thus the addr2line
command must be run on the same
system as the segfaulting proftpd
binary, and must be run on
that same binary. Using the memory address and addr2line
on a different proftpd
, or on a different system, will not
work. Second, using the stacktrace
developer option disables
the changing of the process title that proftpd
normally does.
The obtaining of the stack symbols that is done uses the process title, and if
the stacktrace
option did not disable that process title changing,
the output would be much less legible. The automatic stacktrace code
in the C library will not work if the process has been chrooted (i.e.
you use the DefaultRoot
and/or <Anonymous>
directives); I suspect this has to do with hardcoded assumptions in the
C library itself which are broken in a chrooted process. Finally, use
of the -fomit-frame-pointer
compiler option will cause the
stacktrace feature to not work; those omitted frame pointers contain
exactly the frame symbols/addresses that we want to capture.
The stacktrace
feature is known to work on Linux platform.
On FreeBSD, you need to install the libexecinfo library from the Ports
collection. On Mac OSX, you must be running 10.5 in order to have the
proper C library support.
Frequently Asked Questions
Question: Why do I get a configure error about a
"duplicate build request", like this:
checking checking for duplicate module requests... yes
configure: error: duplicate build request for mod_delay -- aborting
Answer: This happens when your
--with-modules
list contains one of the automatically included
modules (see above). In this example, the
mod_delay
module appeared in the --with-modules
list.
Note that older releases of ProFTPD did not check for these types of
"duplicate build requests". If you are having problems with your
proftpd
and you see the same module appear multiple times in
the output from running:
$ /usr/local/sbin/proftpd -l
Then you should re-configure and re-compile your proftpd
, making
sure that no automatically included modules appear in your
--with-modules
configure option.
Question: Why do I get a configure error like this:
configure: error: source file './modules/d_auth_pam.c' cannot be found -- aborting
Answer: Notice how the name of the module reported
there is "d_auth_pam.c", rather than "mod_auth_pam.c"? If you see a mangled
module name like this, it probably means that your --with-modules
or --with-shared
module lists contain a double colon, e.g.:
$ ./configure --with-modules=mod_sql::mod_sql_mysql:...
or:
$ ./configure --with-shared=mod_sql::mod_sql_mysql:...
Use only a single colon between module names; this should fix this error.
Question: I installed ProFTPD, and encountered this
error when trying to use ftptop
:
$ ftptop
ftptop: no curses or ncurses library on this system
So I installed the ncurses
library on my system, and compiled
ProFTPD again. But the error still occurs! Why?
Answer: The ProFTPD build system discovers the
libraries it needs, like curses
or ncurses
, as part
of the running of the configure
command; the results of those
discoveries are recorded in the generated config.h
(and other)
files.
This means that if you install a needed library after building ProFTPD,
you need to re-run configure
, make
, etc in
order for ProFTPD to discover that new library and use it:
$ cd /path/to/proftpd/
$ make clean
$ ./configure ...
$ make
$ make install
The "make clean" step is necessary, to clean up any leftover state from the
previous build.
Question: I can't seem to compile mod_tls
and mod_sql
. Using one or the other works (i.e.
shows up in the `proftpd -l`
list), but not both. I'm using the
following configure command:
$ ./configure --with-modules=mod_tls --with-modules=mod_sql:mod_sql_mysql ...
Answer: The problem is that the
--with-modules
option cannot appear multiple times in the
configure command. If it does, only the last one seen on the command line
wins. In this case, the user would need to put all of the desired modules
into one colon-delimited list, e.g.:
$ make clean
$ ./configure --with-modules=mod_tls:mod_sql:mod_sql_mysql ...
And keep in mind that the same restriction holds true for the
--with-includes
and --with-libraries
options.
Question: I try to start my proftpd
,
but I get this error:
warning: the mod_sql_mysql module has not been properly initialized. Please
make sure your --with-modules configure option lists mod_sql *before*
mod_sql_mysql, and recompile.
Answer: The issue here is that the