3
# ------------------------------------------------------------------
5
# Copyright (C) 2002-2005 Novell/SUSE
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of version 2 of the GNU General Public
9
# License published by the Free Software Foundation.
11
# ------------------------------------------------------------------
14
#####################################################################
16
# ag_subdomain_profiles - Immunix SCR agent for the
17
# management of SubDomain profiles
20
#####################################################################
25
use Immunix::SubDomain;
35
system("/usr/sbin/autodep $filename > /dev/null 2>&1");
36
system("/usr/sbin/enforce $filename > /dev/null 2>&1");
40
# ###############################################################################
42
# YCP <-> SCR Commands:
44
# Command Path Argument Returns
45
# ------- ---- -------- --------
47
# Read all hash containing all profiles
49
# Read .new pathtoprogram true/false (creates new profile)
51
# Write hash { true/false
55
# <hash containing the
59
# Write .delete pathtoprogram true/fale (deletes profile)
61
# Write .reload - true (reloads profiles)
64
################################################################################
69
my ($command, $path, $argument) = ycp::ParseCommand ($_);
70
$argument = "NONE" if ( ! $argument );
71
ycp::y2milestone ("DOM command: $command, path: $path, argument: $argument");
74
if ( $command && $path && $argument ) {
75
if ( $command eq "Read" and $argument eq "all") {
77
Immunix::SubDomain::readprofiles();
79
} elsif ( $command eq "Read" and $path eq ".new" ) {
80
my $pfname = getprofilefilename($argument);
84
newprofile( $argument );
85
ycp::Return( "true" );
87
} elsif ( $command eq "Read" ) {
88
my $pfname = getprofilefilename($argument);
91
Immunix::SubDomain::readprofiles();
92
ycp::Return( $sd{$argument} );
94
ycp::Return( "false" );
96
} elsif ( $command eq "Read") {
98
Immunix::SubDomain::readprofile("$profiledir/$argument",
99
\&$Immunix::SubDomain::fatal_error, 1);
101
} elsif ( $command eq "Write" and $path eq ".delete") {
102
if ( $argument ne "" ) {
103
my $profilefile = getprofilefilename( $argument );
104
if ( -e $profilefile ) {
105
unlink( $profilefile );
107
ycp::Return( "true" );
109
ycp::Return( "false" );
111
} elsif ( $command eq "Write" and $path eq ".reload") {
112
$result = system("/sbin/rcsubdomain reload > /dev/null 2>&1");
113
ycp::Return( "true" );
114
} elsif ( $command eq "Write") {
115
if ( (ref($argument) eq "HASH") ) {
116
my $profilename = "";
117
$profilename = $$argument{"PROFILE_NAME"};
118
my $ref = $$argument{"PROFILE_HASH"};
120
$profiles{$profilename} = $ref;
121
if ( (ref($ref) eq "HASH") ) {
124
$result = Immunix::SubDomain::writeprofile($profilename);
126
ycp::Return( "false" );
128
ycp::Return( "true" );
133
my $ycpCmd = ycpGetCommand() || "";
134
my $ycpArg = ycpGetArgType() || "";
135
$result = "Unknown instruction $ycpCmd or argument: $ycpArg\n";
136
ycp::Return( $result );