From 2b4697d313c0dfae862ee42d4bbc608e50c5eb22 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Sun, 3 May 2015 06:31:59 -0500 Subject: added a NetBSDian tcpident which doesn't even deal with real sockets so you can check any ports and IPs you want. identd.sh uses tcpident and peerip and sockip programs to be a simple inetd runnable ident service. --- nocompile/bin/identd.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 nocompile/bin/identd.sh (limited to 'nocompile') 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 -- cgit v1.2.3