summaryrefslogtreecommitdiff
path: root/nocompile
diff options
context:
space:
mode:
Diffstat (limited to 'nocompile')
-rwxr-xr-xnocompile/bin/identd.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/nocompile/bin/identd.sh b/nocompile/bin/identd.sh
new file mode 100755
index 0000000..67de244
--- /dev/null
+++ b/nocompile/bin/identd.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+IPA="$(/usr/local/libexec/sockip | head -n1)"
+IPB="$(/usr/local/libexec/peerip | head -n1)"
+#read the ports from stdin to be looked up.
+#in the format: PORT, PORT\r\n
+read LINE
+PB="$(printf "%s" "$LINE" | cut -d, -f1 | tr -cd "[0-9]")"
+PA="$(printf "%s" "$LINE" | cut -d, -f2 | tr -cd "[0-9]")"
+#example output:
+#57132,6667:USERID:UNIX:segfault
+#5132,6667:ERROR:NO-USER
+USER="$(getent passwd "$(tcpident $IPA $PA $IPB $PB)" | cut -d: -f1)"
+if [ "_$USER" != "_" ];then
+ printf "%s,%s:USERID:UNIX:%s\r\n" "$PB" "$PA" "$USER"
+else
+ printf "%s,%s:ERROR:NO-USER\r\n" "$PB" "$PA"
+fi