Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions net/vsftpd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=vsftpd
PKG_VERSION:=3.0.5
PKG_RELEASE:=$(AUTORELEASE)
PKG_RELEASE:=7

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://security.appspot.com/downloads/
PKG_HASH:=26b602ae454b0ba6d99ef44a09b6b9e0dfa7f67228106736df1f278c70bc91d3

PKG_MAINTAINER:=Cezary Jackiewicz <cezary@eko.one.pl>
PKG_LICENSE:=GPLv2
PKG_CPE_ID:=cpe:/a:beasts:vsftpd
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING COPYRIGHT LICENSE
PKG_CPE_ID:=cpe:/a:vsftpd_project:vsftpd

include $(INCLUDE_DIR)/package.mk

Expand Down Expand Up @@ -46,12 +47,14 @@ endef
define Package/vsftpd/conffiles
/etc/vsftpd.conf
/etc/vsftpd
/etc/config/vsftpd
endef

Package/vsftpd-tls/conffiles=$(Package/vsftpd/conffiles)

ifneq ($(CONFIG_USE_MUSL),)
NLSSTRING:=-lcrypt
TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
else ifneq ($(CONFIG_USE_GLIBC),)
NLSSTRING:=-lcrypt
else
Expand Down Expand Up @@ -91,6 +94,8 @@ define Package/vsftpd/install
$(INSTALL_CONF) ./files/$(PKG_NAME).conf $(1)/etc/$(PKG_NAME).conf
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/$(PKG_NAME).uci $(1)/etc/config/$(PKG_NAME)
$(INSTALL_DIR) $(1)/etc/vsftpd
endef

Expand Down
4 changes: 1 addition & 3 deletions net/vsftpd/files/vsftpd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
background=YES
background=NO
listen=YES
anonymous_enable=NO
local_enable=YES
Expand Down Expand Up @@ -27,5 +27,3 @@ session_support=NO
#ssl_sslv3=NO
#rsa_cert_file=/etc/vsftpd/vsftpd_cert.pem
#rsa_private_key_file=/etc/vsftpd/vsftpd_privkey.pem
seccomp_sandbox=NO
isolate_network=NO
163 changes: 158 additions & 5 deletions net/vsftpd/files/vsftpd.init
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,165 @@
# Copyright (C) 2006-2011 OpenWrt.org

START=50
USE_PROCD=1
BIN="/usr/sbin/vsftpd"

start() {
mkdir -m 0755 -p /var/run/vsftpd
service_start /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() {
local key="$1"
local value="$2"

if [ -n "$key" ] && [ -n "$value" ]; then
echo "$key=$value" >> "$TEMP_OUTPUT_CONF"
fi
}

write_conf_bool() {
local key="$1"
local value="$2"

if [ "$value" = "1" ]; then
write_conf "$key" "YES"
else
write_conf "$key" "NO"
fi
}

validate_vsftpd_section() {
uci_load_validate vsftpd global "$1" "$2" \
'listen:bool:1' \
'listen_ipv6:bool:0' \
'listen_port:port' \
'anonymous_enable:bool:0' \
'anon_root:directory' \
'local_enable:bool:1' \
'local_root:directory' \
'write_enable:bool:1' \
'local_umask:uinteger:022' \
'check_shell:bool:0' \
'dirmessage_enable:bool:1' \
'secure_chroot_dir:directory' \
'ftpd_banner:string' \
'session_support:bool:0' \
'syslog_enable:bool' \
'userlist_enable:bool' \
'userlist_deny:bool' \
'userlist_file:file' \
'xferlog_enable:bool' \
'xferlog_file:file' \
'xferlog_std_format:bool' \
'ssl_enable:bool' \
'allow_anon_ssl:bool' \
'force_local_data_ssl:bool' \
'force_local_logins_ssl:bool' \
'ssl_tlsv1:bool' \
'ssl_sslv2:bool' \
'ssl_sslv3:bool' \
'rsa_cert_file:file' \
'rsa_private_key_file:file'
}

setup_vsftpd() {
local section="$1"
local validation_result="$2"

if [ "$validation_result" != "0" ]; then
echo "Validation failed for section: $section"
return 1
fi

# Clean up
rm -rf "$TEMP_OUTPUT_CONF" # Clear temporary file
touch "$TEMP_OUTPUT_CONF"

# always run in foreground
write_conf_bool "background" "0"

[ -n "$listen" ] && write_conf_bool "listen" "$listen"
[ -n "$listen_ipv6" ] && write_conf_bool "listen_ipv6" "$listen_ipv6"
[ -n "$anonymous_enable" ] && write_conf_bool "anonymous_enable" "$anonymous_enable"
[ -n "$local_enable" ] && write_conf_bool "local_enable" "$local_enable"
[ -n "$write_enable" ] && write_conf_bool "write_enable" "$write_enable"
[ -n "$check_shell" ] && write_conf_bool "check_shell" "$check_shell"
[ -n "$dirmessage_enable" ] && write_conf_bool "dirmessage_enable" "$dirmessage_enable"
[ -n "$session_support" ] && write_conf_bool "session_support" "$session_support"
[ -n "$syslog_enable" ] && write_conf_bool "syslog_enable" "$syslog_enable"
[ -n "$userlist_enable" ] && write_conf_bool "userlist_enable" "$userlist_enable"
[ -n "$userlist_deny" ] && write_conf_bool "userlist_deny" "$userlist_deny"
[ -n "$xferlog_enable" ] && write_conf_bool "xferlog_enable" "$xferlog_enable"
[ -n "$xferlog_std_format" ] && write_conf_bool "xferlog_std_format" "$xferlog_std_format"
[ -n "$ssl_enable" ] && write_conf_bool "ssl_enable" "$ssl_enable"
[ -n "$allow_anon_ssl" ] && write_conf_bool "allow_anon_ssl" "$allow_anon_ssl"
[ -n "$force_local_data_ssl" ] && write_conf_bool "force_local_data_ssl" "$force_local_data_ssl"
[ -n "$force_local_logins_ssl" ] && write_conf_bool "force_local_logins_ssl" "$force_local_logins_ssl"
[ -n "$ssl_tlsv1" ] && write_conf_bool "ssl_tlsv1" "$ssl_tlsv1"
[ -n "$ssl_sslv2" ] && write_conf_bool "ssl_sslv2" "$ssl_sslv2"
[ -n "$ssl_sslv3" ] && write_conf_bool "ssl_sslv3" "$ssl_sslv3"

[ -n "$anon_root" ] && write_conf "anon_root" "$anon_root"
[ -n "$ftpd_banner" ] && write_conf "ftpd_banner" "$ftpd_banner"
[ -n "$listen_port" ] && { write_conf "listen_port" "$listen_port"; PORT="$listen_port"; }
[ -n "$local_umask" ] && write_conf "local_umask" "$local_umask"
[ -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 "$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"
}

start_service() {
local disabled mdns conf_file

# Load UCI configuration for vsftpd
config_load vsftpd

# if disabled, just return
config_get_bool disabled global disabled 0
if [ "${disabled}" -eq 1 ]; then
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 conf_file global conf_file ""
if [ -n "$conf_file" ]; then
# use user defined conf file instead of UCI
OUTPUT_CONF="$conf_file"
else
# Process the global configuration
config_foreach validate_vsftpd_section global setup_vsftpd
fi

procd_open_instance "vsftpd"

config_get_bool mdns global mdns 0
[ "${mdns}" -eq 1 ] && procd_add_mdns "ftp" "tcp" "$PORT" "daemon=vsftpd"

procd_set_param command "$BIN" "$OUTPUT_CONF"
procd_set_param respawn
procd_close_instance
}

stop() {
service_stop /usr/sbin/vsftpd
service_triggers() {
procd_add_reload_trigger "vsftpd"
procd_add_validation validate_vsftpd_section
}
4 changes: 4 additions & 0 deletions net/vsftpd/files/vsftpd.uci
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config global 'global'
option disabled '0'
option mdns '0'
option conf_file '/etc/vsftpd.conf'