2
# ----------------------------------------------------------------------
3
# Copyright (c) 2005 Novell, Inc. All Rights Reserved.
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of version 2 of the GNU General Public
7
# License as published by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, contact Novell, Inc.
17
# To contact Novell about this file by physical or electronic mail,
18
# you may find current contact information at www.novell.com.
19
# ----------------------------------------------------------------------
25
use Immunix::AppArmor;
32
# initialize the local poo
33
setlocale(LC_MESSAGES, "");
34
textdomain("apparmor-utils");
42
'dir|d=s' => \$profiledir,
46
# tell 'em how to use it...
47
&usage && exit if $help;
49
# let's convert it to full path...
50
$profiledir = get_full_path($profiledir);
52
unless (-d $profiledir) {
53
UI_Important("Can't find AppArmor profiles in $profiledir.");
57
# what are we profiling?
58
my @profiling = @ARGV;
61
@profiling = (UI_GetString("Please enter the program to switch to audit mode: ", ""));
64
for my $profiling (@profiling) {
66
next unless $profiling;
70
$fqdbin = get_full_path($profiling);
73
if ($profiling !~ /\//) {
74
opendir(DIR,$profiledir);
75
my @tmp_fqdbin = grep ( /$profiling/, readdir(DIR));
77
if (scalar @tmp_fqdbin eq 1) {
78
$fqdbin = "$profiledir/$tmp_fqdbin[0]";
80
my $which = which($profiling);
82
$fqdbin = get_full_path($which);
91
if ($fqdbin =~ /^$profiledir\//) {
94
$filename = getprofilefilename($fqdbin);
97
# argh, skip directories
98
next unless -f $filename;
100
# skip rpm backup files
101
next if isSkippableFile($filename);
103
printf(gettext('Setting %s to audit mode.'), $fqdbin);
105
setprofileflags($filename, "audit");
107
my $cmd_info = qx(cat $filename | $parser -I$profiledir -r 2>&1 1>/dev/null);
113
# if check_for_subdomain();
115
if ($profiling =~ /^[^\/]+$/) {
116
UI_Info(sprintf(gettext('Can\'t find %s in the system path list. If the name of the application is correct, please run \'which %s\' as a user with the correct PATH environment set up in order to find the fully-qualified path.'), $profiling, $profiling));
119
UI_Info(sprintf(gettext('%s does not exist, please double-check the path.') . $profiling));
128
UI_Info(sprintf(gettext("usage: \%s [ -d /path/to/profiles ] [ program to switch to audit mode ]"), $0));