1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
#!/bin/sh
# File: sfdconf
#
# Author: Ulli Horlacher (framstag@rus.uni-stuttgart.de)
#
# History:
#
# 23 Nov 1997 Framstag initial version
# 4 Jan 1998 Framstag added -r option
#
# The daemon configuration helper program for the sendfile package.
#
# Copyright 1997,1998 Ulli Horlacher
# This file is covered by the GNU General Public License
#SPOOL=`sendfile -qW=spool`
SPOOL=/var/spool/sendfile
INLOG=/var/spool/sendfile/LOG/in
OUTLOG=/var/spool/sendfile/LOG/out
CONFIG=/usr/local/etc/sendfile.cf
ALIASES=/usr/local/etc/sendfile.aliases
DENY=/usr/local/etc/sendfile.deny
ALLOW=/usr/local/etc/sendfile.allow
EDITOR=${EDITOR:=vi}
PAGER=${PAGER:=more}
PRG=`basename $0`
FILE=
usage() {
echo "$PRG is the sendfiled configuration helper"
echo "usage: $PRG OPTION ARGUMENT"
echo "options: -l -- list"
echo " -e -- edit"
echo " -i -- initialize (= edit with default values)"
echo " -r -- receiving mode"
echo "arguments for options -l -e -i :"
echo " config -- sendfiled configuration file"
echo " redirect -- system alias (redirection) file"
echo " allow -- users allow-only file"
echo " deny -- users deny file"
echo "arguments for option -l :"
echo " inlog -- input log file (only with -l option)"
echo " outlog -- output log file (only with -l option)"
echo "arguments for option -r :"
echo " enable -- enable receiving (only with -r option)"
echo " disable -- disable receiving (only with -r option)"
echo "examples:"
echo " $PRG -l deny # list the deny file"
echo " $PRG -e config # edit the configuration file"
exit
}
testfile() {
error="`(cat $1 >/dev/null) 2>&1 | sed 's/cat: //'`"
if [ "$error" ]; then
echo "%$PRG-Error: $error" >&2
exit 1
fi
}
init_append() {
if [ -r $FILE ]; then
cat <<EOD>> $FILE.tmp
## The next lines are from your old `basename $FILE` file.
## You may want to delete them (if they are garbage).
EOD
cat $FILE >> $FILE.tmp
fi
mv $FILE.tmp $FILE
}
init_aliases() {
cat <<EOD> $FILE.tmp || exit 1
## This is the global aliases file for sendfiled.
## It is used only for redirection of incoming files or messages!
## Text after a # is a comment and will be ignored.
## The syntax is: ALIAS USER[@HOST], examples:
# zrxh0370 framstag
# root admin@bigvax.saft.net
EOD
init_append
}
init_config() {
cat <<EOD> $FILE.tmp || exit 1
CONFIG
EOD
init_append
}
init_deny() {
cat <<EOD> $FILE.tmp || exit 1
## This is the exclusion list for sendfiled.
## Users which are listed here are not allowed to receive files or messages.
## Warning: if sendfile.allow contains any user names it will be used as an
## allow-only list and this file here will be ignored.
## Text after a # is a comment.
daemon
bin
news
ftp
lpr
uucp
anonymous
nobody
OUTGOING
LOG
EOD
init_append
}
init_allow() {
cat <<EOD> $FILE.tmp || exit 1
## This is the allow-only list for sendfiled.
## Only users which are listed here are allowed to receive files or messages.
## If this files contains no user names at all, it will be ignored and
## senfile.deny will be used instead as an exclusion list.
## Text after a # is a comment.
EOD
init_append
}
#args=`getopt h?lei $*` || usage
#set -- x $args
#while shift; do
# case $1 in
# -\?|-h) usage;;
# -l) list=true;;
# -e) edit=true;;
# -i) init=true;;
# --) shift; break;;
# esac
#done
list=
edit=
init=
rmode=
case "$1" in
-l) list=true;;
-e) edit=true;;
-i) init=true;;
-r) rmode=true;;
*) usage;;
esac
if [ "$rmode" = true ]; then
case "$2" in
e|enable|y) rmode=enable;;
d|disable|n) rmode=disable;;
*) rmode=show;;
esac
else
case "$2" in
r|redirect) FILE=$ALIASES;;
c|conf|config) FILE=$CONFIG;;
a|allow) FILE=$ALLOW;;
d|deny) FILE=$DENY;;
i|inlog) FILE=$INLOG; log=true;;
o|outlog) FILE=$OUTLOG; log=true;;
*) usage;;
esac
fi
if [ "$rmode" ]; then
status=0
case "$rmode" in
enable) rm -f $SPOOL/.nosendfile; status=$?;;
disable) touch $SPOOL/.nosendfile; status=$?;;
esac
if [ -f $SPOOL/.nosendfile ]; then
echo "receiving of files is disabled"
else
echo "receiving of files is enabled"
fi
exit $status
fi
if [ "$log" = true ]; then
if [ "$list" != true ]; then usage; fi
testfile $FILE
utf7decode $FILE | $PAGER
exit $?
fi
if [ "$list" = true ]; then
testfile $FILE
$PAGER $FILE
exit $?
fi
if [ "$edit" = true ]; then
if [ -f $FILE ]; then
$EDITOR $FILE
exit $?
else
echo "%$PRG-Error: $FILE does not exist" >&2
echo "%$PRG-Info: you can create it with: $PRG -i $2" >&2
exit 1
fi
fi
if [ "$init" = true ]; then
trap "rm -f $FILE.tmp;exit" 1 2 3 15
case $FILE in
*aliases) init_aliases;;
*cf) init_config;;
*allow) init_allow;;
*deny) init_deny;;
esac
$EDITOR $FILE
exit $?
fi
|