Dmitry V. Levin | f23b097 | 2014-05-29 21:35:34 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check how SCM_RIGHTS control messages are decoded in -y mode. |
| 4 | |
| 5 | . "${srcdir=.}/init.sh" |
| 6 | |
| 7 | # strace -y is implemented using /proc/$pid/fd |
| 8 | [ -d /proc/self/fd/ ] || |
| 9 | framework_skip_ '/proc/self/fd/ is not available' |
| 10 | |
| 11 | check_prog grep |
Dmitry V. Levin | f23b097 | 2014-05-29 21:35:34 +0000 | [diff] [blame] | 12 | |
| 13 | rm -f $LOG.* |
| 14 | |
| 15 | ./scm_rights || |
| 16 | fail_ 'scm_rights failed' |
| 17 | |
| 18 | args="-tt -ff -y -xx -enetwork -o $LOG ./scm_rights" |
| 19 | $STRACE $args || |
| 20 | fail_ "$STRACE $args failed" |
| 21 | |
| 22 | "$srcdir"/../strace-log-merge $LOG > $LOG || { |
| 23 | cat $LOG |
| 24 | fail_ 'strace-log-merge failed' |
| 25 | } |
| 26 | rm -f $LOG.* |
| 27 | |
| 28 | grep_log() |
| 29 | { |
| 30 | local syscall="$1"; shift |
| 31 | local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +' |
| 32 | |
| 33 | LC_ALL=C grep -E -x "$prefix$syscall$*" $LOG > /dev/null || { |
| 34 | cat $LOG |
| 35 | fail_ "$STRACE $args failed to trace \"$syscall\" properly" |
| 36 | } |
| 37 | } |
| 38 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 39 | n='[1-9][0-9]*' |
| 40 | msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"\\x00\\x00\\x00\\x00[^"]*", '"$n"'\}\], msg_controllen='"$n" |
| 41 | rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \[3</dev/null>, 4</dev/zero>\]\}' |
| 42 | creds='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, \{pid='"$n"', uid=[0-9]+, gid=[0-9]+\}\}' |
| 43 | grep_log sendmsg '\(1<socket:\[[0-9]+\]>, '"$msg"', \['"$rights"'\], msg_flags=0\}, 0\) += '"$n" |
| 44 | grep_log recvmsg '\(0<socket:\[[0-9]+\]>, '"$msg"', \['"$creds"', '"$rights"'\], msg_flags=0\}, 0\) += '"$n" |
Dmitry V. Levin | f23b097 | 2014-05-29 21:35:34 +0000 | [diff] [blame] | 45 | |
| 46 | exit 0 |