[Bug 178396] [kernel] [patch] Add jid to kernel log when a process has been forced closed

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Jan 6 00:42:38 UTC 2016


thomas at gibfest.dk changed:

           What    |Removed                     |Added
                 CC|                            |thomas at gibfest.dk

--- Comment #3 from thomas at gibfest.dk ---
Created attachment 165129
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=165129&action=edit
updated patch against stable/10 r293209

The original attachment in this bug no longer works since it doesn't use the
newish jailed() to check if the process is jailed. 

The attachment I'm adding is a patch against stable/10 base r293209 which fixes
the jailed detection, and also adds jail hostname to the log entry (when a jail
hostname is available).

For this patch to work on HEAD the exit1() call needs to be changed, no other
changes needed I think.

This patch could be a few lines shorter by only having one log() call, which
includes a empty string for nonjailed processes and something like ", jid: xxx
(example.com)" for jailed processes. The current is arguably more readable

Testing with this patch applied:

[tykling at test /usr/src]$ sudo jail -c path=/ command=/bin/sh
# perl -e 'dump'
Abort trap (core dumped)
# ^Djail: /bin/sh: failed
[tykling at test /usr/src]$ sudo jail -c path=/ host.hostname=example.com
# perl -e 'dump'
Abort trap (core dumped)
# ^Djail: /bin/sh: failed
[tykling at test /usr/src]$ perl -e 'dump'
Abort trap
[tykling at test /usr/src]$ dmesg | tail -3
pid 847 (perl), uid 0, jid 3: exited on signal 6 (core dumped)
pid 853 (perl), uid 0, jid 4 (example.com): exited on signal 6 (core dumped)
pid 857 (perl), uid 1001: exited on signal 6
[tykling at test /usr/src]$

I am not good with C so please feel free to comment on style and other
problems. Thanks :)

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-bugs mailing list