Home | History | Annotate | Download | only in regress
      1 #	$OpenBSD: forcecommand.sh,v 1.3 2015/03/03 22:35:19 markus Exp $
      2 #	Placed in the Public Domain.
      3 
      4 tid="forced command"
      5 
      6 cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
      7 
      8 cp /dev/null $OBJ/authorized_keys_$USER
      9 for t in ${SSH_KEYTYPES}; do
     10 	printf 'command="true" ' >>$OBJ/authorized_keys_$USER
     11 	cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
     12 done
     13 
     14 for p in ${SSH_PROTOCOLS}; do
     15 	trace "forced command in key option proto $p"
     16 	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
     17 	    fail "forced command in key proto $p"
     18 done
     19 
     20 cp /dev/null $OBJ/authorized_keys_$USER
     21 for t in ${SSH_KEYTYPES}; do
     22 	printf 'command="false" ' >> $OBJ/authorized_keys_$USER
     23 	cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
     24 done
     25 
     26 cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
     27 echo "ForceCommand true" >> $OBJ/sshd_proxy
     28 
     29 for p in ${SSH_PROTOCOLS}; do
     30 	trace "forced command in sshd_config overrides key option proto $p"
     31 	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
     32 	    fail "forced command in key proto $p"
     33 done
     34 
     35 cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
     36 echo "ForceCommand false" >> $OBJ/sshd_proxy
     37 echo "Match User $USER" >> $OBJ/sshd_proxy
     38 echo "    ForceCommand true" >> $OBJ/sshd_proxy
     39 
     40 for p in ${SSH_PROTOCOLS}; do
     41 	trace "forced command with match proto $p"
     42 	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
     43 	    fail "forced command in key proto $p"
     44 done
     45