mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-29 05:17:59 +00:00
fixes for bugs 177039 1980891 198359
This commit is contained in:
parent
2d35d6e0fe
commit
42f1de10e6
@ -7,12 +7,31 @@
|
||||
* License published by the Free Software Foundation.
|
||||
*
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
{
|
||||
include "subdomain/config_complain.ycp";
|
||||
include "subdomain/event_notification_helptext.ycp";
|
||||
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 () {
|
||||
// AppArmor Status
|
||||
boolean sdIsEnabled = false;
|
||||
@ -22,7 +41,7 @@ define symbol displayAppArmorConfig () {
|
||||
|
||||
if (subdomain == "enabled") {
|
||||
sdIsEnabled = true;
|
||||
sdEnStr = _("AppArmor is enabled");
|
||||
sdEnStr = _("AppArmor is enabled");
|
||||
}
|
||||
|
||||
// Notification Status
|
||||
@ -30,7 +49,7 @@ define symbol displayAppArmorConfig () {
|
||||
string evEnStr = _("Notification is disabled");
|
||||
if (evnotify == "enabled") {
|
||||
ntIsEnabled = true;
|
||||
evEnStr = _("Notification is enabled");
|
||||
evEnStr = _("Notification is enabled");
|
||||
} else if (evnotify == "notinstalled") {
|
||||
evnotify = "disabled";
|
||||
}
|
||||
@ -40,7 +59,7 @@ define symbol displayAppArmorConfig () {
|
||||
string help = _("<p><b>AppArmor Status</b><br>This reports whether the AppArmor policy enforcement module is loaded and functioning.</p> <p><b>Security Event Notification</b><br>Configure this tool if you want to be notified by email when access violations have occurred.</p> <p><b>Profile Modes</b><br>Use this tool to change the way that AppArmor uses individual profiles.</p>");
|
||||
|
||||
term contents =
|
||||
`HVCenter( `HBox(
|
||||
`HVCenter( `HBox(
|
||||
`Frame(_("AppArmor Status"), `HBox(
|
||||
`VBox(
|
||||
`VSpacing(3), `HSpacing(2),
|
||||
@ -63,16 +82,15 @@ define symbol displayAppArmorConfig () {
|
||||
|
||||
`VSpacing( 1 ),
|
||||
`Frame ( _("Configure Profile Modes"),
|
||||
`HBox(
|
||||
//`HVCenter( `Label( `id(`notifyLabel), _("Configure Modes") )),
|
||||
`Left(`HVCenter( `Label( `id(`notifyLabel), " " + _("Set Profile Modes") ))),
|
||||
`PushButton( `id(`modeconf), _("Co&nfigure") )
|
||||
)
|
||||
),
|
||||
`VSpacing(3), `HSpacing( 2 )
|
||||
`HBox(
|
||||
`Left(`HVCenter( `Label( `id(`notifyLabel), " " + _("Set Profile Modes") ))),
|
||||
`PushButton( `id(`modeconf), _("Co&nfigure") )
|
||||
)
|
||||
),
|
||||
`VSpacing(3),
|
||||
`HSpacing( `opt(`hstretch), 4 )
|
||||
`VSpacing(3), `HSpacing( 2 )
|
||||
),
|
||||
`VSpacing(3),
|
||||
`HSpacing( `opt(`hstretch), 4 )
|
||||
)))
|
||||
)));
|
||||
|
||||
@ -82,7 +100,7 @@ define symbol displayAppArmorConfig () {
|
||||
Wizard::DisableBackButton();
|
||||
|
||||
while( true ) {
|
||||
symbol ret = (symbol) UI::UserInput();
|
||||
symbol ret = (symbol) UI::UserInput();
|
||||
|
||||
if ( ret == `abort || ret == `cancel || ret == `next) {
|
||||
break;
|
||||
@ -94,24 +112,24 @@ define symbol displayAppArmorConfig () {
|
||||
}
|
||||
|
||||
UI::OpenDialog(
|
||||
`VBox(
|
||||
`Frame ( _("Enable AppArmor"),
|
||||
`HBox(
|
||||
`RadioButtonGroup(`id(`subdomain),
|
||||
`HBox(
|
||||
`VSpacing( `opt(`vstretch), 0.5),
|
||||
`Left(`RadioButton(`id(0), _("Disabled"), sdNotEnabled)),
|
||||
`Left(`RadioButton(`id(1), _("Enabled"), sdIsEnabled)),
|
||||
`VSpacing( `opt(`vstretch), 0.5)
|
||||
)
|
||||
)
|
||||
)),
|
||||
`HBox (
|
||||
`PushButton(`id(`abort), _("&Cancel") ),
|
||||
`PushButton(`id(`ok), _("&OK") )
|
||||
))
|
||||
`VBox(
|
||||
`Frame ( _("Enable AppArmor"),
|
||||
`HBox(
|
||||
`RadioButtonGroup(`id(`subdomain),
|
||||
`HBox(
|
||||
`VSpacing( `opt(`vstretch), 0.5),
|
||||
`Left(`RadioButton(`id(0), _("Disabled"), sdNotEnabled)),
|
||||
`Left(`RadioButton(`id(1), _("Enabled"), sdIsEnabled)),
|
||||
`VSpacing( `opt(`vstretch), 0.5)
|
||||
)
|
||||
)
|
||||
)),
|
||||
`HBox (
|
||||
`PushButton(`id(`abort), _("&Cancel") ),
|
||||
`PushButton(`id(`ok), _("&OK") )
|
||||
))
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
/* Popup dialog to turn SD on/off */
|
||||
any sdInput = UI::UserInput();
|
||||
@ -131,42 +149,55 @@ define symbol displayAppArmorConfig () {
|
||||
scrret = SCR::Execute(.sdconf, sdAction);
|
||||
}
|
||||
UI::CloseDialog();
|
||||
if ( scrret != nil && is(scrret, string) ) {
|
||||
// Error condition.
|
||||
string errormsg = (string) scrret;
|
||||
string popError = _("This operation generated the following error. Please check your installation and AppArmor profile settings.");
|
||||
Popup::Message( popError+ "\n[" + errormsg + "]");
|
||||
sdIsEnabled = sdorig;
|
||||
} else {
|
||||
string sdLabelVal = "";
|
||||
if ( sdIsEnabled == true ) {
|
||||
sdLabelVal = _("AppArmor is enabled");
|
||||
} else {
|
||||
sdLabelVal = _("AppArmor is disabled") + " ";
|
||||
}
|
||||
UI::ChangeWidget( `id(`sdlabel), `Value, sdLabelVal );
|
||||
}
|
||||
if ( scrret != nil && is(scrret, string) ) {
|
||||
// Error condition.
|
||||
string errormsg = (string) scrret;
|
||||
string popError = _("This operation generated the following error. Please check your installation and AppArmor profile settings.");
|
||||
Popup::Message( popError+ "\n[" + errormsg + "]");
|
||||
sdIsEnabled = sdorig;
|
||||
} else {
|
||||
string sdLabelVal = "";
|
||||
if ( sdIsEnabled == true ) {
|
||||
sdLabelVal = _("AppArmor is enabled");
|
||||
} else {
|
||||
sdLabelVal = _("AppArmor is disabled") + " ";
|
||||
}
|
||||
UI::ChangeWidget( `id(`sdlabel), `Value, sdLabelVal );
|
||||
}
|
||||
} 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");
|
||||
|
||||
any t_freq = settings["terse_freq"]:0;
|
||||
any s_freq = settings["summary_freq"]:0;
|
||||
any v_freq = settings["verbose_freq"]:0;
|
||||
map<string,any> terse = settings["terse"]:$[];
|
||||
map<string,any> summary = settings["summary"]:$[];
|
||||
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;
|
||||
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") {
|
||||
t_unknown = false;
|
||||
}
|
||||
|
||||
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") {
|
||||
s_unknown = false;
|
||||
}
|
||||
|
||||
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") {
|
||||
v_unknown = false;
|
||||
}
|
||||
@ -217,8 +248,8 @@ define symbol displayAppArmorConfig () {
|
||||
`VBox(`opt(`vstretch),
|
||||
`HBox(
|
||||
`ComboBox(`id(`terse_freq), _("Frequency"), terse_items),
|
||||
`TextEntry(`id(`terse_email), _("Email Address"), settings["terse_email"]:""),
|
||||
`IntField(`id(`terse_level), _("Severity"), 0,10, settings["terse_level"]:0)
|
||||
`TextEntry(`id(`terse_email), _("Email Address"), terse["terse_email"]:""),
|
||||
`IntField(`id(`terse_level), _("Severity"), 0,10, terse["terse_level"]:0)
|
||||
),
|
||||
`HBox(
|
||||
`CheckBox( `id(`terse_unknown), _("Include Unknown Severity Events"), t_unknown)
|
||||
@ -230,8 +261,8 @@ define symbol displayAppArmorConfig () {
|
||||
`VBox(`opt(`vstretch),
|
||||
`HBox(
|
||||
`ComboBox(`id(`summary_freq), _("Frequency"), summary_items),
|
||||
`TextEntry(`id(`summary_email), _("Email Address"), settings["summary_email"]:""),
|
||||
`IntField(`id(`summary_level), _("Severity"), 0,10, settings["summary_level"]:0)
|
||||
`TextEntry(`id(`summary_email), _("Email Address"), summary["summary_email"]:""),
|
||||
`IntField(`id(`summary_level), _("Severity"), 0,10, summary["summary_level"]:0)
|
||||
),
|
||||
`HBox(
|
||||
`CheckBox( `id(`summary_unknown), _("Include Unknown Severity Events"), s_unknown)
|
||||
@ -243,8 +274,8 @@ define symbol displayAppArmorConfig () {
|
||||
`VBox(`opt(`vstretch),
|
||||
`HBox(
|
||||
`ComboBox(`id(`verbose_freq), _("Frequency"), verbose_items),
|
||||
`TextEntry(`id(`verbose_email), _("Email Address"), settings["verbose_email"]:""),
|
||||
`IntField(`id(`verbose_level), _("Severity"), 0,10, settings["verbose_level"]:0)
|
||||
`TextEntry(`id(`verbose_email), _("Email Address"), verbose["verbose_email"]:""),
|
||||
`IntField(`id(`verbose_level), _("Severity"), 0,10, verbose["verbose_level"]:0)
|
||||
),
|
||||
`HBox(
|
||||
`CheckBox( `id(`verbose_unknown), _("Include Unknown Severity Events"), v_unknown)
|
||||
@ -266,117 +297,136 @@ define symbol displayAppArmorConfig () {
|
||||
any ntInput = nil;
|
||||
string notifyLabelValue = "";
|
||||
|
||||
while( true ) {
|
||||
ntInput = UI::UserInput();
|
||||
while( true ) {
|
||||
ntInput = UI::UserInput();
|
||||
|
||||
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);
|
||||
s_freq = UI::QueryWidget(`id(`summary_freq), `Value);
|
||||
v_freq = UI::QueryWidget(`id(`verbose_freq), `Value);
|
||||
t_freq = UI::QueryWidget(`id(`terse_freq), `Value);
|
||||
s_freq = UI::QueryWidget(`id(`summary_freq), `Value);
|
||||
v_freq = UI::QueryWidget(`id(`verbose_freq), `Value);
|
||||
|
||||
answers["sd-set-notify"] = "yes";
|
||||
answers["terse_freq"] = tostring(t_freq);
|
||||
answers["summary_freq"] = tostring(s_freq);
|
||||
answers["verbose_freq"] = tostring(v_freq);
|
||||
set_notify["sd-set-notify"] = "yes";
|
||||
terse["terse_freq"] = tostring(t_freq);
|
||||
summary["summary_freq"] = tostring(s_freq);
|
||||
verbose["verbose_freq"] = tostring(v_freq);
|
||||
|
||||
if(t_freq != 0) {
|
||||
if (t_freq != 0) {
|
||||
|
||||
string t_email = (string) UI::QueryWidget(`id(`terse_email), `Value);
|
||||
string t_email = (string) UI::QueryWidget(`id(`terse_email), `Value);
|
||||
|
||||
if ( t_email == nil || t_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
}
|
||||
if ( t_email == nil || t_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
} else if ( ! safeFormat(t_email) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
answers["enable_terse"] = "yes";
|
||||
answers["terse_email"] = (string) UI::QueryWidget(`id(`terse_email), `Value);
|
||||
answers["terse_level"] = (string) tostring(UI::QueryWidget(`id(`terse_level), `Value));
|
||||
terse["enable_terse"] = "yes";
|
||||
terse["terse_email"] = (string) UI::QueryWidget(`id(`terse_email), `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) {
|
||||
answers["terse_unknown"] = "1";
|
||||
} else {
|
||||
answers["terse_unknown"] = "0";
|
||||
}
|
||||
if (t_unknown == true) {
|
||||
terse["terse_unknown"] = "1";
|
||||
} else {
|
||||
terse["terse_unknown"] = "0";
|
||||
}
|
||||
|
||||
} else {
|
||||
answers["enable_terse"] = "no";
|
||||
}
|
||||
} else {
|
||||
terse["enable_terse"] = "no";
|
||||
}
|
||||
|
||||
if (s_freq != 0) {
|
||||
if (s_freq != 0) {
|
||||
|
||||
string s_email = (string) UI::QueryWidget(`id(`summary_email), `Value);
|
||||
if ( s_email == nil || s_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
}
|
||||
string s_email = (string) UI::QueryWidget(`id(`summary_email), `Value);
|
||||
if ( s_email == nil || s_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
} else if ( ! safeFormat(s_email) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
answers["enable_summary"] = "yes";
|
||||
answers["summary_email"] = (string) UI::QueryWidget(`id(`summary_email), `Value);
|
||||
answers["summary_level"] = (string) tostring(UI::QueryWidget(`id(`summary_level), `Value));
|
||||
summary["enable_summary"] = "yes";
|
||||
summary["summary_email"] = (string) UI::QueryWidget(`id(`summary_email), `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) {
|
||||
answers["summary_unknown"] = "1";
|
||||
} else {
|
||||
answers["summary_unknown"] = "0";
|
||||
}
|
||||
if (s_unknown == true) {
|
||||
summary["summary_unknown"] = "1";
|
||||
} else {
|
||||
summary["summary_unknown"] = "0";
|
||||
}
|
||||
|
||||
} else {
|
||||
answers["enable_summary"] = "no";
|
||||
}
|
||||
} else {
|
||||
summary["enable_summary"] = "no";
|
||||
}
|
||||
|
||||
if (v_freq != 0) {
|
||||
string v_email = (string) UI::QueryWidget(`id(`verbose_email), `Value);
|
||||
if ( v_email == nil || v_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
}
|
||||
if (v_freq != 0) {
|
||||
string v_email = (string) UI::QueryWidget(`id(`verbose_email), `Value);
|
||||
if ( v_email == nil || v_email == "" ) {
|
||||
Popup::Error( _("An email address is required for each selected notification method.") );
|
||||
continue;
|
||||
} else if (! safeFormat(v_email) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
answers["enable_verbose"] = "yes";
|
||||
answers["verbose_email"] = (string) UI::QueryWidget(`id(`verbose_email), `Value);
|
||||
answers["verbose_level"] = (string) tostring(UI::QueryWidget(`id(`verbose_level), `Value));
|
||||
verbose["enable_verbose"] = "yes";
|
||||
verbose["verbose_email"] = (string) UI::QueryWidget(`id(`verbose_email), `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) {
|
||||
answers["verbose_unknown"] = "1";
|
||||
} else {
|
||||
answers["verbose_unknown"] = "0";
|
||||
}
|
||||
} else {
|
||||
answers["enable_verbose"] = "no";
|
||||
}
|
||||
if (v_unknown == true) {
|
||||
verbose["verbose_unknown"] = "1";
|
||||
} else {
|
||||
verbose["verbose_unknown"] = "0";
|
||||
}
|
||||
} else {
|
||||
verbose["enable_verbose"] = "no";
|
||||
}
|
||||
|
||||
SCR::Execute(.sdconf, answers);
|
||||
answers["set_notify"] = set_notify;
|
||||
answers["terse"] = terse;
|
||||
answers["summary"] = summary;
|
||||
answers["verbose"] = verbose;
|
||||
|
||||
if ( t_freq != 0 || s_freq != 0 || v_freq != 0 ) {
|
||||
notifyLabelValue = _("Notification is enabled");
|
||||
} else {
|
||||
notifyLabelValue = _("Notification is disabled");
|
||||
}
|
||||
}
|
||||
string result = (string) SCR::Execute(.sdconf, answers);
|
||||
|
||||
Wizard::CloseDialog();
|
||||
if ( (ntInput == `ok) || (ntInput == `next) ) {
|
||||
UI::ChangeWidget( `id(`notifyLabel), `Value, notifyLabelValue );
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (result != "success") {
|
||||
Popup::Error( _("Configuration failed for the following operations: ") + result);
|
||||
}
|
||||
|
||||
} else if (ret == `modeconf ) {
|
||||
if ( t_freq != 0 || s_freq != 0 || v_freq != 0 ) {
|
||||
notifyLabelValue = _("Notification is enabled");
|
||||
} else {
|
||||
notifyLabelValue = _("Notification is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
ret = profileModeConfigForm();
|
||||
if ( ret == `back ) {
|
||||
displayAppArmorConfig();
|
||||
}
|
||||
Wizard::CloseDialog();
|
||||
if ( (ntInput == `ok) || (ntInput == `next) ) {
|
||||
UI::ChangeWidget( `id(`notifyLabel), `Value, notifyLabelValue );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
} else if (ret == `modeconf ) {
|
||||
|
||||
ret = profileModeConfigForm();
|
||||
if ( ret == `back ) {
|
||||
displayAppArmorConfig();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
} else {
|
||||
y2milestone("Weird dialogue close--incl." + tostring(ret));
|
||||
|
Loading…
x
Reference in New Issue
Block a user