#!/usr/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/proftpd-show-vuser - Show proftpd virtual user # # Creation: 2019-09-13 ap # Last Update: $Id$ # # Copyright (c) 2019-2022 Ansgar Puester, ansgar.puester(at)freenet(dot)de # Copyright (c) 2024-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib proftpd_virtual_user_auth='/etc/proftpd/auth' proftpd_virtual_user_passwd="${proftpd_virtual_user_auth}/passwd" proftpd_virtual_user_group="${proftpd_virtual_user_auth}/group" ASK='/var/install/bin/ask' # --------------------------------------------------------------------------- # check if console minium 80x24 # --------------------------------------------------------------------------- check_screensize case ${?} in 0) : # nothing to do ;; *) exit 1 ;; esac config_file='/etc/config.d/proftpd' . ${config_file} # --------------------------------------------------------------------------- # print header line # --------------------------------------------------------------------------- print_header_line() { clrhome mecho --info "Show ProFTPD virtual user" } # --------------------------------------------------------------------------- # print footer # --------------------------------------------------------------------------- footer() { mecho _ask_tmpfile=$(mktemp -t XXXXXXXXXXXXX) ${ASK} "Continue" 'no' >${_ask_tmpfile} rc=${?} read answer < ${_ask_tmpfile} rm -f ${_ask_tmpfile} if [ ${rc} = 255 ] then answer=no fi case "${answer}" in no) ret=1 ;; yes) ret=0 ;; esac return ${ret} } print_header_line if [ ! ${PROFTPD_ENABLE_VIRTUAL_USERS} = 'yes' ] then mecho --error "ProFTPd virtual users are not enabled" mecho --error "no user can be selected" footer exit fi fini=false while [ $fini = 'false' ] do mecho _ask_tmpfile=$(mktemp -t XXXXXXXXXXXXX) ${ASK} "ProFTPd virtual user" "" "+" >${_ask_tmpfile} rc=${?} read user < ${_ask_tmpfile} rm -f ${_ask_tmpfile} if [ ${rc} = 255 ] then user='' fi if [ -n "${user}" ] then if [ -s "${proftpd_virtual_user_passwd}" ] then if grep -q "^${user}:" ${proftpd_virtual_user_passwd} then line=$(grep "^${user}:" ${proftpd_virtual_user_passwd}) user=$(echo "$line" | cut -d: -f 1) pw=$(echo "$line" | cut -d: -f 2) uid=$(echo "$line" | cut -d: -f 3) gid=$(echo "$line" | cut -d: -f 4) home=$(echo "$line" | cut -d: -f 6) gline=$(grep ":${gid}:" ${proftpd_virtual_user_group}) group=$(echo "$gline" | cut -d: -f 1) echo "Login : ${user}" echo "Password : ${pw}" echo "UID : ${uid}" echo "GID : ${gid} (${group})" echo "Directory : ${home}" else mecho -n --error "ProFTPD virtual user " mecho -n "'${user}' " mecho --error "does not exist" fi else mecho --error "No ProFTPD virtual users are defined" fi fi if footer then print_header_line else fini=true fi done # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------