1
0
mirror of https://github.com/InfrastructureServices/vsftpd.git synced 2025-04-19 01:24:02 +03:00

117 Commits

Author SHA1 Message Date
Artem Egorenkov
e81c284128 add option to disable TLSv1.3 2022-02-09 15:58:21 +01:00
Artem Egorenkov
aa87e83ebf ALPACA fix backported from upstram 3.0.5 version 2022-02-09 15:38:38 +01:00
Artem Egorenkov
03827879e8 fixed comparision of signed and unsigned ints 2021-04-08 16:34:35 +02:00
Artem Egorenkov
00723168b8
Merge pull request #3 from InfrastructureServices/replace_unprintable_with_hex
Logging improvements
2021-04-08 13:56:15 +02:00
Artem Egorenkov
56402c0a2d Fixes after review 2021-04-01 12:11:16 +02:00
Artem Egorenkov
8b82e73c93 Enable wide-character support in logs 2021-03-31 15:12:22 +02:00
Artem Egorenkov
63f0498a64 Replace unprintable with HEX not question mark in logs 2021-03-29 16:24:40 +02:00
Ondřej Lysoněk
ab797dcffc Remove a hint about the ftp_home_dir SELinux boolean
The boolean has been removed from SELinux.
2020-03-17 12:57:36 +01:00
Ondřej Lysoněk
e91e27a518 Drop an unused global variable
The global variable `s_timezone` is not used anymore, so we can drop
it.
2020-02-13 18:10:31 +01:00
Ondřej Lysoněk
66497b9067 Fix timestamp handling in MDTM
There were two problems with the timestamp handling with MDTM:

1. In vsf_sysutil_parse_time(), the `the_time.tm_isdst` attribute was
   always set to 0, regardless of whether DST (daylight saving time)
   is active on the given date or not.

   This made glibc shift the timestamp when DST was in fact active on
   the given date, in an attempt to correct the discrepancy between
   the given timestamp and the `tm_isdst` attribute. The shifting
   produced incorrect results however.

   We fix this by setting `tm_isdst` to -1 to let glibc decide if DST
   is active or not at the time of the timestamp. glibc won't touch
   the timestamp then.

2. vsftpd used to record the offset from UTC of the current timezone
   in the global variable `s_timezone`. This variable was then
   subtracted from the variable `the_time` in vsf_sysutil_setmodtime()
   when the config option use_localtime=NO was set. This was done to
   compensate for the fact that mktime(), used in
   vsf_sysutil_parse_time(), expects a timestamp expressed as local
   time, whereas vsftpd is dealing with universal time.

   However, this did not work in the case when the offset stored in
   `s_timezone` did not match the timezone of the timestamp given to
   mktime() - this happens when DST is active at the current time, but
   DST is not active at the time of the timestamp, or vice versa.

   We fix this by subtracting the real timezone offset directly in
   vsf_sysutil_parse_time().

   Note that the `tm_gmtoff` attribute, used in this fix, is a
   BSD/glic extension. However, using `tm_gmtoff` seems like the
   simplest solution and we need to make this work only with glibc
   anyway.

The fix was tested in the following way. We checked that the timestamp
given to the MDTM command when setting modification time exactly
matches the timestamp received as response from MDTM when reading back
the modification time. Additionally, we checked that the modification
time was set correctly on the given file on disk.

These two checks were performed under various conditions - all the
combinations of DST/non-DST system time, DST/non-DST modification
time, use_localtime=YES/NO.

Note that (I think) this will still not work if the rules for when DST
is active change. For example, if DST is ever completely cancelled in
the Europe/Prague timezone, and vsftpd is dealing with a timestamp
from a time when DST was active, it will produce incorrect results. I
think we would need the full zone file to fix this, but the zone file
is hard to provide when we're chroot-ed.

Resolves: rhbz#1567855
2020-02-13 18:10:31 +01:00
Ondřej Lysoněk
8882c5f778 Fix assignment of an enumerator of a different type
The kVSFSysStrOpenUnknown enumerator is not part of the
EVSFSysUtilOpenMode enum. The assignment causes a build failure with
gcc 10.

The open_mode variable need not be initialized, because the switch
statement either sets the variable or causes us to exit.

Resolves: rhbz#1800239
2020-02-07 11:51:46 +01:00
Ondřej Lysoněk
7957425ef5 Repeat pututxline() until it succeeds if it fails with EINTR
Since the pututxline() bug rhbz#1749439 is now fixed in glibc in
Fedora and RHEL-8, we can implement a complete solution for the stale
utmp entries issue originally reported as rhbz#1688848.

This patch is a followup to commit 896b3694ca062d7.

Resolves: rhbz#1688852
Resolves: rhbz#1737433
2019-11-28 15:48:41 +01:00
Ondřej Lysoněk
896b3694ca Repeat pututxline() if it fails with EINTR
This is a partial fix for rhbz#1688848. We cannot resolve it
completely until glibc bug rhbz#1734791 is fixed. See
https://bugzilla.redhat.com/show_bug.cgi?id=1688848#c13.

The maximum number of attempts is currently 2, which might seem
low. However setting it to 2 was a decision based on data - see
https://bugzilla.redhat.com/show_bug.cgi?id=1688848#c16.

Resolves: rhbz#1688848
2019-08-05 13:55:37 +02:00
Ondřej Lysoněk
96698a5257 Set s_uwtmp_inserted only after record insertion/removal
pututxline() is the function that actually inserts the new record, so
setting 's_uwtmp_inserted' before calling pututxline() doesn't make
sense.

We'll need this change for other fixes.
2019-08-05 13:46:21 +02:00
Ondřej Lysoněk
e679a3ce0f Prevent recursion in bug()
Resolves: rhbz#1666380
2019-08-03 20:03:16 +02:00
Ondřej Lysoněk
40fea45523 Move closing standard FDs after listen()
The vsf_sysutil_close() calls need to be moved a bit further so that
die() works properly in case listen() fails.

I see no reason the calls should be placed before listen()
specifically, as they are now. My guess is that the author who added
the calls thought that listen() is a blocking call, which is not the
case. The only thing we need to satisfy is that close() is called
before accept, because that is a blocking call. That's all that is
needed to fix the bug that was fixed by adding the close() calls.

Resolves: rhbz#1666380
2019-08-03 17:50:14 +02:00
Ondřej Lysoněk
970711fde9 Fix SEGFAULT when running in a container as PID 1
When vsftpd is running in a container as PID 1, it is possible
that it will get SIGCHILD for processes, which were not directly
created by it, but by some of its children. These processes will
not be in the s_p_pid_ip_hash hash table, and thus trying to
delete the entry from the hash table in standalone.c:handle_sigchld()
will result in segmentation fault.

I can quite easily reproduce it with the upstream vsftpd and default
configuration, except for isolate=NO and isolate_network=NO being set
(it seems to me that network namespaces take a long time to create
and destroy, which hides the race condition), on a quad-core machine.
When connecting to vsftpd in a loop like this:
$ while true; do echo -en '' | nc localhost 21; done

vsftpd crashes after a couple of seconds.
2018-07-25 11:52:07 +02:00
Ondřej Lysoněk
be7c2d6391 Make the max number of bind retries tunable
Resolves: rhbz#1318198
2018-06-21 09:57:26 +02:00
Ondřej Lysoněk
380e409306 Improve error message when max number of bind attempts is exceeded
Resolves: rhbz#1318198
2018-06-21 09:57:11 +02:00
Ondřej Lysoněk
ee6af258e8 Log die() calls to syslog
Pass messages given to die(), die2() and bug() to syslog. Currently this
functionality requires waiting for a short amount of time (1 second is
used) after logging the message and before exiting. This is a workaround
for the following systemd bug:
https://github.com/systemd/systemd/issues/2913

The need for this workaround is the main reason why I decided not to
enable this functionality by default.

Resolves: rhbz#1318198
Resolves: rhbz#1582672
2018-06-18 13:39:13 +02:00
Ondřej Lysoněk
c7ac05fdf2 vsf_sysutil_get_tz: Check the return value of syscalls
Check the return value of syscalls. There's always the possibility that
they'll fail. (Failure of close() is not handled though, apart from EINTR.
The file is open read-only so it shouldn't fail, and even if it does,
it's not tragic.)

We return NULL in case of syscall failure. One might be tempted to simply
call die() when any kind of error occurs when parsing the timezone data,
but I think it's more in line with the behaviour of tzset(3) not to do
anything drastic in such a case (tzset() will silently use UTC when
the value given in the TZ environment variable is invalid).
2018-05-10 09:48:58 +02:00
Ondřej Lysoněk
ca27e6e34d vsf_sysutil_rcvtimeo: Check return value of setsockopt 2018-05-10 09:48:58 +02:00
Ondřej Lysoněk
315f9720db Always do chdir("/") after chroot()
Always do chdir("/") after chroot() to be more sure we'll never get out
of it. This will not affect the working directory after calling
vsf_sysutil_chroot(), because in the current state vsftpd always calls
vsf_sysutil_chroot(".").
2018-05-10 09:48:52 +02:00
Ondřej Lysoněk
01b646d2af Fix rDNS with IPv6
Previously IPv6 addresses were not translated to hostnames for PAM to use.
2018-05-10 09:23:13 +02:00
Ondřej Lysoněk
765f99b267 Improve documentation of better_stou in the man page 2018-04-05 12:29:03 +02:00
Ondřej Lysoněk
f8663f35d5 Don't link with libnsl
Don't link with libnsl. It builds just fine without it and
vsf_findlibs.sh enables it only when tcp_wrappers is enabled.
2018-02-06 18:04:53 +01:00
Ondřej Lysoněk
1203b943b3 Add new filename generation algorithm for STOU command
A new configuration option 'better_stou' can be used to enable
a better algorithm for generating unique filenames.

Resolves: rhbz#1479237
2018-02-06 15:01:48 +01:00
Ondřej Lysoněk
9cba9e81aa Fix default value of strict_ssl_read_eof in man page 2018-01-05 10:35:52 +01:00
Ondřej Lysoněk
b383ec42bb Disable tcp_wrappers support
Resolves: rhbz#1518796
2018-01-05 10:35:47 +01:00
Ondřej Lysoněk
446f7c1ec5 vsftpd.conf: Refer to the man page regarding the ascii_* options 2018-01-02 16:33:18 +01:00
Ondřej Lysoněk
61327320b5 Expand explanation of ascii_* options behaviour in man page 2018-01-02 16:25:55 +01:00
Ondřej Lysoněk
ffaeebcfdb Disable anonymous_enable in default config file
Resolves: rhbz#1338637
2018-01-02 09:54:43 +01:00
Ondřej Lysoněk
75c942c77a Enable only TLSv1.2 by default
Disable TLSv1 and TLSv1.1 - enable only TLSv1.2 by default.
2017-12-21 16:41:42 +01:00
Ondřej Lysoněk
1c280a0b04 When handling FEAT command, check ssl_tlsv1_1 and ssl_tlsv1_2
Send 'AUTH SSL' in reply to the FEAT command when the ssl_tlsv1_1
or ssl_tlsv1_2 configuration option is enabled.

The patch was written by Martin Sehnoutka.

Resolves: rhbz#1432054
2017-12-21 14:38:49 +01:00
Ondřej Lysoněk
2369d1ea51 Document the new default for ssl_ciphers in the man page
Related: rhbz#1483970
2017-12-21 14:19:18 +01:00
Martin Sehnoutka
b83be8b4f8 Use system wide crypto policy
Resolves: rhbz#1483970
2017-12-21 13:56:18 +01:00
Ondřej Lysoněk
7d4b76abb4 Improve documentation of ASCII mode in the man page 2017-11-24 11:26:37 +01:00
Ondřej Lysoněk
35ec3be542 Document allow_writeable_chroot in the man page 2017-11-24 11:22:43 +01:00
Ondřej Lysoněk
221f35f302 Document the relationship of text_userdb_names and chroot_local_user
Note in vsftpd.conf(5) that text_userdb_names may not work when
chroot_local_user is set to YES.
2017-10-26 13:08:32 +02:00
Ondřej Lysoněk
18e0ab25a0 Redefine VSFTP_COMMAND_FD to 1
Redefine VSFTP_COMMAND_FD to 1 (stdout) so that error messages generated
during startup are picked up by systemd.

Resolves: rhbz#1443055
2017-09-05 14:26:08 +02:00
Ondřej Lysoněk
6c8dd87f31 Modify DH enablement patch to build with OpenSSL 1.1 2017-09-04 11:32:03 +02:00
Martin Sehnoutka
4922e60589 Turn off seccomp sandbox, because it is too strict. 2016-11-18 10:23:29 +01:00
Martin Sehnoutka
01bef55a19 Introduce TLSv1.1 and TLSv1.2 options.
Users can now enable a specific version of TLS protocol.
2016-11-17 13:36:17 +01:00
Martin Sehnoutka
aa9cb48373 Propagate errors from nfs with quota to client.
vsftpd now checks for errors when closing newly uploaded file and
forward errors to the client (e.g. when file system quota was
exceeded)
2016-11-17 13:29:59 +01:00
Martin Sehnoutka
0da42468ac Fix question mark wildcard withing a file name.
Previously '?' worked only at the end of a file name, now it can
be used anywhere.
2016-11-17 13:25:12 +01:00
Martin Sehnoutka
03ff061f18 Fix logging into syslog when enabled in config. 2016-11-17 13:18:22 +01:00
Martin Sehnoutka
34b9e1d10c Fix segfault in config file parser. 2016-11-17 13:14:55 +01:00
Martin Sehnoutka
ea99be1a7a Fix man page rendering. 2016-11-17 13:12:52 +01:00
Martin Sehnoutka
6224ecc5ac Delete files when upload fails.
Previously the uploaded file wasn't removed when the network was
disconnected. Now it is successfully deleted.
2016-11-17 13:10:41 +01:00
Martin Sehnoutka
1e65a0a15f Prevent hanging in SIGCHLD handler.
vsftpd can now handle pam_exec.so in pam.d config without hanging
in SIGCHLD handler.
2016-11-17 13:02:27 +01:00