[yast-commit] r49538 - in /trunk/auditd/src: Auditd.ycp complex.ycp dialogs.ycp
Author: gs Date: Thu Jul 31 11:27:34 2008 New Revision: 49538 URL: http://svn.opensuse.org/viewcvs/yast?rev=49538&view=rev Log: read/write audit.rules Modified: trunk/auditd/src/Auditd.ycp trunk/auditd/src/complex.ycp trunk/auditd/src/dialogs.ycp Modified: trunk/auditd/src/Auditd.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/Auditd.ycp?rev=49538&r1=49537&r2=49538&view=diff ============================================================================== --- trunk/auditd/src/Auditd.ycp (original) +++ trunk/auditd/src/Auditd.ycp Thu Jul 31 11:27:34 2008 @@ -24,7 +24,6 @@ * Summary: Auditd settings, input and output functions * Authors: Gabriele Mohr <gs@suse.de> * - * $Id: Auditd.ycp 41350 2007-10-10 16:59:00Z dfiser $ * * Representation of the configuration of auditd. * Input and output routines. @@ -59,12 +58,33 @@ boolean proposal_valid = false; /** + * Filename (path) rules file + */ +string rules_file = "/etc/audit/audit.rules"; + +/** + * Filename (path) config file + */ +string config_file = "/etc/audit/auditd.conf"; + +/** * Write only, used during autoinstallation. * Don't run services and SuSEconfig, it's all done at one place. */ boolean write_only = false; /** + * Return rules file path + */ +global string GetRulesFile() { + return rules_file; +} + +global string GetConfigFile() { + return config_file; +} + +/** * Data was modified? * @return true if modified */ @@ -127,16 +147,16 @@ } // -// Settings: Define all variables needed for configuration of laf-audit +// Settings: Define all variables needed for configuration of auditd // /** - * map of audit settings + * map of audit settings (from /etc/audit/auditd.conf) */ map <string, list <string> > SETTINGS = $[]; /** - * map of auditd settings (from /etc/auditd.conf) + * default settings for /etc/audit/auditd.conf */ map <string, list <string> > DEFAULT_CONFIG = $[ "log_file" : ["/var/log/audit/audit.log"], @@ -158,6 +178,14 @@ "disk_error_action" : ["SUSPEND"] ]; +/** + * Rules for auditd (passed via auditctl) read from /etc/audit/audit.rules + */ +string RULES = ""; + +/** + * Get value of given option from SEETINGS + */ global string GetAuditdOption( string key) { list <string> option_list = SETTINGS[key]:DEFAULT_CONFIG[key]:[]; @@ -167,6 +195,10 @@ return ""; } +/** + * Set option to given value in SETTINGS + */ + global boolean SetAuditdOption( string key, string value ) { list <string> option_list = []; @@ -180,14 +212,59 @@ else return false; } - + +/** + * Get all rules + */ +global string GetRules() { + return RULES; +} + +/* + * Set rules + */ +global boolean SetRules( string rules ) { + if ( rules != nil && rules != "" ) + { + RULES = rules; + return true; + } + else + return false; +} + +/** + * Read rules from audit.rules + */ +boolean ReadAuditdRules() { + + string rules = (string)SCR::Read(.target.string, rules_file ); + + if ( rules != nil && rules != "" ) + { + RULES = rules; + return true; + } + else + return false; +} + +/** + * Write rules to audit.rules + */ +boolean WriteAuditdRules() { + boolean success = (boolean)SCR::Write(.target.string, rules_file, RULES ); + return success; +} + + /** * Read settings from auditd.conf * @return true on success */ boolean ReadAuditdSettings() { - if ( ! FileUtils::Exists ("/etc/audit/auditd.conf") ) + if ( ! FileUtils::Exists ( config_file) ) return false; list <string> optionsList = (list <string>) SCR::Dir(.auditd); @@ -201,7 +278,7 @@ if (val != nil) SETTINGS[key] = val; }); - y2milestone("/etc/audit/auditd.conf has been read: %1", SETTINGS); + y2milestone("%1 has been read: %2", config_file, SETTINGS); return true; } @@ -210,7 +287,8 @@ * @return true on success */ global boolean Read() { - + boolean success = true; + /* Auditd read dialog caption */ string caption = _("Initializing auditd Configuration"); @@ -241,17 +319,20 @@ if(PollAbort()) return false; Progress::NextStage(); - boolean success = ReadAuditdSettings(); + success = ReadAuditdSettings(); // Report error - if( !success) Report::Error(_("Cannot read database1.")); + if( !success) Report::Error(_("Cannot read auditd.conf.")); sleep(sl); // read another database if(PollAbort()) return false; Progress::NextStep(); + + success = ReadAuditdRules(); + /* Error message */ - if(false) Report::Error(_("Cannot read database2.")); + if(!success) Report::Error(_("Cannot read audit.rules.")); sleep(sl); // read current settings @@ -273,7 +354,7 @@ boolean WriteAuditdSettings() { boolean success = true; - if ( ! FileUtils::Exists ("/etc/audit/auditd.conf") ) + if ( ! FileUtils::Exists ( config_file ) ) return false; // list all options set in auditd.conf @@ -285,7 +366,7 @@ // This is very important // it flushes the cache, and stores the configuration on the disk SCR::Write(.etc.ssh.sshd_config, nil); - y2milestone("/etc/audit/auditd.conf has been written: %1", SETTINGS); + y2milestone("%1 has been written: %2", config_file, SETTINGS); return true; } @@ -295,7 +376,8 @@ * @return true on success */ global boolean Write() { - + boolean success = true; + /* Auditd read dialog caption */ string caption = _("Saving auditd Configuration"); @@ -311,12 +393,12 @@ /* Progress stage 1/2 */ _("Write the settings"), /* Progress stage 2/2 */ - _("Run SuSEconfig") + _("Write the rules") ], [ /* Progress step 1/2 */ _("Writing the settings..."), /* Progress step 2/2 */ - _("Running SuSEconfig..."), + _("Writing the rules..."), Message::Finished() ], "" @@ -326,16 +408,17 @@ if(PollAbort()) return false; Progress::NextStage(); - boolean success = WriteAuditdSettings(); + success = WriteAuditdSettings(); /* Error message */ - if(!success) Report::Error (_("Cannot write settings.")); + if(!success) Report::Error (_("Cannot write settings to auditd.conf.") ); sleep(sl); // run SuSEconfig if(PollAbort()) return false; Progress::NextStage (); + success = WriteAuditdRules(); /* Error message */ - if(false) Report::Error (Message::SuSEConfigFailed()); + if(!success) Report::Error (_("Cannot write settings to auditd.rules.") ); sleep(sl); if(PollAbort()) return false; Modified: trunk/auditd/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/complex.ycp?rev=49538&r1=49537&r2=49538&view=diff ============================================================================== --- trunk/auditd/src/complex.ycp (original) +++ trunk/auditd/src/complex.ycp Thu Jul 31 11:27:34 2008 @@ -186,10 +186,28 @@ } void InitRulesDialog( string id ) { + + list<string> rules_list = []; + string rules = Auditd::GetRules(); + + if ( rules != nil && rules != "") + { + rules_list = splitstring( rules, "\n"); + } + + y2milestone( "RULES read from %1: %2", Auditd::GetRulesFile(), rules_list ); + + UI::ChangeWidget( `id( "rules"), `Value, rules ); + y2milestone ( "Init rules dialog" ); } void StoreRulesDialog( string id, map event) { + string rules = (string)UI::QueryWidget( `id("rules"), `Value ); + + Auditd::SetRules( rules ); + + y2debug( "RULES: %1", rules ); y2milestone( "Store rules dialog" ); } Modified: trunk/auditd/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/dialogs.ycp?rev=49538&r1=49537&r2=49538&view=diff ============================================================================== --- trunk/auditd/src/dialogs.ycp (original) +++ trunk/auditd/src/dialogs.ycp Thu Jul 31 11:27:34 2008 @@ -181,13 +181,14 @@ } term RulesDialogContent() { + return `MarginBox( mbox_x, mbox_y, `VBox( `VSpacing(1.0), `VBox( `Left(`Label(_("Edit rules for audit daemon here"))), `VSpacing(1.0), - `MultiLineEdit(`id(`rules), ("/etc/audit/audit.rules")) + `MultiLineEdit(`id("rules"), Auditd::GetRulesFile() ) ), `VStretch() ) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn.opensuse.org