Author: gs Date: Wed Jun 24 11:13:07 2009 New Revision: 57715 URL: http://svn.opensuse.org/viewcvs/yast?rev=57715&view=rev Log: command line support added (functionality 'set' not yet complete) Added: trunk/audit-laf/src/cmdline.ycp Modified: trunk/audit-laf/src/Makefile.am trunk/audit-laf/src/audit-laf.ycp Modified: trunk/audit-laf/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/Makefile.am?rev=577... ============================================================================== --- trunk/audit-laf/src/Makefile.am (original) +++ trunk/audit-laf/src/Makefile.am Wed Jun 24 11:13:07 2009 @@ -11,7 +11,8 @@ helps.ycp \ wizards.ycp \ dialogs.ycp \ - complex.ycp + complex.ycp \ + cmdline.ycp desktop_DATA = \ audit-laf.desktop Modified: trunk/audit-laf/src/audit-laf.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/audit-laf.ycp?rev=5... ============================================================================== --- trunk/audit-laf/src/audit-laf.ycp (original) +++ trunk/audit-laf/src/audit-laf.ycp Wed Jun 24 11:13:07 2009 @@ -47,24 +47,52 @@ import "CommandLine"; include "audit-laf/wizards.ycp"; +include "audit-laf/cmdline.ycp"; -map cmdline_description = $[ - "id" : "audit-laf", - /* Command line help text for the Xaudit-laf module */ - "help" : _("Configuration of Linux Audit Framework (LAF)"), - "guihandler" : AuditLafSequence, - "initialize" : AuditLaf::Read, - "finish" : AuditLaf::Write, - "actions" : $[ - // FIXME TODO: fill the functionality description here - ], - "options" : $[ - // FIXME TODO: fill the option descriptions here - ], - "mappings" : $[ - // FIXME TODO: fill the mappings of actions and options here - ] -]; +map cmdline_description = + $[ + "id" : "audit-laf", + /* Command line help text for the audit-laf module */ + "help" : _("Configuration of Linux Audit Framework (LAF)"), + "guihandler": AuditLafSequence, + "initialize": AuditLaf::Read, + "finish" : AuditLaf::Write, + "actions" : $[ + "show" :$[ + "handler" : ShowHandler, + // translators: command line help text for show action + "help" : _("Show information about audit settings") + + ], + "set" :$[ + "handler" : SettingsHandler, + // translators: command line help text for set action + "help" : _("Set specified option"), + "options" : ["non_strict"], + // help text for unknown parameter name + "non_strict_help": _("Specify parameter and value to set") + ] + ], + "options" : $[ + "logfile" :$[ + // translators: command line help text for show logfile option + "help" : _("Show logfile settings") + ], + "diskspace" :$[ + // translators: command line help text for show disk space option + "help" : _("Show disk space settings") + ], + "max_log_file":$[ + // translators: command line help text for max_log_file option + "help" : _("Maximal number of logfiles"), + "type" : "string" + ] + ], + "mappings" : $[ + "show" : [ "logfile", "diskspace" ], + "set" : [ "max_log_file" ] + ] + ]; /* is this proposal or not? */ boolean propose = false; Added: trunk/audit-laf/src/cmdline.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/cmdline.ycp?rev=577... ============================================================================== --- trunk/audit-laf/src/cmdline.ycp (added) +++ trunk/audit-laf/src/cmdline.ycp Wed Jun 24 11:13:07 2009 @@ -0,0 +1,100 @@ +/** + * File: include/audit-laf/cmdline.ycp + * Package: Configuration of audit-laf + * Summary: Command line interface functions. + * Authors: Gabriele Mohr <gs@suse.de> + * + * + * All command line interface functions. + */ +{ + +textdomain "audit-laf"; + +import "CommandLine"; +import "AuditLaf"; +import "Report"; + +list <string> logfile_settings = ["log_file", + "max_log_file", + "name", + "log_format", + "flush", + "max_log_file_action", + "name_format" + ]; +list <string> diskspace_settings = ["space_left", + "action_mail_acct", + "admin_space_left", + "space_left_action", + "admin_space_left_action", + "disk_full_action", + "disk_error_action" + ]; + +define string GetLogfileSettings() { + + string settings = ""; + + foreach ( string key, logfile_settings, { + settings = settings + key + ": " + AuditLaf::GetAuditdOption(key) + "\n"; + } ); + return settings; +} + +define string GetDiskspaceSettings() { + string settings = ""; + + foreach ( string key, diskspace_settings, { + settings = settings + key + ": " + AuditLaf::GetAuditdOption(key) + "\n"; + } ); + + return settings; +} + +define boolean SettingsHandler (map<string,any> options ) { + + y2milestone ( "Options: %1", options ); + + foreach( string key, any val, options, ``{ + if ( contains (logfile_settings, key) || contains(diskspace_settings, key) ) + AuditLaf::SetAuditdOption( key, (string)val ); + }); + + return true; // call Write +} + +/** + * Show information about settings + * @return boolean false + */ +define boolean ShowHandler (map<string,any> options ) { + + y2milestone( "Options:%1", options ); + list<string> sets = []; + + foreach ( string key, any val, options, ``{ + if ( contains (["logfile","diskspace"], key) ) + sets = add (sets, key); + }); + if ( sets == [] ) + CommandLine::Print ( "Please specify information ('logfile' or 'diskpace')"); + + foreach ( string option, sets, { + if ( option == "logfile" ) + { + CommandLine::Print( GetLogfileSettings() ); + } + else if ( option == "diskspace" ) + { + CommandLine::Print( GetDiskspaceSettings() ); + } + else + CommandLine::Print ( "Unknown option" ); + } ); + + return false; // do not call Write... +} + + + } //EOF -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org