Author: gs
Date: Tue Jul 29 12:03:47 2008
New Revision: 49480
URL: http://svn.opensuse.org/viewcvs/yast?rev=49480&view=rev
Log:
read/write settings from/to auditd.conf
Modified:
trunk/auditd/src/Auditd.ycp
Modified: trunk/auditd/src/Auditd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/auditd/src/Auditd.ycp?rev=49480&r1=49479&r2=49480&view=diff
==============================================================================
--- trunk/auditd/src/Auditd.ycp (original)
+++ trunk/auditd/src/Auditd.ycp Tue Jul 29 12:03:47 2008
@@ -41,6 +41,8 @@
import "Message";
import "Popup";
import "Mode";
+import "FileUtils";
+
/**
* Prototypes
@@ -124,20 +126,61 @@
return false;
}
-// Settings: Define all variables needed for configuration of auditd
-// TODO FIXME: Define all the variables necessary to hold
-// TODO FIXME: the configuration here (with the appropriate
-// TODO FIXME: description)
-// TODO FIXME: For example:
-// /**
-// * List of the configured cards.
-// */
-// list cards = [];
//
-// /**
-// * Some additional parameter needed for the configuration.
-// */
-// boolean additional_parameter = true;
+// Settings: Define all variables needed for configuration of laf-audit
+//
+
+/**
+ * map of audit settings
+ */
+map SETTINGS = $[];
+
+/**
+ * map of auditd settings (from /etc/auditd.conf)
+ */
+map DEFAULT_CONFIG = $[
+ "log_file" : ["/var/log/audit/audit.log"],
+ "log_format" : ["RAW"],
+ "priority_boost" : ["3"],
+ "flush" : ["INCREMENTAL"],
+ "freq" : ["20"],
+ "num_logs" : ["4"],
+ "dispatcher" : ["/sbin/audispd"],
+ "disp_qos" : ["lossy"],
+ "max_log_file" : ["5"],
+ "max_log_file_action" : ["ROTATE"],
+ "space_left" : ["75"],
+ "space_left_action" : ["SYSLOG"],
+ "action_mail_acct" : ["root"],
+ "dmin_space_left": ["50"],
+ "admin_space_left_action" : ["SUSPEND"],
+ "disk_full_action" : ["SUSPEND"],
+ "disk_error_action" : ["SUSPEND"]
+];
+
+/**
+ * Read settings from auditd.conf
+ * @return true on success
+ */
+boolean ReadAuditdSettings() {
+
+ if ( ! FileUtils::Exists ("/etc/audit/auditd.conf") )
+ return false;
+
+ list <string> optionsList = (list <string>) SCR::Dir(.auditd);
+ y2milestone( "List of options: %1", optionsList );
+
+ // list all options set in auditd.conf
+ foreach (string key, (list <string>) SCR::Dir(.auditd),
+ {
+ // and read the value for each of them
+ list <string> val = (list <string>) SCR::Read(add(.auditd, key));
+ if (val != nil) SETTINGS[key] = val;
+ });
+
+ y2milestone("/etc/audit/auditd.conf has been read: %1", SETTINGS);
+ return true;
+}
/**
* Read all auditd settings
@@ -154,7 +197,6 @@
integer sl = 500;
sleep(sl);
- // TODO FIXME Names of real stages
// We do not set help text here, because it was set outside
Progress::New( caption, " ", steps, [
/* Progress stage 1/3 */
@@ -175,8 +217,11 @@
// read database
if(PollAbort()) return false;
Progress::NextStage();
- /* Error message */
- if(false) Report::Error(_("Cannot read database1."));
+
+ boolean success = ReadAuditdSettings();
+
+ // Report error
+ if( !success) Report::Error(_("Cannot read database1."));
sleep(sl);
// read another database
@@ -199,6 +244,33 @@
}
/**
+ * Write settings to auditd.conf
+ * @return true on success
+ */
+boolean WriteAuditdSettings() {
+ boolean success = true;
+
+ if ( ! FileUtils::Exists ("/etc/audit/auditd.conf") )
+ return false;
+
+ // TESTING:
+ SETTINGS["space_left"] = ["101"];
+ // list all options set in auditd.conf
+ foreach (string key, list <string> value, SETTINGS, {
+ // and write each value
+ success = (boolean)SCR::Write(add(.auditd, key), value );
+ y2milestone("Writing %1: %2", key, success?"true":"false" );
+ });
+
+ // 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);
+
+ return true;
+}
+
+/**
* Write all auditd settings
* @return true on success
*/
@@ -207,7 +279,7 @@
/* Auditd read dialog caption */
string caption = _("Saving auditd Configuration");
- // TODO FIXME And set the right number of stages
+ // set the right number of stages
integer steps = 2;
integer sl = 500;
@@ -231,14 +303,12 @@
);
// write settings
- if(PollAbort())
- {
- y2error( "ABORT" );
- return false;
- }
+ if(PollAbort()) return false;
Progress::NextStage();
+
+ boolean success = WriteAuditdSettings();
/* Error message */
- if(false) Report::Error (_("Cannot write settings."));
+ if(!success) Report::Error (_("Cannot write settings."));
sleep(sl);
// run SuSEconfig
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org