vsftpd: handle migration and fix secure_chroot_dir error
authorMohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
Fri, 10 Jan 2025 10:12:46 +0000 (15:42 +0530)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Fri, 10 Jan 2025 15:02:24 +0000 (16:02 +0100)
* update UCI to use the traditional vsftpd.conf so
  that people migrating from non-uci version do not face problems
* if secure_chroot_dir is not provided specifically, then create
  an empty directory where vsftpd usually expects it

Signed-off-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
net/vsftpd/Makefile
net/vsftpd/files/vsftpd.init
net/vsftpd/files/vsftpd.uci

index b4ffe3bc01932cc381950c83bc78f794bd5c0eb2..cdabf6061af445ea2daa85c43c4640493ebb2a8d 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=vsftpd
 PKG_VERSION:=3.0.5
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://security.appspot.com/downloads/
@@ -46,6 +46,7 @@ endef
 define Package/vsftpd/conffiles
 /etc/vsftpd.conf
 /etc/vsftpd
+/etc/config/vsftpd
 endef
 
 Package/vsftpd-tls/conffiles=$(Package/vsftpd/conffiles)
index 610253d194576de5b60701c36bc894aa78bc741d..e905bb74d11b1c43f06aea2d514d9a303e8df788 100644 (file)
@@ -3,12 +3,13 @@
 
 START=50
 USE_PROCD=1
-BIN=vsftpd
+BIN="/usr/sbin/vsftpd"
 
 . /lib/functions.sh
 
 PORT=21
 OUTPUT_CONF="/var/etc/vsftpd.conf"
+readonly DEFAULT_SECURE_CHROOT="/var/run/vsftpd"
 readonly TEMP_OUTPUT_CONF="/var/etc/vsftpd.conf.tmp"
 
 write_conf() {
@@ -74,6 +75,7 @@ setup_vsftpd() {
                return 1
        fi
 
+       # Clean up
        rm -rf "$TEMP_OUTPUT_CONF"  # Clear temporary file
        touch "$TEMP_OUTPUT_CONF"
 
@@ -108,10 +110,16 @@ setup_vsftpd() {
        [ -n "$local_root" ] && write_conf "local_root" "$local_root"
        [ -n "$rsa_cert_file" ] && write_conf "rsa_cert_file" "$rsa_cert_file"
        [ -n "$rsa_private_key_file" ] && write_conf "rsa_private_key_file" "$rsa_private_key_file"
-       [ -n "$secure_chroot_dir" ] && write_conf "secure_chroot_dir" "$secure_chroot_dir"
        [ -n "$userlist_file" ] && write_conf "userlist_file" "$userlist_file"
        [ -n "$xferlog_file" ] && write_conf "xferlog_file" "$xferlog_file"
 
+       if [ -n "$secure_chroot_dir" ] && [ "$secure_chroot_dir" != "$DEFAULT_SECURE_CHROOT" ]; then
+               # remove the DEFAULT_SECURE_CHROOT directory
+               # it is not needed now
+               rm -rf "$DEFAULT_SECURE_CHROOT"
+               write_conf "secure_chroot_dir" "$secure_chroot_dir"
+       fi
+
        # move temporary file to the main configuration file
        mv "$TEMP_OUTPUT_CONF" "$OUTPUT_CONF"
 }
@@ -128,6 +136,11 @@ start_service() {
                return
        fi
 
+       # clean and create the default chroot directory
+       rm -rf "$DEFAULT_SECURE_CHROOT"
+       mkdir -m 0755 -p "$DEFAULT_SECURE_CHROOT"
+       chown root:root "$DEFAULT_SECURE_CHROOT"
+
        config_get_bool conf_file global conf_file ""
        if [ -n "$conf_file" ]; then 
                # use user defined conf file instead of UCI
@@ -140,7 +153,7 @@ start_service() {
        procd_open_instance "vsftpd"
 
        config_get_bool mdns global mdns 0
-       [ "${mdns}" -eq 1 ] && procd_add_mdns "ftp" "tcp" "$PORT" "daemon=$BIN"
+       [ "${mdns}" -eq 1 ] && procd_add_mdns "ftp" "tcp" "$PORT" "daemon=vsftpd"
 
        procd_set_param command "$BIN" "$OUTPUT_CONF"
        procd_set_param respawn
index 1394742df188e40dfaa42d6aafd215a30bef449a..e1affdf15f95b34c9f2524f05176e64c985a5cfa 100644 (file)
@@ -1,6 +1,4 @@
 config global 'global'
-       option listen '1'
-       option write_enable '1'
-       option anonymous_enable '0'
-       option local_enable '1'
+       option disabled '0'
        option mdns '0'
+       option conf_file '/etc/vsftpd.conf'