mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
fixes for bugs 177039 1980891 198359
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
#
|
||||
@@ -12,172 +12,138 @@
|
||||
|
||||
################################################################################
|
||||
# ag_sd_config
|
||||
#
|
||||
# Version 0.51
|
||||
################################################################################
|
||||
|
||||
use Immunix::Ycp;
|
||||
use Immunix::Reports;
|
||||
use strict;
|
||||
use ycp;
|
||||
use Immunix::Notify;
|
||||
use Immunix::Reports;
|
||||
use Data::Dumper;
|
||||
use POSIX;
|
||||
use Locale::gettext;
|
||||
|
||||
setlocale(LC_MESSAGES, "");
|
||||
textdomain("apparmor-utils");
|
||||
|
||||
# Subroutines
|
||||
################################################################################
|
||||
|
||||
sub setSubdomain {
|
||||
|
||||
my $action = shift;
|
||||
my $action = shift;
|
||||
my $errmsg = "";
|
||||
my $lines = 0;
|
||||
if ($action eq "enable") {
|
||||
if (-e "/sbin/rcapparmor") {
|
||||
if ($action eq "enable") {
|
||||
if (-e "/sbin/rcapparmor") {
|
||||
open(RUN, "/sbin/rcapparmor start 2>&1 |");
|
||||
} else {
|
||||
} else {
|
||||
open(RUN, "/sbin/rcsubdomain start 2>&1 |");
|
||||
}
|
||||
}
|
||||
while (<RUN>) {
|
||||
if (/FATAL:(.*)/) {
|
||||
$errmsg = $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(RUN);
|
||||
if (-f "/etc/init.d/boot.apparmor") {
|
||||
if (-f "/etc/init.d/boot.apparmor") {
|
||||
system("/sbin/insserv boot.apparmor");
|
||||
} else {
|
||||
} else {
|
||||
system("/sbin/insserv boot.subdomain");
|
||||
}
|
||||
if (-f "/etc/init.d/aaeventd") {
|
||||
}
|
||||
if (-f "/etc/init.d/aaeventd") {
|
||||
system("/sbin/rcaaeventd start");
|
||||
system("/sbin/insserv aaeventd");
|
||||
}
|
||||
} else {
|
||||
if (-e "/sbin/rcapparmor") {
|
||||
}
|
||||
} else {
|
||||
if (-e "/sbin/rcapparmor") {
|
||||
open(RUN, "/sbin/rcapparmor stop 2>&1 |");
|
||||
} else {
|
||||
} else {
|
||||
open(RUN, "/sbin/rcsubdomain stop 2>&1 |");
|
||||
}
|
||||
}
|
||||
while (<RUN>) {
|
||||
if (/FATAL:(.*)/) {
|
||||
$errmsg = $1;
|
||||
}
|
||||
}
|
||||
close(RUN);
|
||||
if (-f "/etc/init.d/boot.apparmor") {
|
||||
if (-f "/etc/init.d/boot.apparmor") {
|
||||
system("/sbin/insserv -r boot.apparmor");
|
||||
} else {
|
||||
} else {
|
||||
system("/sbin/insserv -r boot.subdomain");
|
||||
}
|
||||
if (-f "/etc/init.d/aaeventd") {
|
||||
}
|
||||
if (-f "/etc/init.d/aaeventd") {
|
||||
system("/sbin/rcaaeventd stop");
|
||||
system("/sbin/insserv -e aaeventd");
|
||||
}
|
||||
}
|
||||
return $errmsg;
|
||||
}
|
||||
}
|
||||
return $errmsg;
|
||||
}
|
||||
|
||||
sub setNotify {
|
||||
|
||||
my $action = shift;
|
||||
my $action = shift;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub setLearningMode {
|
||||
|
||||
my $action = shift;
|
||||
my $rcscript = -f "/sbin/rcapparmor" ? "/sbin/rcapparmor"
|
||||
: "/sbin/rcsubdomain";
|
||||
my $action = shift;
|
||||
my $rcscript = -f "/sbin/rcapparmor" ? "/sbin/rcapparmor"
|
||||
: "/sbin/rcsubdomain";
|
||||
|
||||
if ($action eq "enable") {
|
||||
system("$rcscript", "stop");
|
||||
system("$rcscript", "complain");
|
||||
} else {
|
||||
system("$rcscript". "stop");
|
||||
system("$rcscript", "start");
|
||||
}
|
||||
if ($action eq "enable") {
|
||||
system("$rcscript", "stop");
|
||||
system("$rcscript", "complain");
|
||||
} else {
|
||||
system("$rcscript". "stop");
|
||||
system("$rcscript", "start");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub setNotifySettings {
|
||||
my $config = shift;
|
||||
|
||||
Immunix::Reports::enableEventD();
|
||||
open(CFG, "> /etc/apparmor/notify.cfg") or die "can't write config info: $!";
|
||||
if($config->{enable_terse} eq "yes") {
|
||||
# if we didn't get passed a valid frequency, default to off
|
||||
$config->{terse_freq} ||= 0;
|
||||
$config->{terse_level} ||= 0;
|
||||
# default to including unknown events if we didn't get passed that setting
|
||||
$config->{terse_unknown} = 1 unless defined $config->{terse_unknown};
|
||||
print CFG "terse_freq $config->{terse_freq}\n";
|
||||
print CFG "terse_email $config->{terse_email}\n";
|
||||
print CFG "terse_level $config->{terse_level}\n";
|
||||
print CFG "terse_unknown $config->{terse_unknown}\n";
|
||||
}
|
||||
if($config->{enable_summary} eq "yes") {
|
||||
# if we didn't get passed a valid frequency, default to off
|
||||
$config->{summary_freq} ||= 0;
|
||||
$config->{summary_level} ||= 0;
|
||||
# default to including unknown events if we didn't get passed that setting
|
||||
$config->{summary_unknown} = 1 unless defined $config->{summary_unknown};
|
||||
print CFG "summary_freq $config->{summary_freq}\n";
|
||||
print CFG "summary_email $config->{summary_email}\n";
|
||||
print CFG "summary_level $config->{summary_level}\n";
|
||||
print CFG "summary_unknown $config->{summary_unknown}\n";
|
||||
}
|
||||
if($config->{enable_verbose} eq "yes") {
|
||||
# if we didn't get passed a valid frequency, default to off
|
||||
$config->{verbose_freq} ||= 0;
|
||||
$config->{verbose_level} ||= 0;
|
||||
# default to including unknown events if we didn't get passed that setting
|
||||
$config->{verbose_unknown} = 1 unless defined $config->{verbose_unknown};
|
||||
print CFG "verbose_freq $config->{verbose_freq}\n";
|
||||
print CFG "verbose_email $config->{verbose_email}\n";
|
||||
print CFG "verbose_level $config->{verbose_level}\n";
|
||||
print CFG "verbose_unknown $config->{verbose_unknown}\n";
|
||||
}
|
||||
close(CFG);
|
||||
}
|
||||
|
||||
# Main
|
||||
################################################################################
|
||||
|
||||
|
||||
while ( <STDIN> ) {
|
||||
|
||||
my ($command, $path, $argument) = Immunix::Ycp::ParseCommand ($_);
|
||||
Immunix::Ycp::y2debug ("command: $command, path: $path");
|
||||
my ($command, $path, $argument) = ycp::ParseCommand ($_);
|
||||
|
||||
my $result = undef;
|
||||
my $action = undef;
|
||||
my $result = undef;
|
||||
my $action = undef;
|
||||
|
||||
if ( $command && $path && $argument ) {
|
||||
if ( $command && $path && $argument ) {
|
||||
|
||||
if(ref($argument) eq "HASH" && $argument->{"sd-set-notify"}) {
|
||||
setNotifySettings($argument);
|
||||
Immunix::Ycp::Return("true");
|
||||
next;
|
||||
}
|
||||
if (ref($argument) eq "HASH" && $argument->{"set_notify"}) {
|
||||
my ($ntSettings, $result) = Immunix::Notify::sanitize($argument);
|
||||
|
||||
($action) = (split(/:/, $argument))[1];
|
||||
if ($result ne "success") {
|
||||
ycp::Return($result);
|
||||
next;
|
||||
} else {
|
||||
$result = Immunix::Notify::setNotifySettings($ntSettings);
|
||||
ycp::Return($result);
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
Immunix::Ycp::y2milestone ("ag_sd_config=> Arg: $argument, Action: $action");
|
||||
($action) = (split(/:/, $argument))[1];
|
||||
|
||||
if ( $argument =~ /subdomain/ ) {
|
||||
$result = setSubdomain($action);
|
||||
} elsif ( $argument =~ /learning/ ) {
|
||||
setLearningMode($action);
|
||||
} elsif ( $argument eq 'sd-notify') {
|
||||
setNotify($action);
|
||||
}
|
||||
Immunix::Ycp::y2milestone ("ag_sd_config=> DONE Arg: $argument, Action: $action");
|
||||
if ( $result ) {
|
||||
Immunix::Ycp::Return( $result );
|
||||
} else {
|
||||
Immunix::Ycp::Return("true");
|
||||
}
|
||||
}
|
||||
if ( $argument =~ /subdomain/ ) {
|
||||
$result = setSubdomain($action);
|
||||
} elsif ( $argument =~ /learning/ ) {
|
||||
setLearningMode($action);
|
||||
} elsif ( $argument eq 'sd-notify') {
|
||||
setNotify($action);
|
||||
}
|
||||
|
||||
if ( $result ) {
|
||||
ycp::Return( $result );
|
||||
} else {
|
||||
ycp::Return("true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
@@ -18,9 +18,16 @@
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use Immunix::Ycp;
|
||||
use ycp;
|
||||
use Immunix::Notify;
|
||||
use Immunix::SubDomain;
|
||||
use Data::Dumper;
|
||||
#use POSIX;
|
||||
#use Locale::gettext;
|
||||
|
||||
#setlocale(LC_MESSAGES, "");
|
||||
#textdomain("apparmor-utils");
|
||||
|
||||
|
||||
# Subroutines
|
||||
################################################################################
|
||||
@@ -47,38 +54,6 @@ sub getSubdomainStatus {
|
||||
return $sdStatus;
|
||||
}
|
||||
|
||||
sub getNotifySettings {
|
||||
|
||||
my $config = { };
|
||||
if(open(CFG, "/etc/apparmor/notify.cfg")) {
|
||||
while(<CFG>) {
|
||||
chomp;
|
||||
$config->{$1} = $2 if /^(\S+)\s+(.+)\s*$/;
|
||||
}
|
||||
close(CFG);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
sub getNotifyStatus {
|
||||
|
||||
my $config = getNotifySettings();
|
||||
|
||||
my $noteStatus = "disabled";
|
||||
|
||||
if($config->{terse_freq} && $config->{terse_freq} != 0) {
|
||||
$noteStatus = "enabled";
|
||||
} elsif($config->{summary_freq} && $config->{summary_freq} != 0) {
|
||||
$noteStatus = "enabled";
|
||||
} elsif($config->{verbose_freq} && $config->{verbose_freq} != 0) {
|
||||
$noteStatus = "enabled";
|
||||
}
|
||||
|
||||
return $noteStatus;
|
||||
}
|
||||
|
||||
sub profileSyntaxCheck {
|
||||
my $errlist = [];
|
||||
Immunix::SubDomain::checkIncludeSyntax($errlist);
|
||||
@@ -91,10 +66,8 @@ sub profileSyntaxCheck {
|
||||
# Main
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
while ( <STDIN> ) {
|
||||
my ($command, $path, $argument) = Immunix::Ycp::ParseCommand($_);
|
||||
my ($command, $path, $argument) = ycp::ParseCommand($_);
|
||||
|
||||
my $result = undef;
|
||||
my $donereturn = 0;
|
||||
@@ -102,32 +75,33 @@ while ( <STDIN> ) {
|
||||
if ( $argument eq 'sd-all') {
|
||||
my %hResult = ''; # hashed result, duh
|
||||
$hResult{'sd-status'} = getSubdomainStatus();
|
||||
$hResult{'sd-notify'} = getNotifyStatus();
|
||||
Immunix::Ycp::ycpReturnHashAsMap( %hResult );
|
||||
$hResult{'sd-notify'} = Immunix::Notify::getNotifyStatus();
|
||||
#ycp::ycpReturnHashAsMap( %hResult );
|
||||
ycp::Return( %hResult );
|
||||
$donereturn = 1;
|
||||
} elsif ( $argument eq 'sd-status') {
|
||||
$result = getSubdomainStatus();
|
||||
} elsif ( $argument eq 'sd-notify') {
|
||||
$result = getNotifyStatus();
|
||||
$result = Immunix::Notify::getNotifyStatus();
|
||||
} elsif ( $command eq "Read" and $argument eq 'custom-includes') {
|
||||
Immunix::SubDomain::readconfig();
|
||||
Immunix::Ycp::ycpReturn(\@Immunix::SubDomain::custom_includes);
|
||||
ycp::ycpReturn(\@Immunix::SubDomain::custom_includes);
|
||||
$donereturn = 1;
|
||||
} elsif ( $command eq "Execute" and $argument eq 'profile-syntax-check') {
|
||||
$result = profileSyntaxCheck();
|
||||
Immunix::Ycp::ycpReturn($result);
|
||||
ycp::ycpReturn($result);
|
||||
$donereturn = 1;
|
||||
} elsif ( $argument eq 'sd-notify-settings') {
|
||||
$result = getNotifySettings();
|
||||
Immunix::Ycp::ycpReturn($result);
|
||||
$result = Immunix::Notify::getNotifySettings();
|
||||
ycp::Return($result);
|
||||
$donereturn = 1;
|
||||
}
|
||||
Immunix::Ycp::ycpReturnSkalarAsString( $result ) if ( ! $donereturn );
|
||||
ycp::ycpReturnSkalarAsString( $result ) if ( ! $donereturn );
|
||||
} else {
|
||||
my $ycpCmd = ycpGetCommand() || "";
|
||||
my $ycpArg = ycpGetArgType() || "";
|
||||
$result = "Unknown instruction $ycpCmd or argument: $ycpArg\n";
|
||||
Immunix::Ycp::ycpReturnSkalarAsString( $result );
|
||||
ycp::ycpReturnSkalarAsString( $result );
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user