Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload after omitting explicit ModulePath value causes fatal module load failures #1476

Closed
voetsjoeba opened this issue Jun 28, 2022 · 1 comment
Assignees
Labels
Milestone

Comments

@voetsjoeba
Copy link

What I Did

When you remove an explicit ModulePath line in your config that already matches the compiled-in default (and which therefore shouldn't cause a change in value), and then reload the proftpd master daemon, the daemon terminates with a fatal error that modules could not be found, like this:

Jun 28 14:32:35 bullseye proftpd[18029]: bullseye - received SIGHUP -- master server reparsing configuration file
Jun 28 14:32:35 bullseye proftpd[18029]: mod_dso/0.5: unable to load 'mod_site_misc.c'; check to see if 'site_misc/mod_site_misc.la' exists
Jun 28 14:32:35 bullseye proftpd[18029]: fatal: LoadModule: error loading module 'mod_site_misc.c': No such file or directory on line 2 of '/usr/local/etc/proftpd.conf'

But after this happens, the daemon (now without the explicit ModulePath line) will happily start up fresh again, finding and loading all of its modules without issue as before. Reloading works fine again after the restart, too.

It appears that the problem happens only for this particular sequence of events:

  • start the daemon while there is an explicit ModulePath <same-path-as-compiled-in-value> in the config file
  • remove the explicit ModulePath value from the config
  • reload the daemon

Here's the simplest possible way I've found to reproduce the error, with a fresh out-of-the-box build from master to /usr/local on a vanilla Debian bullseye machine:

apt-get -y install git build-essential

git clone https://github.com/proftpd/proftpd.git
cd proftpd/

./configure --enable-dso --with-shared=mod_site_misc && make && make install

Here's the relevant compiled in paths from the build (full output included below):

# /usr/local/sbin/proftpd -V
...
  Files:
    Configuration File:
      /usr/local/etc/proftpd.conf
    Pid File:
      /usr/local/var/proftpd.pid
    Scoreboard File:
      /usr/local/var/proftpd.scoreboard
    Header Directory:
      /usr/local/include/proftpd
    Shared Module Directory:
      /usr/local/libexec
...

Now creating a systemd unit (matching the one that ships with Debian's package) and adding the explicit ModulePath line matching the built-in value:

cat >/etc/systemd/system/proftpd.service <<'EOF'
# proftpd.service from Debian bullseye's proftpd-core 1.3.7a+dfsg-12+deb11u2
[Unit]
Description=proftpd
Wants=network-online.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target

[Service]
Type=forking
Environment=OPTIONS= CONFIG_FILE=/usr/local/etc/proftpd.conf
ExecStartPre=/usr/local/sbin/proftpd --configtest -c $CONFIG_FILE
ExecStart=/usr/local/sbin/proftpd -c $CONFIG_FILE $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
EOF

cat >/tmp/new-config.conf <<'EOF'
ModulePath /usr/local/libexec
LoadModule mod_site_misc.c
EOF
cat /usr/local/etc/proftpd.conf >>/tmp/new-config.conf
mv /tmp/new-config.conf /usr/local/etc/proftpd.conf

systemctl enable proftpd.service --now

Journalctl now shows the service booting successfully:

journalctl -eu proftpd.service
Jun 28 14:56:58 bullseye systemd[1]: Starting proftpd...
Jun 28 14:56:58 bullseye proftpd[18257]: Checking syntax of configuration file
Jun 28 14:56:58 bullseye systemd[1]: Started proftpd.
Jun 28 14:56:58 bullseye proftpd[18259]: bullseye - ProFTPD 1.3.8rc4 (git) (built Tue Jun 28 2022 14:31:02 UTC) standalone mode STARTUP

Now remove the explicit ModulePath line and nothing else, and try to reload the service:

sed -i'' -re 's/^ModulePath (.*)/#ModulePath \1/g' /usr/local/etc/proftpd.conf

journalctl -eu proftpd.service
Jun 28 15:01:58 bullseye systemd[1]: Reloading proftpd.
Jun 28 15:01:58 bullseye systemd[1]: Reloaded proftpd.
Jun 28 15:01:58 bullseye proftpd[18259]: bullseye - received SIGHUP -- master server reparsing configuration file
Jun 28 15:01:58 bullseye proftpd[18259]: mod_dso/0.5: unable to load 'mod_site_misc.c'; check to see if 'site_misc/mod_site_misc.la' exists
Jun 28 15:01:58 bullseye proftpd[18259]: fatal: LoadModule: error loading module 'mod_site_misc.c': No such file or directory on line 2 of '/usr/local/etc/proftpd.conf'
Jun 28 15:01:58 bullseye systemd[1]: proftpd.service: Succeeded.

But now it starts back up and reloads fine again:

systemctl start proftpd
systemctl reload proftpd
journalctl -eu proftpd.service
Jun 28 15:12:28 bullseye systemd[1]: Starting proftpd...
Jun 28 15:12:28 bullseye proftpd[18289]: Checking syntax of configuration file
Jun 28 15:12:28 bullseye systemd[1]: Started proftpd.
Jun 28 15:12:28 bullseye proftpd[18291]: bullseye - ProFTPD 1.3.8rc4 (git) (built Tue Jun 28 2022 14:31:02 UTC) standalone mode STARTUP
Jun 28 15:12:33 bullseye systemd[1]: Reloading proftpd.
Jun 28 15:12:33 bullseye systemd[1]: Reloaded proftpd.
Jun 28 15:12:33 bullseye proftpd[18291]: bullseye - received SIGHUP -- master server reparsing configuration file

What I Expected/Wanted

Omitting a value for ModulePath should cause it to default to the compile-time value, so I would not expect doing so and reloading the server to cause it to crash.

ProFTPD Version and Configuration

# /usr/local/sbin/proftpd -V
Compile-time Settings:
  Version: 1.3.8rc4 (git)
  Platform: LINUX [Linux 5.10.0-15-amd64 x86_64]
  OS/Release:
    PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
    NAME="Debian GNU/Linux"
    VERSION_ID="11"
    VERSION="11 (bullseye)"
    VERSION_CODENAME=bullseye
    ID=debian
  Built: Tue Jun 28 2022 14:31:02 UTC
  Built With:
    configure  '--enable-dso' '--with-shared=mod_site_misc'

  CFLAGS: -g2 -O2 -Wall -fno-omit-frame-pointer -fno-strict-aliasing -Werror=implicit-function-declaration
  LDFLAGS: -Wl,-L$(top_srcdir)/lib,-L$(top_builddir)/lib  -rdynamic 
  LIBS:  -lnsl -lresolv -lresolv -lcrypt -ldl 

  Files:
    Configuration File:
      /usr/local/etc/proftpd.conf
    Pid File:
      /usr/local/var/proftpd.pid
    Scoreboard File:
      /usr/local/var/proftpd.scoreboard
    Header Directory:
      /usr/local/include/proftpd
    Shared Module Directory:
      /usr/local/libexec

  Info:
    + Max supported UID: 4294967295
    + Max supported GID: 4294967295

  Features:
    - Autoshadow support
    - Controls support
    - curses support
    - Developer support
    + DSO support
    + IPv6 support
    + Largefile support
    - Lastlog support
    - Memcache support
    - ncurses support
    - NLS support
    - OpenSSL support
    - PCRE support
    - PCRE2 support
    - POSIX ACL support
    - Redis support
    + Sendfile support
    + Shadow file support
    - Sodium support
    + Trace support
    + xattr support

  Tunable Options:
    PR_TUNABLE_BUFFER_SIZE = 1024
    PR_TUNABLE_DEFAULT_RCVBUFSZ = 8192
    PR_TUNABLE_DEFAULT_SNDBUFSZ = 8192
    PR_TUNABLE_ENV_MAX = 2048
    PR_TUNABLE_GLOBBING_MAX_MATCHES = 100000
    PR_TUNABLE_GLOBBING_MAX_RECURSION = 8
    PR_TUNABLE_HASH_TABLE_SIZE = 40
    PR_TUNABLE_LOGIN_MAX = 256
    PR_TUNABLE_NEW_POOL_SIZE = 512
    PR_TUNABLE_PATH_MAX = 4096
    PR_TUNABLE_SCOREBOARD_BUFFER_SIZE = 80
    PR_TUNABLE_SCOREBOARD_SCRUB_TIMER = 30
    PR_TUNABLE_SELECT_TIMEOUT = 30
    PR_TUNABLE_TIMEOUTIDENT = 10
    PR_TUNABLE_TIMEOUTIDLE = 600
    PR_TUNABLE_TIMEOUTLINGER = 10
    PR_TUNABLE_TIMEOUTLOGIN = 300
    PR_TUNABLE_TIMEOUTNOXFER = 300
    PR_TUNABLE_TIMEOUTSTALLED = 3600
    PR_TUNABLE_XFER_SCOREBOARD_UPDATES = 10
# cat /usr/local/etc/proftpd.conf
# omitting this ModulePath line and reloading causes a crash
ModulePath /usr/local/libexec
LoadModule mod_site_misc.c
# This is a basic ProFTPD configuration file (rename it to 
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName                      "ProFTPD Default Installation"
ServerType                      standalone
DefaultServer                   on

# Port 21 is the standard FTP port.
Port                            21

# Don't use IPv6 support by default.
UseIPv6                         off

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask                           022

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30

# Set the user and group under which the server will run.
User                            nobody
Group                           nogroup

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite          on

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous ~ftp>
  User                          ftp
  Group                         ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"
  UserAlias                     anonymous ftp

  # Limit the maximum number of anonymous logins
  MaxClients                    10

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin                  welcome.msg
  DisplayChdir                  .message

  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>
@Castaglia Castaglia self-assigned this Jul 2, 2022
@Castaglia Castaglia added the bug label Jul 2, 2022
@Castaglia Castaglia added this to the 1.3.8 milestone Jul 2, 2022
Castaglia added a commit that referenced this issue Jul 2, 2022
… in the `mod_dso` module during a SIGHUP/restart.
Castaglia added a commit that referenced this issue Jul 2, 2022
… in the `mod_dso` module during a SIGHUP/restart.
Castaglia added a commit that referenced this issue Jul 2, 2022
Issue #1476: Make sure to reinitialize the default `ModulePath` value…
@Castaglia
Copy link
Member

Thanks for reporting this issue. It should now be fixed in master. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants