2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 21:38:15 +00:00

fixes for bugs 177039 1980891 198359

This commit is contained in:
David J Drewelow 2006-11-10 09:43:49 +00:00
parent 2d35d6e0fe
commit 42f1de10e6

View File

@ -7,12 +7,31 @@
* License published by the Free Software Foundation. * License published by the Free Software Foundation.
* *
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
{ {
include "subdomain/config_complain.ycp"; include "subdomain/config_complain.ycp";
include "subdomain/event_notification_helptext.ycp"; include "subdomain/event_notification_helptext.ycp";
textdomain "yast2-apparmor"; textdomain "yast2-apparmor";
define boolean safeFormat (string emailAddr) {
boolean isSafe = false;
integer emailAddrLength = size(emailAddr);
// Allow only name@host formats
if ( emailAddrLength > 128 ) {
Popup::Error( _("Email address is too long. Please enter another address.") );
} else if ( ! regexpmatch(emailAddr, "..+") &&
regexpmatch(emailAddr, "/^(\w+\.?)+\w+\@(\w+\.?)+\w+$") ) {
isSafe = true;
} else if ( regexpmatch(emailAddr, "\\w+@\\w+") ) {
isSafe = true;
} else {
Popup::Error( _("Error in email address format. Please use \"name@host\" format.") );
}
return isSafe;
}
define symbol displayAppArmorConfig () { define symbol displayAppArmorConfig () {
// AppArmor Status // AppArmor Status
boolean sdIsEnabled = false; boolean sdIsEnabled = false;
@ -64,7 +83,6 @@ define symbol displayAppArmorConfig () {
`VSpacing( 1 ), `VSpacing( 1 ),
`Frame ( _("Configure Profile Modes"), `Frame ( _("Configure Profile Modes"),
`HBox( `HBox(
//`HVCenter( `Label( `id(`notifyLabel), _("Configure Modes") )),
`Left(`HVCenter( `Label( `id(`notifyLabel), " " + _("Set Profile Modes") ))), `Left(`HVCenter( `Label( `id(`notifyLabel), " " + _("Set Profile Modes") ))),
`PushButton( `id(`modeconf), _("Co&nfigure") ) `PushButton( `id(`modeconf), _("Co&nfigure") )
) )
@ -147,26 +165,39 @@ define symbol displayAppArmorConfig () {
UI::ChangeWidget( `id(`sdlabel), `Value, sdLabelVal ); UI::ChangeWidget( `id(`sdlabel), `Value, sdLabelVal );
} }
} else if (ret == `ntconf ) { } else if (ret == `ntconf ) {
//map<string,map> settings = (map<string,map>) SCR::Execute(.subdomain, "sd-notify-settings");
map settings = (map) SCR::Execute(.subdomain, "sd-notify-settings"); map settings = (map) SCR::Execute(.subdomain, "sd-notify-settings");
any t_freq = settings["terse_freq"]:0; map<string,any> terse = settings["terse"]:$[];
any s_freq = settings["summary_freq"]:0; map<string,any> summary = settings["summary"]:$[];
any v_freq = settings["verbose_freq"]:0; map<string,any> verbose = settings["verbose"]:$[];
//foreach (string k, any v, terse, { string av = tostring(v); y2milestone("[appa] Terse Check: Type: %1, Val: %2", k,av); return av; });
any t_freq = terse["terse_freq"]:0;
any s_freq = summary["summary_freq"]:0;
any v_freq = verbose["verbose_freq"]:0;
boolean t_unknown = true; boolean t_unknown = true;
string t_poop = settings["terse_unknown"]:"1"; //string t_poop = summary["terse_unknown"]:"1";
any a_t_poop = (any) terse["terse_unknown"]:"1";
string t_poop = tostring(a_t_poop);
if(t_poop == "0") { if(t_poop == "0") {
t_unknown = false; t_unknown = false;
} }
boolean s_unknown = true; boolean s_unknown = true;
string s_poop = settings["summary_unknown"]:"1"; //string s_poop = summary["summary_unknown"]:"1";
any a_s_poop = terse["summary_unknown"]:"1";
string s_poop = tostring(a_s_poop);
if(s_poop == "0") { if(s_poop == "0") {
s_unknown = false; s_unknown = false;
} }
boolean v_unknown = true; boolean v_unknown = true;
string v_poop = settings["verbose_unknown"]:"1"; //string v_poop = verbose["verbose_unknown"]:"1";
any a_v_poop = verbose["verbose_unknown"]:"1";
string v_poop = tostring(a_v_poop);
if(v_poop == "0") { if(v_poop == "0") {
v_unknown = false; v_unknown = false;
} }
@ -217,8 +248,8 @@ define symbol displayAppArmorConfig () {
`VBox(`opt(`vstretch), `VBox(`opt(`vstretch),
`HBox( `HBox(
`ComboBox(`id(`terse_freq), _("Frequency"), terse_items), `ComboBox(`id(`terse_freq), _("Frequency"), terse_items),
`TextEntry(`id(`terse_email), _("Email Address"), settings["terse_email"]:""), `TextEntry(`id(`terse_email), _("Email Address"), terse["terse_email"]:""),
`IntField(`id(`terse_level), _("Severity"), 0,10, settings["terse_level"]:0) `IntField(`id(`terse_level), _("Severity"), 0,10, terse["terse_level"]:0)
), ),
`HBox( `HBox(
`CheckBox( `id(`terse_unknown), _("Include Unknown Severity Events"), t_unknown) `CheckBox( `id(`terse_unknown), _("Include Unknown Severity Events"), t_unknown)
@ -230,8 +261,8 @@ define symbol displayAppArmorConfig () {
`VBox(`opt(`vstretch), `VBox(`opt(`vstretch),
`HBox( `HBox(
`ComboBox(`id(`summary_freq), _("Frequency"), summary_items), `ComboBox(`id(`summary_freq), _("Frequency"), summary_items),
`TextEntry(`id(`summary_email), _("Email Address"), settings["summary_email"]:""), `TextEntry(`id(`summary_email), _("Email Address"), summary["summary_email"]:""),
`IntField(`id(`summary_level), _("Severity"), 0,10, settings["summary_level"]:0) `IntField(`id(`summary_level), _("Severity"), 0,10, summary["summary_level"]:0)
), ),
`HBox( `HBox(
`CheckBox( `id(`summary_unknown), _("Include Unknown Severity Events"), s_unknown) `CheckBox( `id(`summary_unknown), _("Include Unknown Severity Events"), s_unknown)
@ -243,8 +274,8 @@ define symbol displayAppArmorConfig () {
`VBox(`opt(`vstretch), `VBox(`opt(`vstretch),
`HBox( `HBox(
`ComboBox(`id(`verbose_freq), _("Frequency"), verbose_items), `ComboBox(`id(`verbose_freq), _("Frequency"), verbose_items),
`TextEntry(`id(`verbose_email), _("Email Address"), settings["verbose_email"]:""), `TextEntry(`id(`verbose_email), _("Email Address"), verbose["verbose_email"]:""),
`IntField(`id(`verbose_level), _("Severity"), 0,10, settings["verbose_level"]:0) `IntField(`id(`verbose_level), _("Severity"), 0,10, verbose["verbose_level"]:0)
), ),
`HBox( `HBox(
`CheckBox( `id(`verbose_unknown), _("Include Unknown Severity Events"), v_unknown) `CheckBox( `id(`verbose_unknown), _("Include Unknown Severity Events"), v_unknown)
@ -271,16 +302,20 @@ define symbol displayAppArmorConfig () {
if (ntInput == `next) { if (ntInput == `next) {
map<string,string> answers = $[ ]; map<string,map> answers = $[ ];
map<string,string> set_notify = $[ ];
map<string,string> summary = $[ ];
map<string,string> verbose = $[ ];
map<string,string> terse = $[ ];
t_freq = UI::QueryWidget(`id(`terse_freq), `Value); t_freq = UI::QueryWidget(`id(`terse_freq), `Value);
s_freq = UI::QueryWidget(`id(`summary_freq), `Value); s_freq = UI::QueryWidget(`id(`summary_freq), `Value);
v_freq = UI::QueryWidget(`id(`verbose_freq), `Value); v_freq = UI::QueryWidget(`id(`verbose_freq), `Value);
answers["sd-set-notify"] = "yes"; set_notify["sd-set-notify"] = "yes";
answers["terse_freq"] = tostring(t_freq); terse["terse_freq"] = tostring(t_freq);
answers["summary_freq"] = tostring(s_freq); summary["summary_freq"] = tostring(s_freq);
answers["verbose_freq"] = tostring(v_freq); verbose["verbose_freq"] = tostring(v_freq);
if (t_freq != 0) { if (t_freq != 0) {
@ -289,22 +324,24 @@ define symbol displayAppArmorConfig () {
if ( t_email == nil || t_email == "" ) { if ( t_email == nil || t_email == "" ) {
Popup::Error( _("An email address is required for each selected notification method.") ); Popup::Error( _("An email address is required for each selected notification method.") );
continue; continue;
} else if ( ! safeFormat(t_email) ) {
continue;
} }
answers["enable_terse"] = "yes"; terse["enable_terse"] = "yes";
answers["terse_email"] = (string) UI::QueryWidget(`id(`terse_email), `Value); terse["terse_email"] = (string) UI::QueryWidget(`id(`terse_email), `Value);
answers["terse_level"] = (string) tostring(UI::QueryWidget(`id(`terse_level), `Value)); terse["terse_level"] = (string) tostring(UI::QueryWidget(`id(`terse_level), `Value));
boolean t_unknown = (boolean) UI::QueryWidget(`id(`terse_unknown), `Value); boolean t_unknown = (boolean) UI::QueryWidget(`id(`terse_unknown), `Value);
if (t_unknown == true) { if (t_unknown == true) {
answers["terse_unknown"] = "1"; terse["terse_unknown"] = "1";
} else { } else {
answers["terse_unknown"] = "0"; terse["terse_unknown"] = "0";
} }
} else { } else {
answers["enable_terse"] = "no"; terse["enable_terse"] = "no";
} }
if (s_freq != 0) { if (s_freq != 0) {
@ -313,22 +350,24 @@ define symbol displayAppArmorConfig () {
if ( s_email == nil || s_email == "" ) { if ( s_email == nil || s_email == "" ) {
Popup::Error( _("An email address is required for each selected notification method.") ); Popup::Error( _("An email address is required for each selected notification method.") );
continue; continue;
} else if ( ! safeFormat(s_email) ) {
continue;
} }
answers["enable_summary"] = "yes"; summary["enable_summary"] = "yes";
answers["summary_email"] = (string) UI::QueryWidget(`id(`summary_email), `Value); summary["summary_email"] = (string) UI::QueryWidget(`id(`summary_email), `Value);
answers["summary_level"] = (string) tostring(UI::QueryWidget(`id(`summary_level), `Value)); summary["summary_level"] = (string) tostring(UI::QueryWidget(`id(`summary_level), `Value));
boolean s_unknown = (boolean) UI::QueryWidget(`id(`summary_unknown), `Value); boolean s_unknown = (boolean) UI::QueryWidget(`id(`summary_unknown), `Value);
if (s_unknown == true) { if (s_unknown == true) {
answers["summary_unknown"] = "1"; summary["summary_unknown"] = "1";
} else { } else {
answers["summary_unknown"] = "0"; summary["summary_unknown"] = "0";
} }
} else { } else {
answers["enable_summary"] = "no"; summary["enable_summary"] = "no";
} }
if (v_freq != 0) { if (v_freq != 0) {
@ -336,24 +375,35 @@ define symbol displayAppArmorConfig () {
if ( v_email == nil || v_email == "" ) { if ( v_email == nil || v_email == "" ) {
Popup::Error( _("An email address is required for each selected notification method.") ); Popup::Error( _("An email address is required for each selected notification method.") );
continue; continue;
} else if (! safeFormat(v_email) ) {
continue;
} }
answers["enable_verbose"] = "yes"; verbose["enable_verbose"] = "yes";
answers["verbose_email"] = (string) UI::QueryWidget(`id(`verbose_email), `Value); verbose["verbose_email"] = (string) UI::QueryWidget(`id(`verbose_email), `Value);
answers["verbose_level"] = (string) tostring(UI::QueryWidget(`id(`verbose_level), `Value)); verbose["verbose_level"] = (string) tostring(UI::QueryWidget(`id(`verbose_level), `Value));
boolean v_unknown = (boolean) UI::QueryWidget(`id(`verbose_unknown), `Value); boolean v_unknown = (boolean) UI::QueryWidget(`id(`verbose_unknown), `Value);
if (v_unknown == true) { if (v_unknown == true) {
answers["verbose_unknown"] = "1"; verbose["verbose_unknown"] = "1";
} else { } else {
answers["verbose_unknown"] = "0"; verbose["verbose_unknown"] = "0";
} }
} else { } else {
answers["enable_verbose"] = "no"; verbose["enable_verbose"] = "no";
} }
SCR::Execute(.sdconf, answers); answers["set_notify"] = set_notify;
answers["terse"] = terse;
answers["summary"] = summary;
answers["verbose"] = verbose;
string result = (string) SCR::Execute(.sdconf, answers);
if (result != "success") {
Popup::Error( _("Configuration failed for the following operations: ") + result);
}
if ( t_freq != 0 || s_freq != 0 || v_freq != 0 ) { if ( t_freq != 0 || s_freq != 0 || v_freq != 0 ) {
notifyLabelValue = _("Notification is enabled"); notifyLabelValue = _("Notification is enabled");