3 # Check how SCM_RIGHTS and SCM_CREDENTIALS control messages are decoded in -y mode.
5 . "${srcdir=.}/init.sh"
7 # strace -y is implemented using /proc/$pid/fd
8 [ -d /proc/self/fd/ ] ||
9 framework_skip_ '/proc/self/fd/ is not available'
19 framework_skip_ 'failed to create a directory'
21 file="$dir/$(for i in $(seq 1 127); do echo A; done; echo Z)"
24 framework_skip_ 'failed to create a file'
26 run_prog ./scm_rights /dev/zero
27 run_strace_merge -y -x -enetwork $args "$file"
30 msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"\\x00\\x00\\x00\\x00[^"]*", '"$n"'\}\], msg_controllen='"$n"
31 rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \[3</dev/null>, 4</dev/zero>, 5</[^}>]*/(A\\n){127}Z>\]\}'
32 creds='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, \{pid='"$n"', uid=[0-9]+, gid=[0-9]+\}\}'
33 prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +'
34 EXPECTED="$LOG.expected"
36 cat > "$EXPECTED" << __EOF__
37 ${prefix}sendmsg\\(1<socket:\\[[0-9]+\\]>, $msg, \\[$rights\\], msg_flags=0\\}, 0\\) += $n
38 ${prefix}recvmsg\\(0<socket:\\[[0-9]+\\]>, $msg, \\[$creds, $rights\\], msg_flags=0\\}, 0\\) += $n
41 match_grep "$LOG" "$EXPECTED"