-
Notifications
You must be signed in to change notification settings - Fork 1
/
do_audit_for.sh
executable file
·60 lines (47 loc) · 1.27 KB
/
do_audit_for.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
export AUDIT_USER=${1}
echo \$0: $0
COMMANDS=${SSH_ORIGINAL_COMMAND-'audit 403332564 6'}
# parse SSH_ORIGINAL_COMMAND to figure out what the user wanted to do
read tool session user <<< "$COMMANDS"
echo tool: $tool
echo session: $session
echo user: $user
export AUDIT_TOOL=${tool}
export AUDIT_SESSION=${session}
export AUDIT_UID=${user}
export BASE=$HOME/session
export SESS_KEY="${user}-${session}"
export BRANCH="audit/$(date +%F)-${SESS_KEY}"
export WORK_BASE="$HOME/sessions/${SESS_KEY}"
export WORK_CONF=$WORK_BASE/conf
export WORK_REMOTE=$WORK_BASE/remote.git
export WORK_LOCAL=$WORK_BASE/local
export VMODEM=${WORK_BASE}/vmodem
export PATH="$HOME/bin:$PATH"
export WORK_BASE WORK_CONF WORK_REMOTE WORK_LOCAL BASE VMODEM
SESSION_CONFIG=$WORK_CONF/audit.config
export SESSION_CONFIG BRANCH SESS_KEY
. common
if [[ $AUDIT_TOOL == "audit" ]] ; then
PHR_REPO=$(read_config registration.phr)
export PHR_REPO
env
setup_audit_work
echo "CREATE VMODEM" $(which create_vmodem)
create_vmodem $WORK_CONF/audit.config
sleep 2
perform_audit
clean_audit_work
else
env
echo "HOWDY, $user"
echo "DID NOT UNDERSTAND:" $AUDIT_TOOL
echo "YOUR COMMAND:"
ssh-add -l
echo $SSH_ORIGINAL_COMMAND
fi
ps
echo "THIS IS MY SPECIAL LOGIN SHELL. HANGING UP."
#####
# EOF