3
# $Id: unconfined 458 2007-03-20 22:58:38Z jmichael-at-suse-de $
5
# ----------------------------------------------------------------------
6
# Copyright (c) 2005 Novell, Inc. All Rights Reserved.
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of version 2 of the GNU General Public
10
# License as published by the Free Software Foundation.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, contact Novell, Inc.
20
# To contact Novell about this file by physical or electronic mail,
21
# you may find current contact information at www.novell.com.
22
# ----------------------------------------------------------------------
25
# audit local system for processes listening on network connections
26
# that are not currently running with a profile.
30
use Immunix::SubDomain;
34
setlocale(LC_MESSAGES, "");
35
textdomain("apparmor-utils");
42
'paranoid' => \$paranoid,
46
# tell 'em how to use it...
47
&usage && exit if $help;
50
printf(gettext("Usage: %s [ --paranoid ]\n"), $0);
54
my $subdomainfs = check_for_subdomain();
56
die gettext("SubDomain does not appear to be started. Please enable SubDomain and try again.") . "\n"
61
opendir(PROC, "/proc") or die gettext("Can't read /proc\n");
62
@pids = grep { /^\d+$/ } readdir(PROC);
65
if (open(NETSTAT, "/bin/netstat -nlp |")) {
69
if /^(tcp|udp)\s+\d+\s+\d+\s+\S+\:(\d+)\s+\S+\:(\*|\d+)\s+(LISTEN|\s+)\s+(\d+)\/(\S+)/;
75
for my $pid (sort { $a <=> $b } @pids) {
76
my $prog = readlink "/proc/$pid/exe" or next;
78
if (open(CURRENT, "/proc/$pid/attr/current")) {
81
$attr = $_ if (/^\// || /^null/);
86
if ($prog =~ m/^(\/usr\/bin\/python|\/usr\/bin\/perl|\/bin\/bash)$/) {
88
#my $scriptname = (split(/\0/, `cat /proc/$pid/cmdline`))[1];
89
my $cmdline = `cat /proc/$pid/cmdline`;
93
print "$pid $prog ($cmdline) " . gettext("not confined\n");
95
print "$pid $prog " . gettext("not confined\n");
98
if ($prog =~ m/^(\/usr\/bin\/python|\/usr\/bin\/perl|\/bin\/bash)$/) {
100
#my $scriptname = (split(/\0/, `cat /proc/$pid/cmdline`))[1];
101
my $cmdline = `cat /proc/$pid/cmdline`;
102
$cmdline =~ s/\0/ /g;
103
$cmdline =~ s/\s+$//;
105
print "$pid $prog ($cmdline) " . gettext("confined by") . " '$attr'\n";
107
print "$pid $prog " . gettext("confined by") . " '$attr'\n";