1f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin#!/bin/sh
2f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
3f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin# Check how SCM_RIGHTS control messages are decoded in -y mode.
4f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
5f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin. "${srcdir=.}/init.sh"
6f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
7f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin# strace -y is implemented using /proc/$pid/fd
8f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin[ -d /proc/self/fd/ ] ||
9f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	framework_skip_ '/proc/self/fd/ is not available'
10f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
11f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levincheck_prog grep
12f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levincheck_prog rm
13f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
14f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levinrm -f $LOG.*
15f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
16f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin./scm_rights ||
17f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	fail_ 'scm_rights failed'
18f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
19f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levinargs="-tt -ff -y -xx -enetwork -o $LOG ./scm_rights"
20f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin$STRACE $args ||
21f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	fail_ "$STRACE $args failed"
22f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
23f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin"$srcdir"/../strace-log-merge $LOG > $LOG || {
24f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	cat $LOG
25f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	fail_ 'strace-log-merge failed'
26f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin}
27f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levinrm -f $LOG.*
28f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
29f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levingrep_log()
30f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin{
31f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	local syscall="$1"; shift
32f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +'
33f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
34f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	LC_ALL=C grep -E -x "$prefix$syscall$*" $LOG > /dev/null || {
35f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin		cat $LOG
36f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin		fail_ "$STRACE $args failed to trace \"$syscall\" properly"
37f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin	}
38f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin}
39f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
40e25fb4fd8eb2ec0962cfac614e85762d7f9dbd38Dmitry V. Levingrep_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]*'
41e25fb4fd8eb2ec0962cfac614e85762d7f9dbd38Dmitry V. Levingrep_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]*'
42f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levin
43f23b097fc5fdc031dc795c10876d97f31b2826d8Dmitry V. Levinexit 0
44