better efingerd maintenance

This commit is contained in:
James Tomasino 2019-01-01 14:44:04 -05:00
parent a74223717a
commit ab77a34340
7 changed files with 91 additions and 54 deletions

View File

@ -1,4 +1,4 @@
install: bin templates man completion files skel
install: bin templates man completion files efingerd
bin:
stow -t "/usr/local/bin" bin
@ -19,14 +19,16 @@ files:
mkdir -p "/usr/share/games/fortunes"
cd files && stow -t "/usr/share/games/fortunes" fortunes
skel:
rsync -avzh skel/ /etc/skel/
efingerd:
mkdir -p "/etc/efingerd"
stow -t "/etc/efingerd" efingerd
uninstall:
stow -t "/usr/local/bin" -D bin
stow -t "/etc/templates" -D templates
stow -t "/usr/share/man/man1/" -D man
stow -t "/etc/bash_completion.d" -D completion
stow -t "/etc/efingerd" -D efingerd
cd files && stow -t "/usr/share/games/fortunes" -D fortunes
.PHONY: bin templates man completion files skel
.PHONY: bin templates man completion files efingerd

View File

@ -1,23 +0,0 @@
#!/bin/sh
run_user=$(id -u)
if [ "$run_user" -eq 0 ]; then
for d in /home/*
do
if [ ! -f "${d}/.efingerd" ]; then
# if no .efingerd file, add one
printf "%s - no .efingerd found\\n" "$d"
owner="$(basename "$d")"
cp "/etc/skel/.efingerd" "${d}/.efingerd"
chown "$owner" "${d}/.efingerd"
chgrp "$owner" "${d}/.efingerd"
else
version="$(sed -n '2{p;q}' "${d}/.efingerd")"
if [ "$version" = "# version 1" ]; then
printf "%s - version 1\\n" "$d"
else
printf "%s - customized\\n" "$d"
fi
fi
done
fi

8
efingerd/list Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
. /etc/efingerd/log
cat <<EOM
QEC STATUS: DENIED
THIS REQUEST HAS BEEN LOGGED
EOM

6
efingerd/log Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# file /var/log/efingerd.log has to be writeable by UID
# efingerd runs under for this to work
echo `date` "$3" fingered from "$1@$2" >>/var/log/efingerd.log

34
efingerd/luser Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
# $1 = identity of remote user fingering you
# $2 = address of remote machine fingering you
# $3 = name of user being fingered (you!)
. /etc/efingerd/log
if [ "$3" = "root" ]; then
printf "QEC STATUS: ERROR\\nROOT ACCESS DENIED.\\n"
else
user_folder="/home/${3}"
# Prints current user's ship roster
printf "Ships registered to user \"%s\"\\n" "$3"
/usr/local/bin/roster "$3" | awk '{$1=">>"; print $0}'
# This portion is maintained for compatability with fellowsh
# a tildeverse/pubnix social network built on fingerd
printf "Plan:\\n"
if [ -f "${user_folder}/.plan" ]; then
cat "${user_folder}/.plan"
else
printf "No Plan.\\n"
fi
printf "Project:\\n"
if [ -f "${user_folder}/.project" ]; then
cat "${user_folder}/.project"
else
printf "No Project.\\n"
fi
if [ -f "${user_folder}/.tz" ]; then
printf "Timezone: %s\\n" "$(cat "${user_folder}/.tz")"
fi
fi

37
efingerd/nouser Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
if [ "$3" = "latest" ]; then
echo "The latest messages logged to the QEC:"
/usr/local/bin/latest
exit 0
fi
if [ "$3" = "time" ]; then
echo The time is...
date
exit 0
fi
if [ "$3" = "ping" ]; then
echo "PONG!"
ping -c 5 "$2"
exit 0
fi
if [ "$3" = "fortune" ]; then
/usr/games/fortune
exit 0
fi
if [ "$3" = "uptime" ]; then
/usr/bin/uptime
exit 0
fi
. /etc/efingerd/log
cat <<EOM
QEC STATUS: ERROR
SHIP OR USER NOT DEFINED.
THIS REQUEST HAS BEEN LOGGED.
EOM

View File

@ -1,27 +0,0 @@
#!/bin/sh
# version 1
# $1 = identity of remote user fingering you
# $2 = address of remote machine fingering you
# $3 = name of user being fingered (you!)
# Prints current user's ship roster
printf "Ships registered to user \"%s\"\\n" "$3"
/usr/local/bin/roster "$3" | awk '{$1=">>"; print $0}'
# This portion is maintained for compatability with fellowsh
# a tildeverse/pubnix social network built on fingerd
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
printf "Plan:\\n"
if [ -f "${SCRIPTPATH}/.plan" ]; then
cat "${SCRIPTPATH}/.plan"
else
printf "No Plan.\\n"
fi
printf "Project:\\n"
if [ -f "${SCRIPTPATH}/.project" ]; then
cat "${SCRIPTPATH}/.project"
else
printf "No Project.\\n"
fi