#!/bin/bash -e # Exit immediately if a simple command fails. # This script will generate the list $OUTPUT of $HOME (and put it there), # using the access rights of $USER. # The defaults are: ls-R, the anonymous ftp home, the anonymous user of vsftpd. readonly HOME=/var/ftp/ \ USER=vsftpd \ OUTPUT=ls-R cd "$HOME" readonly new="$(mktemp "$OUTPUT".XXXX)" trap 'rm -f "$new"' EXIT su "$USER" -c 'find -noleaf -printf "%P\n" || true' --shell /bin/sh &> "$new" chmod a+r "$new" mv -f "$new" "$OUTPUT"