<p>This is very useful when debugging SELinux issues, in particular when a process runs in an unexpected context or didn't transition properly, or typically when a file being opened has not the proper context.</p>
<p>Sub-option <code>--typeonly</code> may be used to only print the type, as shown in the examples below:</p>
<p>Without any option (standard strace, here used <code>-fttTvyy</code> flags):</p>
<pre><code>118104  16:52:11.141122 select(9, [4<TCP:[0.0.0.0:22]> 6<TCPv6:[[::]:22]>], NULL, NULL, NULL) = 1 (in [4]) <1.845416>
119820  16:52:13.133319 openat(AT_FDCWD, "/home/rmetrich/.ssh/authorized_keys", O_RDONLY|O_NONBLOCK) = 11</home/rmetrich/.ssh/authorized_keys> <0.000399>
</code></pre>
<p>With <code>--secontext</code> option, a new column is added after PID, showing the context the PID is executing and each PATH has its context associated (when file exists) :</p>
<pre><code>118104 [system_u:system_r:sshd_t:s0-s0:c0.c1023] 16:52:11.141122 select(9, [4<TCP:[0.0.0.0:22]> 6<TCPv6:[[::]:22]>], NULL, NULL, NULL) = 1 (in [4]) <1.845416>
119820 [system_u:system_r:sshd_t:s0-s0:c0.c1023] 16:52:13.133319 openat(AT_FDCWD, "/home/rmetrich/.ssh/authorized_keys" [system_u:object_r:nfs_t:s0], O_RDONLY|O_NONBLOCK) = 11</home/rmetrich/.ssh/authorized_keys> [system_u:object_r:nfs_t:s0] <0.000399>
</code></pre>
<p>With <code>--typeonly</code> sub-option, same except only the type is displayed:</p>
<pre><code>118104 [sshd_t] 16:52:11.141122 select(9, [4<TCP:[0.0.0.0:22]> 6<TCPv6:[[::]:22]>], NULL, NULL, NULL) = 1 (in [4]) <1.845416>
119820 [sshd_t] 16:52:13.133319 openat(AT_FDCWD, "/home/rmetrich/.ssh/authorized_keys" [nfs_t], O_RDONLY|O_NONBLOCK) = 11</home/rmetrich/.ssh/authorized_keys> [nfs_t] <0.000399>
</code></pre>
<p>This only requires binding strace to libdl at compilation time.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/strace/strace/pull/121'>https://github.com/strace/strace/pull/121</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Print SELinux contexts when enabling "--secontext" (not compatible with</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/121/files#diff-0">Makefile.am</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/121/files#diff-1">defs.h</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/121/files#diff-2">strace.c</a>
    (122)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/121/files#diff-3">util.c</a>
    (12)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/strace/strace/pull/121.patch'>https://github.com/strace/strace/pull/121.patch</a></li>
  <li><a href='https://github.com/strace/strace/pull/121.diff'>https://github.com/strace/strace/pull/121.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/strace/strace/pull/121?email_source=notifications&email_token=AAFX7DCVF5ES5XHRA7HLAXDRAK65FA5CNFSM4KNUZHZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJ2AKPA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAFX7DG54ZQMXQZD25RJX63RAK65FANCNFSM4KNUZHZA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAFX7DD62K5F5HHUWPGW2VDRAK65FA5CNFSM4KNUZHZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJ2AKPA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/strace/strace/pull/121?email_source=notifications\u0026email_token=AAFX7DCVF5ES5XHRA7HLAXDRAK65FA5CNFSM4KNUZHZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJ2AKPA",
"url": "https://github.com/strace/strace/pull/121?email_source=notifications\u0026email_token=AAFX7DCVF5ES5XHRA7HLAXDRAK65FA5CNFSM4KNUZHZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJ2AKPA",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>