uFTP 4.4.0 release notes¶
Changes since 4.3.0.
New¶
- Users from your own program (
AUTH_HOOK): database, LDAP, a web API or a file, without restarting uFTP and without libraries in the server. It is the last step of a login, only for names that nobody else knows; a hook that does not answer never lets anybody in. It can give a user every setting of the configuration file. Ready examples incontrib/auth-hooks/. - Run scripts (
SITE RUN,SITE STATUS; the output files are never overwritten, and the reply comes when they are made): a user with the new permissionrunstarts, in the background, a script that you listed (SITE_COMMAND_<name>), with one checked parameter, a time limit and a size limit. For backups and database dumps. Scripts and recipes (lftp,curl,rclone) incontrib/site-commands/and on the site. - Stronger password hashes: PBKDF2-SHA256 with 600,000 iterations by default, the value recommended for this algorithm. The check runs in a thread, so the other clients are not kept waiting; the hashes of before keep the count they have.
- Checksums without downloading:
HASH(andOPTS HASH),XCRC,XMD5,XSHA1,XSHA256, andMFMTto keep the date of a file (HASH_MAX_SIZE_MB). - Permissions for each user (
PERMISSIONS_n,READ_ONLY_n): list, download, upload, overwrite, delete, rename, mkdir, chmod and run. - Speed limits for each user, shared by all of his connections (
MAX_DOWNLOAD_SPEED,MAX_UPLOAD_SPEEDand the_nof each user). - Users in a file of their own (
USERS_FILE) and./uFTP --split-usersto make it from the users you already have. - Users whose numbers have gaps (
USER_0,USER_2,USER_10are three users, read in increasing order). EveryUSER_nneedsPASSWORD_nandHOME_n, and an option of a number that has noUSER_nstops the server instead of being ignored. uftpctl adduseranduftpctl passwd: an FTP user is added, or a password changed, without editing the file. The password is asked on the terminal, saved as a PBKDF2 hash (the iteration count is chosen with--iterations), and the file keeps its mode and owner, with a copy of before (.bak).adduserwrites toUSERS_FILEwhen there is one.- Logs where the system looks:
syslog,stderrand a transfer log in the standardxferlogformat (SYSLOG_ENABLED,LOG_TO_STDERR,XFERLOG_FILE). - A private key with a password (
TLS_KEY_PASSWORD_FILE): the password is read from a file, once at start. Without it a protected key stops the server with a clear message: it never asks the terminal. - TLS options: minimum version, ciphers, and the reuse of the TLS session on the data connection (
TLS_*). PAM service of your choice (PAM_SERVICE_NAME). - Without root: a hardened
systemdunit (contrib/systemd/) and a Docker image that does not run as root (contrib/docker/), with guides on the site. - A new certificate and new users without a restart:
SIGHUP(systemctl reload,uftpctl reload) reads the TLS certificate and its key again, and the users of the configuration file and ofUSERS_FILE. A new user can log in, a removed one can not, a new password and new permissions work; the open connections go on with the settings they had. If the new certificate or the users file is not valid, the ones in use stay. A hook for certbot incontrib/certbot/. - Health and metrics (
HEALTH_PORT, off):/livez,/readyzand/metricsfor Prometheus, without names of users or files. uftpctl(CONTROL_SOCKET, off): who is connected, close a connection, read the certificate again.uFTP --check: what the server would find at start.- Networks for each user (
ALLOW_FROM_n,DENY_FROM_n) and permissions of new files (UMASK,UMASK_n). - Manual pages and packages:
.debfor Debian/Ubuntu amd64, arm64 and armhf (Raspberry Pi OS; armhf needs ARMv7), and.rpmfor Rocky Linux/EL 9 and 10 on x86_64 and aarch64. Signed APT and DNF repositories for the same systems. Theuftpserverpackages include TLS and PAM, with PAM off by default. The package configuration blocks FTP login asroot. - Orderly stop (
SHUTDOWN_GRACE_SECONDS):SIGTERMlets the transfers in progress end. - Continuous integration on GitHub (
.github/workflows/ci.yml): five builds, the tests, the sanitizers and a minute of fuzzing.
Improvements¶
- Much less memory when idle: a slot that is not used takes about 1 KB. 10,000 slots took 385 MB before the first client, now about 20 MB.
- A slow command does not stop the others: checksums,
STATof a path and the PAM check run in a thread of their own. - File permissions: the group of a file now gives the group bits only (it used to give full access); a
chownthat fails is written in the log. - Fatal errors at start also go to standard error (
journalctl,docker logsshow why the server stopped). - A silent server for devices with no place to write: with
MAXIMUM_LOG_FILES = 0(and nosyslog,LOG_TO_STDERRorxferlog) uFTP now writes nothing in normal operation, not even the start-up banner or a line on standard error. Only a[FATAL]line and a crash report say why it stopped. (Before, the start-up lines and a fewperrorcalls still went to standard output and standard error.)
Fixes¶
- Crash:
USERduring a transfer could use freed memory (with a speed limit or a transfer log). - The server stopped:
LISTorNLSTwith options, sent while its TLS data connection was being closed, could end the whole server (only logged-in users; a very short window). - Lost descriptors:
PASVorEPSVfollowed at once byABORor another data command lost a descriptor each time, until nobody could connect; an upload stopped while its file was being opened could lose one, and one stopped while its file was being closed could end the server (only logged-in users). - The server no longer waits for one client:
STATover TLS, a slow authentication hook, the lack of free descriptors, a transfer on a disk that does not answer and the check of a hashed password could stop all of them. Too many checks of passwords at the same time are answered421; too manyHASH,Xchecksums andSTATof a path are answered450(try again). - File permissions:
HASHand theXchecksums need to read the file andMFMTto write it; withHOME_n = /the check of the root directory was skipped;RMDcan not remove the home. - TLS data connections:
PROT Csent during a transfer no longer makes the rest of it go in clear text:PROTis for the next data connection. A transfer on a connection that was opened with the other protection is answered425. - A listing cancelled by the client (the data connection closed during
LIST,NLSTorMLSD) is answered426and the session goes on: it was closed. - Large files on 32 bit systems: a file over 2 GB was not seen, and an upload that went on after 4 GB could write in the wrong place of the file.
- Interrupted transfers (
ABOR, a newPASV, a connection that is lost) leave a line in the logs. RNTOmust come right afterRNFR(onlyNOOPandSTATin between): after another command it is503.- After a restart by the supervisor, a
SIGTERMsent to the server was passed on to a process that was not its own. - A full server sends away the connection without login that came first: of the ones that came in the same second it could send away the newest.
- Limits by address: a connection that is refused no longer pushes out another client when the server is full; two addresses no longer reset each other's count of
MAX_CONNECTION_RATE_PER_IP; the failed logins no longer grow without end (4,096 addresses for each table). - PAM with
AUTH_HOOK: a user refused by PAM and accepted by the hook was answered530. - Logs: lines of different threads and processes do not mix; when the log can not be written (a full disk) the server says it once on standard error, and how many lines are missing when it works again.
- TLS: with
TLS_REQUIRE_SESSION_REUSEonly a session of the same control connection is accepted; an upload that ends with a TLS error answers426, not226. - Configuration: the last line counts also without an end of line (a
READ_ONLY_n = "true"there was lost); areadonly=of the hook that is not valid refuses the login. - The rest of a command line that is too long is not a command; a refused command does not change the
RESTof the transfer in progress; a read error of a download is not226; the checksum cache, the days of the log files and the dates under load are right. --versionand--help; an unknown option of the command line is reported.- An interrupted upload belongs to its owner. Relative paths work in daemon mode. The log says, at start, which options are not known or repeated, and which files others can change.
Upgrading¶
SIGTERMandSIGINTnow wait for the transfers in progress, up to 30 seconds (SHUTDOWN_GRACE_SECONDS); a second signal, orSHUTDOWN_GRACE_SECONDS = 0, stops at once as before. Makesystemctl stopanddocker stopwait at least that long (the shipped unit and Compose file do).- The memory of a slot is no longer reserved at start:
MAXIMUM_ALLOWED_FTP_CONNECTIONis only the limit of connections. - With an owner configured for a user (
USER_NAME_OWNER_n), a file whose group is the user's group now gives the group permission bits, not full access. HASH,XCRC,XMD5,XSHA1,XSHA256andMFMTare on by default (HASH_MAX_SIZE_MB = 256;0turns the checksums off). They need the permissionsdownloadandoverwrite.- FTPS data connections must resume their control connection's TLS session by default (
TLS_REQUIRE_SESSION_REUSE = true). Set it tofalsefor clients that do not support session reuse. runis not part ofall:SITE RUNis for the users that you name (PERMISSIONS_n = all,run).- The users of a file are no longer read until the first missing number:
USER_0,USER_2andUSER_10are all loaded. EveryUSER_nnow needsPASSWORD_nandHOME_n, and an option of a number with noUSER_n(aPERMISSIONS_5with noUSER_5) stops the server: it used to be ignored in silence. Check every file withuFTP --checkbefore the restart. USERon a connection that is already logged in stops a transfer in progress (426, then331; an interrupted upload stays partial), closes a waitingPASVand drops a pendingRESTorRNFR.PASSwithout a newUSERis refused with503. This fixes a use-after-free that could stop the server, and anRNFRof one user completed by another.- New password hashes (
--hash-password,uftpctl adduserandpasswd) use 600,000 iterations by default. The hashes already in the file keep their count and keep working. SIGHUPnow reads the users too (the configuration file andUSERS_FILE), not only the certificate: a new user or a new password needs no restart. A file that is not valid leaves the users in use. Nothing else of the configuration is read (ports, folders, the server limits,BLOCK_USER_n): a restart is needed for those.- With an owner configured,
DELE,RMD,RNFRandRNTOalso need to write the directory, like on the system: who deleted files in a directory that it can not write now gets550. - The group
root(0) is a group like the others: a user with another owner and the grouprootgets the group bits, not full access. - A hook that answers a
readonly=different from1,true,0andfalse(it used to give full access) is refused. - A last line of
uftpd.cfgwithout an end of line, that was lost or cut, now counts: look at it before the restart. - An option that must be a number and is not (
LOGIN_TIMEOUT = abc) stops the server at start: it was 0, which turns many limits off. A comment after the number is fine. So does a read error of the configuration file, which was taken as an empty file. SIGHUPdoes not end a server in the foreground any more (closing its terminal neither): use Ctrl-C orSIGTERM.- A C11 compiler is needed (GCC 4.9 or later, or clang).
- Building without the
Makefile: the sources now includelibrary/addressTable.c,networkList.c,health.c,control.c,doctor.candlibrary/ckeep/src/*.c(with-Ilibrary/ckeep/include), a copy of a part of our libraryckeep. PASSwhen the connection is logged in already is503. The backup and the users file of--split-usersare0640at most. A link in the place of the log file of the day is not followed (uftpLog.currentis not touched).- Other optional features remain off or unset:
AUTH_HOOK,SITE_COMMAND_<name>,USERS_FILE, speed limits,syslog,XFERLOG_FILE,TLS_KEY_PASSWORD_FILE, and custom TLS cipher lists. TLS 1.2 is the minimum by default; TLS session reuse is required by default.
Known limits¶
TYPE A does not convert line ends, STRU P is not implemented, and implicit FTPS (port 990) is not supported. A hook and a SITE RUN script run with the privileges of uFTP: run uFTP without root. SITE RUN jobs do not survive a restart.
Tried before this release: the Docker image and the Compose file (built and run with the example folders, users and limits, docker stop with a transfer in progress), the system-call filters of the systemd unit, the packages on Debian 12/13, Ubuntu 22.04/24.04 and Rocky Linux 9/10 (amd64, arm64, armhf, x86_64, aarch64; the ARM packages in emulated containers), and the signed APT and DNF repositories (apt install in Debian 12 amd64/arm64 and Ubuntu 24.04, dnf install in Rocky 9 x86_64), and the FileZilla client. Not tried against the real thing: the examples for MySQL, PostgreSQL, LDAP and a web API, the rclone recipe, the GitHub workflow, the parts of the systemd unit that need a system service (User=, ProtectSystem), PAM with real users outside a container, certbot, a real Prometheus, and the full test suite on ARM.