From 0d0b1e0b0b35b28aa8add3f2bf752a8020ce21ba Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Mon, 7 Nov 2022 12:43:51 +0530 Subject: [PATCH 1/7] Added support for a new env variable that sets the listen port This will enable vsftpd to set listen port higher than 1024 if required so that we can run the container using podman in rootless mode. --- README.md | 6 ++++++ run-vsftpd.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 38b1799..1481840 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,12 @@ This image uses environment variables to allow the configuration of some paramet * Accepted values: * 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 diff --git a/run-vsftpd.sh b/run-vsftpd.sh index e731236..c7018b8 100644 --- a/run-vsftpd.sh +++ b/run-vsftpd.sh @@ -40,6 +40,7 @@ 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 "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` From 7d04ae2f5f991f2e0d7fb494a05a0311069a9d45 Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Mon, 7 Nov 2022 19:11:09 +0530 Subject: [PATCH 2/7] Create container_build.yml --- .github/workflows/container_build.yml | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/container_build.yml diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml new file mode 100644 index 0000000..c094bc4 --- /dev/null +++ b/.github/workflows/container_build.yml @@ -0,0 +1,34 @@ +name: Build and Push Image +on: [ push ] + +jobs: + build: + name: Build and push image + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - 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 }}" From 0323bee541e9e196da7e1acea15de8b9e0b41bb5 Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Mon, 7 Nov 2022 19:11:20 +0530 Subject: [PATCH 3/7] Make Dockerfile executable --- Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Dockerfile diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 From 3140f90c2d06b9f429a14d90b25d3459fe46fecd Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Mon, 7 Nov 2022 23:05:16 +0530 Subject: [PATCH 4/7] Added manual trigger capability --- .github/workflows/container_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index c094bc4..e736882 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -1,5 +1,5 @@ name: Build and Push Image -on: [ push ] +on: [ push,workflow_dispatch ] jobs: build: From 76da763a0c883bd9d4ca040cd64c7eeb22be2d9e Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Tue, 8 Nov 2022 09:05:02 +0530 Subject: [PATCH 5/7] Added shellcheck as a github action Also fixed the issues identified by running shellcheck manually. --- .github/workflows/container_build.yml | 10 +++++++++- run-vsftpd.sh | 24 ++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index e736882..7cc7ba3 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -7,7 +7,15 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - name: Shellcheck + id: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master - name: Build Image id: build-image diff --git a/run-vsftpd.sh b/run-vsftpd.sh index c7018b8..baf4c35 100644 --- a/run-vsftpd.sh +++ b/run-vsftpd.sh @@ -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 /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 "listen_port=${LISTEN_PORT}" >> /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 @@ -63,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: From 1dbc8859d17eb5e9664fec31eb3a69f244d493d6 Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Fri, 11 Nov 2022 07:37:45 +0530 Subject: [PATCH 6/7] corrected syntax --- .github/workflows/container_build.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 7cc7ba3..479ba5b 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -11,11 +11,7 @@ jobs: - name: Shellcheck id: Shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master + uses: ludeeus/action-shellcheck@master - name: Build Image id: build-image From 18c95e60f425e7d66255a2d8004f2bf157e2ca15 Mon Sep 17 00:00:00 2001 From: Osada Lakmal Paranaliyanage Date: Fri, 11 Nov 2022 07:40:01 +0530 Subject: [PATCH 7/7] Add env as well --- .github/workflows/container_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 479ba5b..cb35fd9 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -4,6 +4,7 @@ on: [ push,workflow_dispatch ] jobs: build: name: Build and push image + environment: MainCI runs-on: ubuntu-20.04 steps: