root/trunk/tools/lock.info/authorized_keys_guard

Revision 244, 0.6 kB (checked in by depesz, 7 years ago)

Script to show detailed information about locks in database

  • Property svn:executable set to *
Line 
1 #!/bin/bash
2 if echo "$SSH_ORIGINAL_COMMAND" | grep -qE '^info [0-9]+$'
3 then
4     local_port="${SSH_ORIGINAL_COMMAND##* }"
5     pid="$( sudo netstat -ntap | awk '$4~/:'"$local_port"'$/ && $6 == "ESTABLISHED" {print $7}' | cut -d/ -f1 )"
6     printf "Remote PID        : %d\n" "$pid"
7
8     printf "Working directory : %s\n" "$( sudo readlink /proc/$pid/cwd )"
9     printf "Executable        : %s\n" "$( sudo readlink /proc/$pid/exe )"
10     printf "Real arguments    :"
11     while IFS= read -rd '' argument
12     do
13         printf " %q" "$argument"
14     done < <( sudo cat /proc/$pid/cmdline )
15     echo
16 fi
Note: See TracBrowser for help on using the browser.