summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-07-29 17:52:13 -0400
committerAndrew Cady <d@jerkface.net>2019-07-29 19:09:02 -0400
commit134c077b0607d702f248d26eea49360ae06d0450 (patch)
tree128dc6a99423d966d9f0a51200a96d0e48473357
parent3fa847bc24e79f4c779108caa97549263f407508 (diff)
factor out GET_NOMIC_USER
-rwxr-xr-xhooks/post-receive63
1 files changed, 39 insertions, 24 deletions
diff --git a/hooks/post-receive b/hooks/post-receive
index 67e7610..74fe96b 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -4,34 +4,49 @@ then
4 GIT_WORK_TREE=. git checkout -f master -- hooks/post-receive 4 GIT_WORK_TREE=. git checkout -f master -- hooks/post-receive
5 DID_SELF_UPDATE=y exec hooks/post-receive 5 DID_SELF_UPDATE=y exec hooks/post-receive
6fi 6fi
7exec >&2
8 7
9GIT_WORK_TREE=. git checkout -f master -- authorized_keys.d/\* 8WARNINGS=y
10
11if [ "$SSH_USER_AUTH" ] && [ -f "$SSH_USER_AUTH" ]
12then
13 read authtype keytype keyval < "$SSH_USER_AUTH"
14 [ "$authtype" = publickey ] || exit
15 9
16 user= 10warn()
17 for keyname in authorized_keys.d/* 11{
18 do 12 if [ "$WARNINGS" ]
19 while read a b _ 13 then
20 do 14 printf '%s: Warning: %s\n' "$0" "$*" >&2
21 case "$a $b" in 15 fi
22 "$keytype $keyval") 16}
23 user=${keyname#authorized_keys.d/}
24 break
25 ;;
26 esac
27 done < "$keyname"
28 done
29 17
30 if [ "$user" ] 18GET_NOMIC_USER()
19{
20 if [ "$NOMIC_USER" ]
31 then 21 then
32 echo "user=$user" 22 return
23 elif [ "$SSH_USER_AUTH" ] && [ -f "$SSH_USER_AUTH" ]
24 then
25 read authtype keytype keyval < "$SSH_USER_AUTH"
26 [ "$authtype" = publickey ] || exit
27
28 for keyname in authorized_keys.d/*
29 do
30 while read a b _
31 do
32 case "$a $b" in
33 "$keytype $keyval")
34 NOMIC_USER=${keyname#authorized_keys.d/}
35 break
36 ;;
37 esac
38 done < "$keyname"
39 done
40 true
41 else
42 warn "\$SSH_USER_AUTH missing. Try putting 'ExposeAuthInfo yes' in /etc/ssh/sshd_config"
43 false
33 fi 44 fi
45}
34 46
35else 47GIT_WORK_TREE=. git checkout -f master -- authorized_keys.d/\*
36 echo "\$SSH_USER_AUTH missing. Try putting 'ExposeAuthInfo yes' in /etc/ssh/sshd_config" 48
49if GET_NOMIC_USER
50then
51 warn "NOMIC_USER=$NOMIC_USER"
37fi 52fi