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 11check_prog grep 12check_prog rm 13 14rm -f $LOG.* 15 16./scm_rights || 17 fail_ 'scm_rights failed' 18 19args="-tt -ff -y -xx -enetwork -o $LOG ./scm_rights" 20$STRACE $args || 21 fail_ "$STRACE $args failed" 22 23"$srcdir"/../strace-log-merge $LOG > $LOG || { 24 cat $LOG 25 fail_ 'strace-log-merge failed' 26} 27rm -f $LOG.* 28 29grep_log() 30{ 31 local syscall="$1"; shift 32 local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +' 33 34 LC_ALL=C grep -E -x "$prefix$syscall$*" $LOG > /dev/null || { 35 cat $LOG 36 fail_ "$STRACE $args failed to trace \"$syscall\" properly" 37 } 38} 39 40grep_log sendmsg '\(1<socket:\[[0-9]+\]>, \{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"\\x00\\x00\\x00\\x00[^"]*", [1-9][0-9]*\}\], msg_controllen=[1-9][0-9]*, \{cmsg_len=[1-9][0-9]*, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \{3</dev/null>\}\}, msg_flags=0\}, 0\) += [1-9][0-9]*' 41grep_log recvmsg '\(0<socket:\[[0-9]+\]>, \{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"\\x00\\x00\\x00\\x00[^"]*", [1-9][0-9]*\}\], msg_controllen=[1-9][0-9]*, \{cmsg_len=[1-9][0-9]*, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \{3</dev/null>\}\}, msg_flags=0\}, 0\) += [1-9][0-9]*' 42 43exit 0 44