summaryrefslogtreecommitdiff
path: root/nocompile
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-12-30 07:25:39 -0600
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-12-30 07:25:39 -0600
commit86ba931697790d4da2515f4457ebfb3f20b43860 (patch)
tree839c1f7ae94fd32639d3311c3a2faee34f88f04c /nocompile
parent05d677a3d3e9e540dffd35c76e35335bf43ead7d (diff)
downloadmisc-86ba931697790d4da2515f4457ebfb3f20b43860.tar.gz
misc-86ba931697790d4da2515f4457ebfb3f20b43860.zip
all those .c changes were mostly fixes of warnings for the change in rebuild.sh being changed to use -Wall.
gethostbyname was almost completely rewritten to work better with ipv6 for gopherd.sh gopherd.sh was rewritten to use gethostbyname instead of dig and to cut out any link-local interface indicators from the output of hop0 and to ignore an error if ipA -> hostname -> ipB causes ipA to be not the same as ipB. Don't remember if there's anything else.
Diffstat (limited to 'nocompile')
-rwxr-xr-xnocompile/libexec/gopherd.sh31
1 files changed, 19 insertions, 12 deletions
diff --git a/nocompile/libexec/gopherd.sh b/nocompile/libexec/gopherd.sh
index 130d861..3b44296 100755
--- a/nocompile/libexec/gopherd.sh
+++ b/nocompile/libexec/gopherd.sh
@@ -12,7 +12,9 @@ export PATH=$PATH:/usr/local/bin
read -t 10 req
base="$1"
arg=$(echo "$req" | tr -d '\r' | cut -f2)
-req=$(echo "$req" | tr -d '\r' | cut -f1)
+#req=$(echo "$req" | unescape | tr -d '\r' | cut -f1)
+req=$(echo "$req" | tr -d '\r' | sed 's/\/*$//' | cut -f1)
+cd ${base}
realpath="$(normalpath "${base}${req}")"
if grep -v "^${base}" <<< "${realpath}" > /dev/null;then
echo -e 'i'${base}'\tasdf\tasdf\tasdf\r'
@@ -20,18 +22,23 @@ if grep -v "^${base}" <<< "${realpath}" > /dev/null;then
echo -e 'ierror!!! cant find base in realpath\tasdf\tasdf\tasdf\r'
exit 1
fi
-myIP=$(hop0 $(/usr/local/libexec/peerip | head -n1))
+myIP=$(hop0 $(/usr/local/libexec/peerip | head -n1) | cut -d% -f1)
hostname=$(rdns ${myIP})
if [ ! "${hostname}" ]; then
hostname=${myIP}
else
if strstr "${myIP}" ":";then
- if [ $(dig -t AAAA +short $hostname) != ${myIP} ];then
- logger "hostname (${hostname}) and IP (${myIP}) aren't matching up.";
- exit 2
+ if [ $(gethostbyname $hostname 6) != ${myIP} ];then
+ printf ""
+# echo "fucked off #1"
+# echo "$myIP != $(gethostbyname $hostname 6)"
+# logger "hostname (${hostname}) and IP (${myIP}) aren't matching up.";
+# exit 2
+#jimmy cracked corn but nobody gives a shit.
fi
else
- if [ $(dig -t A +short $hostname) != ${myIP} ];then
+ if [ $(gethostbyname $hostname) != ${myIP} ];then
+ echo "fucked off #2"
logger "hostname (${hostname}) and IP (${myIP}) aren't matching up.";
exit 2
fi
@@ -47,25 +54,25 @@ if strstr "$type" "directory";then
ls "${realpath}" | while read i;do
stype=$(file -L "${realpath}/${i}" | cut -d: -f2-)
if strstr "$stype" "directory"; then
- printf "1%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port
+ printf "1%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port
else
- if [ "_$(stat -L "${realpath}/${i}" | grep -v l | cut '-d ' -f3 | tr 'x' '\n' | wc -l | tr -d ' ')" = "_4" ] ;then
- printf "7%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port
+ if [ "_$(stat -L "${realpath}/${i}" | cut '-d ' -f3 | grep -v l | tr 'x' '\n' | wc -l | tr -d ' ')" = "_4" ] ;then
+ printf "7%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port
else
- printf "0%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port
+ printf "0%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port
fi
fi
done
printf ".\r\n"
else
#this shit is ugly
- numX="$(stat -L "${realpath}" | grep -v l | cut '-d ' -f3 | tr 'x' '\n' | wc -l | tr -d ' ')"
+ numX="$(stat -L "${realpath}" | cut '-d ' -f3 | grep -v l | tr 'x' '\n' | wc -l | tr -d ' ')"
if [ "_$numX" = "_3" ];then
#an executable that outputs text and pretends to be a type 0.
"${realpath}"
elif [ "_$numX" = "_4" ];then
#a type 7
- "${realpath}" $arg | sed "s/\$/"`printf "\r"`"/g"
+ "${realpath}" "$arg" | sed "s/\$/"`printf "\r"`"/g"
else
#output the text of the file
cat "${realpath}"