Author: gs Date: Tue Aug 5 17:41:24 2008 New Revision: 49731 URL: http://svn.opensuse.org/viewcvs/yast?rev=49731&view=rev Log: add possibility to configure enable/disable to rules dialog Modified: trunk/auditd/src/Auditd.ycp trunk/auditd/src/complex.ycp trunk/auditd/src/dialogs.ycp trunk/auditd/src/wizards.ycp Modified: trunk/auditd/src/Auditd.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/Auditd.ycp?rev=49731&r1=49730&r2=49731&view=diff ============================================================================== --- trunk/auditd/src/Auditd.ycp (original) +++ trunk/auditd/src/Auditd.ycp Tue Aug 5 17:41:24 2008 @@ -84,6 +84,11 @@ return config_file; } +global list <string> GetWatches() { + return ( [ "exit,always watch=/etc/passwd perm=rwx", + "entry,always watch=/etc/sysconfig/yast2 perm=rwx"] ); +} + /** * Data was modified? * @return true if modified Modified: trunk/auditd/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/complex.ycp?rev=49731&r1=49730&r2=49731&view=diff ============================================================================== --- trunk/auditd/src/complex.ycp (original) +++ trunk/auditd/src/complex.ycp Tue Aug 5 17:41:24 2008 @@ -187,19 +187,67 @@ void InitRulesDialog( string id ) { - list<string> rules_list = []; - string rules = Auditd::GetRules(); + UI::ChangeWidget( `id( "rules"), `Value, Auditd::GetRules() ); + + y2milestone ( "Init rules dialog" ); +} - if ( rules != nil && rules != "") +symbol HandleRulesDialog(string id, map event) { + any action = event["ID"]:nil; + + if ( action == "audit_enabled" ) { - rules_list = splitstring( rules, "\n"); + string value = (string)UI::QueryWidget( `id("audit_enabled"), `Value ); + string rule = ""; + string rules = Auditd::GetRules(); + list <string> rules_list = []; + + y2milestone( "Setting status to: %1", value ); + + switch ( value ) + { + case "lock": { + rule = "-e 2"; + break; + } + case "enable": { + rule = "-e 1"; + break; + } + case "disable": { + rule = "-e 0"; + break; + } + } + + if ( rules != nil && rules != "") + { + rules_list = splitstring( rules, "\n"); + } + + boolean rule_found = false; + + if ( rules_list != [] ) + { + list<string> new_rules = maplist( string line, rules_list, { + if ( regexpmatch( line, "^[ /t]*-e" ) ) + { + rule_found = true; + return rule; + } + else + { + return line; + } + }); + if ( !rule_found ) + new_rules = add( new_rules, rule ); + + UI::ChangeWidget(`id("rules"), `Value, mergestring( new_rules, "\n" ) ); + } } - y2milestone( "RULES read from %1: %2", Auditd::GetRulesFile(), rules_list ); - - UI::ChangeWidget( `id( "rules"), `Value, rules ); - - y2milestone ( "Init rules dialog" ); + return nil; } void StoreRulesDialog( string id, map event) { Modified: trunk/auditd/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/dialogs.ycp?rev=49731&r1=49730&r2=49731&view=diff ============================================================================== --- trunk/auditd/src/dialogs.ycp (original) +++ trunk/auditd/src/dialogs.ycp Tue Aug 5 17:41:24 2008 @@ -184,12 +184,21 @@ 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"), Auditd::GetRulesFile() ) - ), + `VWeight( 20, `Frame( _("" ), + `VBox( + `Left(`ComboBox( `id("audit_enabled"), `opt(`notify), _("Configure Enabled Flag"), + [`item(`id("enable"), _("Enable Auditing"), true ), // -e 1 + `item(`id("disable"), _("Disable Auditing") ) // -e 0 + ] + )), + `VStretch() + ) + ) ) , + `VWeight( 80, `VBox( + `Left(`Label(_("Current rules for audit daemon:") ) ), + `MultiLineEdit(`id("rules"), Auditd::GetRulesFile() ) + ) + ), `VStretch() ) ); Modified: trunk/auditd/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/wizards.ycp?rev=49731&r1=49730&r2=49731&view=diff ============================================================================== --- trunk/auditd/src/wizards.ycp (original) +++ trunk/auditd/src/wizards.ycp Tue Aug 5 17:41:24 2008 @@ -73,6 +73,7 @@ "widget" : `custom, "help" : HELPS["auditd_rules"]:"", "custom_widget" : RulesDialogContent(), + "handle" : HandleRulesDialog, "init" : InitRulesDialog, "store" : StoreRulesDialog, ], -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org