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

Added support for a new env variable that sets the listen port #76

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
39 changes: 39 additions & 0 deletions .github/workflows/container_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Image
on: [ push,workflow_dispatch ]

jobs:
build:
name: Build and push image
environment: MainCI
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Shellcheck
id: Shellcheck
uses: ludeeus/action-shellcheck@master

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: vsftpd
tags: latest ${{ github.sha }}
containerfiles: |
./Dockerfile

# Podman Login action (https://github.com/redhat-actions/podman-login) also be used to log in,
# in which case 'username' and 'password' can be omitted.
- name: Push To docker.io
id: push-to-docker
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: docker.io/osadal
username: osadal
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-docker.outputs.registry-paths }}"
Empty file modified Dockerfile
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ This image uses environment variables to allow the configuration of some paramet
* Accepted values: <NO|YES>
* Description: Set to YES if you want to disable the PORT security check that ensures that outgoing data connections can only connect to the client. Only enable if you know what you are doing! Legitimate use for this is to facilitate FXP support.

----
* Variable name: `LISTEN_PORT`
* Default value: 21
* Accepted values: Any valid port number.
* Description: Set to a port above 1024 if you are using podman in rootless mode.

----

Exposed ports and volumes
Expand Down
23 changes: 8 additions & 15 deletions run-vsftpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ fi

# If no env var has been specified, generate a random password for FTP_USER:
if [ "$FTP_PASS" = "**Random**" ]; then
export FTP_PASS=`cat /dev/urandom | tr -dc A-Z-a-z-0-9 | head -c${1:-16}`
FTP_PASS=$(tr -dc A-Z-a-z-0-9 </dev/urandom | head -c"${1:-16}")
export FTP_PASS
fi

# Do not log to STDOUT by default:
Expand All @@ -26,23 +27,15 @@ echo -e "${FTP_USER}\n${FTP_PASS}" > /etc/vsftpd/virtual_users.txt

# Set passive mode parameters:
if [ "$PASV_ADDRESS" = "**IPv4**" ]; then
export PASV_ADDRESS=$(/sbin/ip route|awk '/default/ { print $3 }')
PASV_ADDRESS=$(/sbin/ip route|awk '/default/ { print $3 }')
export PASV_ADDRESS
fi

echo "pasv_address=${PASV_ADDRESS}" >> /etc/vsftpd/vsftpd.conf
echo "pasv_max_port=${PASV_MAX_PORT}" >> /etc/vsftpd/vsftpd.conf
echo "pasv_min_port=${PASV_MIN_PORT}" >> /etc/vsftpd/vsftpd.conf
echo "pasv_addr_resolve=${PASV_ADDR_RESOLVE}" >> /etc/vsftpd/vsftpd.conf
echo "pasv_enable=${PASV_ENABLE}" >> /etc/vsftpd/vsftpd.conf
echo "file_open_mode=${FILE_OPEN_MODE}" >> /etc/vsftpd/vsftpd.conf
echo "local_umask=${LOCAL_UMASK}" >> /etc/vsftpd/vsftpd.conf
echo "xferlog_std_format=${XFERLOG_STD_FORMAT}" >> /etc/vsftpd/vsftpd.conf
echo "reverse_lookup_enable=${REVERSE_LOOKUP_ENABLE}" >> /etc/vsftpd/vsftpd.conf
echo "pasv_promiscuous=${PASV_PROMISCUOUS}" >> /etc/vsftpd/vsftpd.conf
echo "port_promiscuous=${PORT_PROMISCUOUS}" >> /etc/vsftpd/vsftpd.conf
{ echo "pasv_address=${PASV_ADDRESS}"; echo "pasv_max_port=${PASV_MAX_PORT}"; echo "pasv_min_port=${PASV_MIN_PORT}"; echo "pasv_addr_resolve=${PASV_ADDR_RESOLVE}"; echo "pasv_enable=${PASV_ENABLE}"; echo "file_open_mode=${FILE_OPEN_MODE}"; echo "local_umask=${LOCAL_UMASK}"; echo "xferlog_std_format=${XFERLOG_STD_FORMAT}"; echo "reverse_lookup_enable=${REVERSE_LOOKUP_ENABLE}"; echo "pasv_promiscuous=${PASV_PROMISCUOUS}"; echo "port_promiscuous=${PORT_PROMISCUOUS}"; echo "listen_port=${LISTEN_PORT}"; } >> /etc/vsftpd/vsftpd.conf

# Get log file path
export LOG_FILE=`grep xferlog_file /etc/vsftpd/vsftpd.conf|cut -d= -f2`
LOG_FILE=$(grep xferlog_file /etc/vsftpd/vsftpd.conf|cut -d= -f2)
export LOG_FILE

# stdout server info:
if [ ! $LOG_STDOUT ]; then
Expand All @@ -62,7 +55,7 @@ cat << EOB
· Redirect vsftpd log to STDOUT: No.
EOB
else
/usr/bin/ln -sf /dev/stdout $LOG_FILE
/usr/bin/ln -sf /dev/stdout "$LOG_FILE"
fi

# Run vsftpd:
Expand Down