) reportdata, {
+ reportlist = add( reportlist, `item( `id(key), repdata["date"]:nil, repdata["prof"]:nil, repdata["pid"]:nil, repdata["mesg"]:nil));
+ });
+
+ string help1 = _("AppArmor Security Events
+ This table displays the events found that match your search criteria.");
+
+
+ // DBG y2milestone("in MainReportForm");
+ term contents_main_prof_form =
+ `VBox(
+ `Label( _("AppArmor Event Report Data") ),
+ `HBox(
+ `VSpacing(10),
+ `Table(`id(`table), `opt(`notify, `immediate ), `header(_("Date"),
+ _("Profile"), _("PID"), _("AppArmor Message") ), reportlist),
+ `VSpacing(0.5)
+ )
+ );
+ Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
+ contents_main_prof_form, help1, Label::BackButton(), _("&Done") );
+
+
+ map event = $[];
+ any id = nil;
+ while( true ) {
+
+ event = UI::WaitForEvent( timeout_millisec );
+ id = event["ID"]:nil; // We'll need this often - cache it
+
+ if ( id == `table ) {
+
+ if ( event["EventReason"]:nil == "Activated" ) {
+ // Widget activated in the table
+ integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
+ }
+
+ } else if ( id == `abort || id == `cancel || id == `done ) {
+ break;
+ } else if ( id == `back || id == `next ) {
+ break;
+ } else {
+ y2error("Unexpected return code: %1", id);
+ continue;
+ }
+ }
+ return (symbol) id;
+}
+
+// This is the first and base reporting form
+define symbol mainReportForm() {
+
+ term mainForm =
+
+ `VBox(
+ `Label( _("AppArmor Reporting") ),
+ `VSpacing(2),
+ `VBox(
+ `Left(`CheckBox( `id(`schedrep), `opt(`notify), _("Schedule Reports"), true )),
+ `Left(`CheckBox( `id(`viewrep), `opt(`notify), _("View Archived Reports") )),
+ `Left(`CheckBox( `id(`runrep), `opt(`notify), _("Run Reports") ))
+ ),
+ `VSpacing(0.5)
+ );
+
+ Wizard::SetContentsButtons( _("AppArmor Security Event Report"), mainForm, mainHelp, Label::BackButton(), Label::NextButton() );
+
+ map event = $[];
+ any id = nil;
+ while( true ) {
+
+ event = UI::WaitForEvent( timeout_millisec );
+ id = event["ID"]:nil; // We'll need this often - cache it
+
+ if ( id == `schedrep ) {
+ UI::ChangeWidget(`id(`viewrep), `Value, false);
+ UI::ChangeWidget(`id(`runrep), `Value, false);
+ } else if ( id == `viewrep ) {
+ UI::ChangeWidget(`id(`schedrep), `Value, false);
+ UI::ChangeWidget(`id(`runrep), `Value, false);
+ } else if ( id == `runrep ) {
+ UI::ChangeWidget(`id(`schedrep), `Value, false);
+ UI::ChangeWidget(`id(`viewrep), `Value, false);
+ } else if ( id == `abort || id == `cancel || id == `done ) {
+ break;
+ } else if ( id == `back ) {
+ break;
+ } else if ( id == `next ) {
+
+ if ( UI::QueryWidget(`id(`schedrep), `Value) == true ) {
+ id = `schedrep;
+ } else if ( UI::QueryWidget(`id(`viewrep), `Value) == true ) {
+ id = `viewrep;
+ } else if ( UI::QueryWidget(`id(`runrep), `Value) == true ) {
+ id = `runrep;
+ }
+
+ break;
+
+ } else {
+ y2error("Unexpected return code: %1", id);
+ continue;
+ }
+ }
+
+ return (symbol) id;
+}
+
+// Form used to select the type of archived report to list
+define term viewForm(map archType, list itemList, string repPath) {
+
+ boolean sirRep = archType["sirRep"]:false;
+ boolean audRep = archType["audRep"]:false;
+ boolean essRep = archType["essRep"]:false;
+
+ if ( repPath == "" || repPath == nil ) {
+ repPath = "/var/log/apparmor/reports-archived/";
+ }
+
+ if ( audRep == false && essRep == false ) {
+ sirRep = true;
+ }
+
+ term vForm =
+ `ReplacePoint(`id(`viewform), `VBox(
+ `Label( _("View Archived Reports") ),
+ `HSpacing(60), // make the table and thus the dialog wide enough
+ `VSpacing(1),
+ `HBox(
+ `Frame( `id(`radioSelect), _("Choose a Report Type"),
+ `RadioButtonGroup(`id(`chooseRep), `HBox(
+ `HStretch(),
+ `RadioButton(`id(`sirRep), `opt(`notify, `immediate), _("SIR"), sirRep),
+ `HSpacing(1),
+ `RadioButton(`id(`audRep), `opt(`notify, `immediate), _("App Aud"), audRep),
+ `HSpacing(1),
+ `RadioButton(`id(`essRep), `opt(`notify, `immediate), _("ESS"), essRep),
+ `HSpacing(1),
+ `HStretch()
+ )))
+ ),
+ `VSpacing(1),
+ `Frame( `id(`repFrame), _("Location of Archived Reports"),
+ `HBox(
+ `Left(`Label(repPath)),
+ `HSpacing(1),
+ `Left(`PushButton(`id(`browse), _("&Browse"))),
+ `HStretch()
+ )
+ ),
+ `VSpacing(0.5),
+ `VWeight( 10, `HBox(
+ `VSpacing(1),
+ `Table(`id(`table), `opt(`notify, `immediate), `header(_("Report"),
+ _("Date") ), itemList ) )
+ ),
+ `VSpacing(1),
+ `HBox(
+ `VSpacing(1),
+ `PushButton(`id(`view), _("&View") ),
+ `PushButton(`id(`viewall), _("View &All") )
+ )
+ ));
+
+ return vForm;
+}
+
+define map filterConfigForm(string name) {
+
+ // Cheating way to set filters
+ map opts = $[];
+ opts["getSirFilters"] = "1";
+ opts["name"] = name;
+ opts["gui"] = "1";
+ map preFilters = $[];
+ preFilters = (map) SCR::Read( .logparse, opts );
+
+ any asev = preFilters["severity"]:nil;
+ string sev = "";
+ if ( asev != nil ) { sev = tostring(asev); }
+ if ( sev == "-" ) { sev = _("All"); }
+
+ Wizard::SetContentsButtons( _("Report Configuration Dialog"),
+ filterForm2(name,preFilters), filterCfHelp1, Label::BackButton(), Label::NextButton() );
+
+ if ( sev != "" && sev != _("All") ) {
+ if ( sev != "U" ) {
+ integer isev = tointeger(sev);
+ if ( isev < 10 ) {
+ sev = "0" + sev;
+ }
+ }
+
+ UI::ChangeWidget(`id(`sev), `Value, sev);
+ }
+
+ string mode = "All";
+ string sdmode = "R";
+
+ Settings = $[ ];
+ map event = $[];
+ any id = nil;
+ UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
+
+ while( true ) {
+
+ event = UI::WaitForEvent( timeout_millisec );
+ id = event["ID"]:nil;
+
+ if ( id == `bydate ) {
+
+ boolean val = (boolean) UI::QueryWidget(`id(`bydate), `Value);
+ if ( val == true ) {
+ UI::ChangeWidget(`id(`bydate_frame), `Enabled, true);
+ } else {
+ UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
+ }
+
+ } else if ( id == `abort || id == `done || id == `cancel) {
+ Settings["break"] = "abort";
+ break;
+
+ } else if ( id == `back ) {
+ Settings["break"] = "back";
+ break;
+
+ } else if ( id == `sdmode ) {
+
+ sdmode = popUpSdMode();
+
+ if ( sdmode != "" ) {
+ Settings["sdmode"] = sdmode;
+ UI::ReplaceWidget(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode) ) );
+ }
+
+ } else if ( id == `mode ) {
+
+ mode = popUpMode();
+
+ if ( mode != "" ) {
+ Settings["mode"] = mode;
+ UI::ReplaceWidget(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )));
+ }
+
+ } else if ( id == `browse ) {
+
+ string selectFile = "";
+ selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
+
+ if ( selectFile != nil ) {
+ UI::ChangeWidget(`id(`expPath), `Value, selectFile);
+ }
+
+ Settings["expPath"] = expPath;
+
+ } else if ( id == `save || id == `next) {
+
+ // Setup the data structures.
+ boolean bydate = (boolean) UI::QueryWidget(`id(`bydate), `Value);
+ boolean expText = false;
+ boolean expHtml = false;
+
+ if ( UI::QueryWidget(`id(`expLog), `Enabled) == true ) {
+ expText = (boolean) UI::QueryWidget(`id(`exportText), `Value);
+ expHtml = (boolean) UI::QueryWidget(`id(`exportHtml), `Value);
+ }
+
+ if ( expText == true ) {
+ Settings["exporttext"] = "true";
+ }
+ if ( expHtml == true ) {
+ Settings["exporthtml"] = "true";
+ }
+
+ string program_name = (string) UI::QueryWidget(`id(`prog), `Value);
+ string profile = (string) UI::QueryWidget(`id(`prof), `Value);
+ string pid = (string) UI::QueryWidget(`id(`pid), `Value);
+ string sev = (string) UI::QueryWidget(`id(`sev), `Value);
+ string res = (string) UI::QueryWidget(`id(`res), `Value);
+ string sdmode = (string) UI::QueryWidget(`id(`sdmode), `Label);
+ string mode = (string) UI::QueryWidget(`id(`mode), `Label);
+ string exppath = (string) UI::QueryWidget(`id(`expPath), `Value);
+
+ // de-i18n
+ if ( sev == _("All") ) { sev = "All"; }
+ if ( sev == _("U") ) { sev = "U"; }
+
+ if (exppath != "" ) { Settings["exportPath"] = expPath; }
+ if ( program_name != "" ) { Settings["prog"] = program_name; }
+ if ( profile != "" ) { Settings["profile"] = profile; }
+ if ( pid != "" ) { Settings["pid"] = pid; }
+ if ( sev != "" && sev != "All" ) { Settings["severity"] = sev; }
+ if ( res != "" ) { Settings["resource"] = res; }
+ if ( sdmode != "" ) { Settings["sdmode"] = humanStringToMode( sdmode); }
+ if ( mode != "" ) { Settings["mode"] = humanStringToMode( mode ); }
+
+ if ( bydate == true ) {
+
+ integer start_hour = (integer) UI::QueryWidget(`id(`startHour), `Value);
+ integer start_min = (integer) UI::QueryWidget(`id(`startMin), `Value);
+ integer startDay = (integer) UI::QueryWidget(`id(`startDay), `Value);
+ integer startMonth = (integer) UI::QueryWidget(`id(`startMonth), `Value);
+ integer startYear = (integer) UI::QueryWidget(`id(`startYear), `Value);
+ integer end_hour = (integer) UI::QueryWidget(`id(`endHour), `Value);
+ integer end_min = (integer) UI::QueryWidget(`id(`endMin), `Value);
+ integer endDay = (integer) UI::QueryWidget(`id(`endDay), `Value);
+ integer endMonth = (integer) UI::QueryWidget(`id(`endMonth), `Value);
+ integer endYear = (integer) UI::QueryWidget(`id(`endYear), `Value);
+
+ string start_time = tostring(start_hour) + ":" + tostring(start_min);
+ string end_time = tostring(end_hour) + ":" + tostring(end_min);
+
+ if ( CheckDate(startDay,startMonth,startYear) == false ) {
+ Popup::Error( _("Illegal start date entered. Please retry.") );
+ continue;
+ }
+
+ if ( CheckDate(endDay,endMonth,endYear) == false ) {
+ Popup::Error( _("Illegal end date entered. Please retry.") );
+ continue;
+ }
+
+ string start_day = tostring(startDay);
+ string start_month = tostring(startMonth);
+ string start_year = tostring(startYear);
+ string end_day = tostring(endDay);
+ string end_month = tostring(endMonth);
+ string end_year = tostring(endYear);
+
+ Settings["startday"] = tostring(start_day);
+ Settings["startmonth"] = tostring(start_month);
+ Settings["startyear"] = tostring(start_year);
+ Settings["endday"] = tostring(end_day);
+ Settings["endmonth"] = tostring(end_month);
+ Settings["endyear"] = tostring(end_year);
+ Settings["starttime"] = start_time;
+ Settings["endtime"] = end_time;
+
+ }
+
+ string expType = (string) UI::QueryWidget(`id(`expType), `Value);
+ string expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
+
+ if ( expType == _("csv") ) {
+ Settings["exporttext"] = "1";
+ } else if ( expType == _("html") ) {
+ Settings["exporthtml"] = "1";
+ } else if ( expType == _("Both") ) {
+ Settings["exporttext"] = "1";
+ Settings["exporthtml"] = "1";
+ }
+
+ Settings["exportPath"] = expPath;
+
+ break;
+ }
+ }
+
+ return Settings;
+}
+
+define term displayEmptyRep(string type) {
+
+ string myLabel = "";
+ string myInfo = "";
+
+ if ( type == "noDb" ) {
+ myLabel = _("Events DB Not Initialized.");
+ myInfo = _("The events database has not been populated. No records exist.");
+ } else if ( type == "noList" ) {
+ myLabel = _("Query Returned Empty List.");
+ myInfo = _("The events database has no records that match the search query.");
+ }
+
+ term newPage =
+
+ `Frame( `id(`newpage), myLabel,
+
+ `VBox(
+ //`Label(myLabel),
+ `HBox(
+ `VSpacing(10),
+ `Label( myInfo ),
+ `VSpacing(0.5)
+ ),
+ `HSpacing(`opt(`hstretch), 1.0),
+ `VSpacing(1)
+ ));
+
+
+ return newPage;
+}
+
+define term displayRep(string type, integer curPage, string slastPage, list reportList ) {
+
+ string myLabel = "";
+ string currentPage = tostring(curPage);
+ term myTable = nil;
+
+ if (type == "onDemand" || type == "sir") {
+ // Very poor i18n here
+ myLabel = _("On Demand Event Report - Page ") + currentPage + _(" of ") + slastPage;
+ myTable = makeSirTable(reportList);
+
+ } else if (type == "archRep") {
+
+ myLabel = _("Archived Event Report - Page ") + currentPage + _(" of ") + slastPage;
+ myTable = makeSirTable(reportList);
+
+ } else if (type == "aud" || type == "audRep" ) {
+
+ myLabel = _("Applications Audit Report");
+ myTable = `Table(`id(`table), `opt(`notify, `immediate ),
+ `header(_("Host"), _("Date"), _("Program"),
+ _("Profile"), _("PID"), _("State"), _("Type") ), reportList);
+
+ } else if (type == "ess" || type == "essRep" ) {
+ if (reportList == nil) {
+ myLabel = _("Executive Security Summary");
+ myTable = `Table(`id(`table), `opt(`notify),
+ `header(_("Query Results")), _("No event information exists."));
+
+ } else {
+ myLabel = _("Executive Security Summary");
+ myTable = `Table(`id(`table), `opt(`notify, `immediate ),
+ `header(_("Host"), _("Start Date"),_("End Date"), _("Num Rejects"),
+ _("Num Events"), _("Ave. Sev"), _("High Sev") ), reportList);
+ }
+ }
+
+ term newPage =
+
+ `Frame( `id(`newpage), myLabel,
+
+ `VBox(
+ `HBox(
+ `VSpacing(10),
+ myTable,
+ `VSpacing(0.5)
+ ),
+ `HSpacing(`opt(`hstretch), 1.0),
+ `VSpacing(0.5),
+ `HBox(
+ `PushButton(`id(`first), _("F&irst Page") ),
+ `PushButton(`id(`prev), _("&Previous") ),
+ `PushButton(`id(`psort), _("&Sort") ),
+ `PushButton(`id(`fwd), _("&Forward") ),
+ `PushButton(`id(`last), _("&Last Page") ),
+ `PushButton(`id(`goto), _("&Go to Page") )
+ ),
+ `VSpacing(1)
+ ));
+
+ return newPage;
+}
+
+
+// View Archived Reports
+define symbol displayArchForm() {
+
+ map archType = $[ ];
+ archType["sirRep"] = true;
+ archType["audRep"] = false;
+ archType["essRep"] = false;
+
+ map Settings = $[ ];
+ string readSched = "1";
+ Settings["getcron"] = "0";
+ Settings["readSched"] = "1";
+ Settings["type"] = "sirRep";
+ string type = Settings["type"]:nil;
+
+ list itemList = [];
+ itemList = getArrayList(type,"");
+
+ Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
+ viewForm(archType, itemList, ""), archHelpText, Label::BackButton(), _("&Done") );
+
+ map event = $[];
+ any archId = nil;
+
+ string repPath = "";
+ integer lastPage = 1;
+ integer curPage = 1;
+
+ string formHelp = runHelp;
+
+
+ while( true ) {
+
+ event = UI::WaitForEvent( );
+
+ archId = event["ID"]:nil; // We'll need this often - cache it
+
+ if (archId == `back || archId == `abort || archId == `done) {
+ break;
+ } else if ( archId == `close || archId == `cancel || archId == `next) {
+ break;
+
+ } else if ( archId == `repPath ) {
+
+ repPath = (string) UI::QueryWidget(`id(`repPath), `Value);
+ Settings["repPath"] = repPath;
+ itemList = getArrayList(type,repPath);
+ Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
+ viewForm(archType, itemList, repPath), archHelpText, Label::BackButton(), _("&Done") );
+
+ } else if ( archId == `browse ) {
+
+ string selectFile = "";
+ selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
+
+ if ( selectFile != nil ) {
+ UI::ChangeWidget(`id(`repPath), `Value, selectFile);
+ // set new reppath
+ repPath = selectFile;
+ Settings["repPath"] = repPath;
+ itemList = getArrayList(type,repPath);
+ Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
+ viewForm(archType, itemList, repPath), archHelpText, Label::BackButton(),
+ _("&Done") );
+ }
+
+
+ } else if ( archId == `sirRep ) {
+ formHelp = sirHelp;
+ archType["sirRep"] = true;
+ archType["audRep"] = false;
+ archType["essRep"] = false;
+ Settings["type"] = "sirRep";
+ type = Settings["type"]:nil;
+
+ itemList = getArrayList(type,repPath);
+
+ Wizard::SetContentsButtons( _("View Archived SIR Report"),
+ viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
+
+ } else if ( archId == `audRep ) {
+ formHelp = audHelp;
+ archType["sirRep"] = false;
+ archType["audRep"] = true;
+ archType["essRep"] = false;
+ Settings["type"] = "audRep";
+ type = Settings["type"]:nil;
+
+ itemList= getArrayList(type,"");
+ Wizard::SetContentsButtons( _("View Archived AUD Report"),
+ viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
+
+ } else if ( archId == `essRep ) {
+ formHelp = essHelp;
+ archType["sirRep"] = false;
+ archType["audRep"] = false;
+ archType["essRep"] = true;
+ Settings["type"] = "essRep";
+ type = Settings["type"]:nil;
+
+ itemList= getArrayList(type,"");
+ Wizard::SetContentsButtons( _("View Archived ESS Report"),
+ viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
+
+
+ } else if ( archId == `view || archId == `viewall || archId == `table) {
+
+ if ( archId == `viewall ) {
+ Settings["single"] = "0";
+ } else {
+ Settings["single"] = "1";
+ }
+
+ integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
+ string logFile = (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, "");
+ string logPath = (string) UI::QueryWidget(`id(`repPath), `Value);
+ list splitPath = splitstring (logPath, "/");
+ string checkPath = splitPath[size(splitPath)-1]:"";
+
+ string longLogName = "";
+
+
+ // Cat strings & check for trailing "/" in path
+ if ( logPath != "" ) {
+ if ( checkPath != "" ) {
+ longLogName = logPath + "/" + logFile;
+ } else {
+ longLogName = logPath + logFile;
+ }
+ }
+
+ if ( type == "sirRep" ) {
+
+ formHelp = sirHelp;
+ map sirSettings = nil;
+ sirSettings = setArchFilter();
+ if ( archId == `viewall ) { sirSettings["single"] = 0; }
+
+ // Force an exit if appropriate
+ any breakCheck = sirSettings["break"]:nil;
+
+ if ( breakCheck == "abort" ) {
+ symbol myBreak = `abort;
+ return myBreak;
+
+ } else if ( breakCheck == "back" ) {
+ symbol myBreak = `back;
+ return myBreak;
+ }
+
+ if ( repPath != "" ) {
+ sirSettings["repPath"] = repPath;
+ }
+
+ Wizard::SetContentsButtons( _("Security Incident Report"),
+ viewArchForm(type,logFile,sirSettings), sirHelp, Label::BackButton(), _("&Done"));
+
+ lastPage = getLastPage(type,Settings,""); // check 'name'
+ setPageButtons(curPage,lastPage);
+
+ } else if ( type == "audRep" ) {
+
+ formHelp = audHelp;
+ list reportList = [];
+ integer key = 1;
+ Settings["page"] = "1";
+ Settings["audArch"] = "1";
+ Settings["turnPage"] = "1";
+ Settings["file"] = logFile;
+
+ list
Edit Entry:
Edit the selected entry.
");
-
- /* help text */
- string help8 = _("Delete Entry:
Removes the selected entry from this profile.
");
-
- /* help text - part y1 */
- string help9 = _("*Clean Exec
The Clean Exec option for the discrete profile
-and unconstrained execute permissions provide added security by stripping the environment
-that is inherited by the child program of specific variables. These variables are:");
- /* help text - part y2 */
- string help10 = "
- GCONV_PATH
- GETCONF_DIR
- HOSTALIASES
- LD_AUDIT
- LD_DEBUG
- LD_DEBUG_OUTPUT
- LD_DYNAMIC_WEAK
- LD_LIBRARY_PATH
- LD_ORIGIN_PATH
- LD_PRELOAD
- LD_PROFILE
- LD_SHOW_AUXV
- LD_USE_LOAD_BIAS
- LOCALDOMAIN
- LOCPATH
- MALLOC_TRACE
- NLSPATH
- RESOLV_HOST_CONF
- RES_OPTION
- TMPDIR
- TZDIR
";
-
-
- integer listnum = 0;
- list itemList = [ `item( `id( `file ), _("&File") ),
- `item( `id( `net ), _("Network &Rule") ),
- `item( `id( `dir ), _("&Directory") ),
- `item( `id( `cap ), _("&Capability") ),
- `item( `id( `include ), _("&Include File") ),
- ];
-
-
- string mainLabel = "";
-
- if ( hat ) {
- mainLabel = _("AppArmor profile ") + Settings["CURRENT_PROFILE"]:"" + "^" + pathname;
- } else {
- itemList = add(itemList,`item( `id( `hat ), _("&Hat") ));
- mainLabel = _("AppArmor profile for ") + pathname ;
- }
- // Define the widget contents
- // for the Wizard
- term contents_main_profile_form =
- `VBox(
- `Label(mainLabel),
- `HBox(
- `VSpacing(10),
- `Table(`id(`table), `opt(`notify, `immediate ), `header(_("File Name"), _("Permissions")), profilelist)
- ),
- `VSpacing(0.5),
- `HBox(
- `HSpacing(`opt(`hstretch), 0.1),
- `HCenter( `MenuButton(`id(`addMenu), _("Add Entry"), itemList)),
- `HCenter(`PushButton(`id(`edit), _("&Edit Entry"))),
- `HCenter(`PushButton(`id(`delete), _("&Delete Entry"))),
- `HSpacing(`opt(`hstretch), 0.1),
- `VSpacing(1)
- ),
- `VSpacing(1)
- );
- string help = "";
- string formtitle = "";
- if ( hat ) {
- help = help1 + help2 + help3 + help4 + help5 + help6 + help7 + help_net + help8 + helpEdit + help9 + help10;
- formtitle = _("AppArmor Hat Dialog");
- } else {
- help = help1 + help2 + help3 + help4 + help5 + help6 + help7 + help_net + helpHat + helpEdit + help8 + help9 + help10;
- formtitle = _("AppArmor Profile Dialog");
- }
- Wizard::SetContentsButtons( formtitle, contents_main_profile_form, help, Label::BackButton(), _("&Done") );
-
-
-
- map event = $[];
- any id = nil;
- while( true )
- {
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- if ( (( id == `table ) && (event["EventReason"]:nil == "Activated" )) ||
- ( id == `edit) )
- {
- // Widget activated in the table
- string rule = (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, "");
- integer findcap = find( rule, "CAP_");
- integer findinc = find( rule, "#include");
- integer findhat = find( rule, "[+] ^");
- integer findnet = find( rule, "network");
- string oldrule = rule;
- if ( findcap == 0 ) {
- caps = capabilityEntryPopup( caps, rule, pathname );
- profile["allow", "capability"] = caps;
- } else if ( findinc == 0 ) {
- Popup::Error(_("Include entries can not be edited. Please select add or delete to manage Include entries."));
- continue;
- } else if ( findhat == 0 ) {
- string hatToEdit = substring( rule, 5);
- Settings["CURRENT_HAT"] = hatToEdit;
- return `showhat;
- } else if ( findnet == 0 ) {
- string newrule = networkEntryPopup( rule );
- if ( newrule != "" && newrule != rule ) {
- netdomain = editNetworkRule( netdomain, rule, newrule );
- }
- profile["allow","netdomain"] = netdomain;
- } else {
- string perms = (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 2, "");
- map results = fileEntryPopup( rule, perms, pathname );
- integer newperms = 0;
- newperms = (integer) SCR::Execute(.subdomain_profiles.string_to_mode, results["PERM"]:"");
- rule = results["FILE"]:"";
- if ( rule != "" ) {
- if ( rule != oldrule ) {
- paths = remove( paths, oldrule );
- }
- paths = add(paths, rule, $[ "audit": 0, "mode": newperms]);
- profile["allow","path"] = paths;
- }
- }
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- UI::ChangeWidget( `id(`table), `CurrentItem, itemselected );
- } else if ( id == `delete ) {
- string rule = (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, "");
- integer findcap = find( rule, "CAP_");
- integer findinc = find( rule, "#include");
- integer findhat = find( rule, "[+] ^");
- integer findnet = find( rule, "network");
-
- if ( findcap == 0 ) {
- string capNameToDelete = linnametolp[rule]:"";
- caps = remove( caps, capNameToDelete );
- profile["allow", "capability"] = caps;
- } else if ( findinc == 0 ) {
- string includeToRemove = substring( rule, 9);
- includes = remove( includes, includeToRemove );
- profile["include"] = includes;
- } else if ( findhat == 0 ) {
- string hatToRemove = substring( rule, 5);
- hats = remove( hats, hatToRemove);
- profile_map = remove( profile_map, hatToRemove );
- } else if ( findnet == 0 ) {
- netdomain = deleteNetworkRule( netdomain, rule );
- profile["allow","netdomain"] = netdomain;
- } else {
- paths = remove( paths, rule );
- profile["allow","path"] = paths;
- }
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- UI::ChangeWidget( `id(`table), `CurrentItem, (itemselected == 0) ? 0 : itemselected -1 );
- } else if ( id == `file || id == `dir ) {
- string addfname = "";
- integer addperms = 0;
- map newentry = nil;
- if ( id == `dir ) {
- newentry = dirEntryPopup( "", "", pathname );
- } else {
- newentry = fileEntryPopup( "", "", pathname );
- }
- if ( newentry == nil ) {
- continue;
- }
- addfname = newentry["FILE"]:"";
- addperms = (integer) SCR::Execute(.subdomain_profiles.string_to_mode, newentry["PERM"]:"");
- // Make sure that the entry doesn't already exist
- paths = add( paths, addfname, $["audit":0, "mode": addperms] );
- profile["allow","path"] = paths;
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- UI::ChangeWidget( `id(`table), `CurrentItem, itemselected );
- } else if ( id == `cap ) {
- caps = capabilityEntryPopup( caps, "", pathname );
- profile["allow","capability"] = caps;
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- } else if ( id == `hat ) {
- if ( hat ) {
- Popup::Error(_("Hats can not have embedded hats."));
- }
- boolean hatCreated = newHatNamePopup( pathname, hats );
- if ( hatCreated == true ) {
- return `showhat;
- }
- } else if ( id == `include ) {
- list customIncludes = (list ) SCR::Read(.subdomain, "custom-includes");
- string newInclude = UI::AskForExistingFile( "/etc/apparmor.d/abstractions", "", _("Select File To Include"));
- if ( newInclude == nil || (string)newInclude == "" ) {
- continue;
- }
- list validIncludes = [ "/etc/apparmor.d/abstractions", "/etc/apparmor.d/program-chunks", "/etc/apparmor.d/tunables" ];
- foreach( string incPath, customIncludes, {
- validIncludes = add( validIncludes, "/etc/apparmor.d/" + incPath);
- });
-
- integer result = 0;
- boolean includePathOK = false;
- foreach( string pathToCheck, (list) validIncludes, {
- result = find (newInclude, pathToCheck);
- if ( result != -1 ) {
- includePathOK = true;
- }
- });
-
- if ( ! includePathOK ) {
- string pathListMsg = "";
- foreach( string pathItem, (list) validIncludes, {
- pathListMsg = pathListMsg + "\n " + pathItem;
- });
- Popup::Error(_("Invalid #include file. Include files must be located in one of these directories: \n") + pathListMsg );
- } else {
- string includeName = substring(newInclude, 16 );
- includes = add( includes, includeName, 1 );
- profile["include"] = includes;
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- }
- } else if ( id == `net ) {
- string newrule = networkEntryPopup( "" );
- if ( newrule != "" ) {
- netdomain = addNetworkRule( netdomain, newrule );
- profile["allow","netdomain"] = netdomain;
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- list profilelist = generateTableContents( paths,
- netdomain,
- caps,
- includes,
- hats );
- UI::ChangeWidget( `id(`table), `Items, profilelist );
- }
- } else if ( id == `abort || id == `cancel ) {
- break;
- } else if ( id == `back ) {
- break;
- } else if ( id == `next ) {
- if ( ! hat ) {
- if (Popup::YesNoHeadline(_("Save changes to the Profile"),
- _("Would you like to save the changes to this profile? \n(Note: after saving the changes the AppArmor profiles will be reloaded.)"))) {
- map argmap = $[ "PROFILE_HASH" : Settings["PROFILE_MAP"]:$[],
- "PROFILE_NAME" : pathname
- ];
- any result = SCR::Write(.subdomain_profiles, argmap);
- any result2 = SCR::Write(.subdomain_profiles.reload, "-");
- }
- } else {
- if ( ! haskey(hats, Settings["CURRENT_HAT"]:"") ) {
- profile["allow","path"] = paths;
- profile["allow","capability"] = caps;
- profile["include"] = includes;
- profile_map[pathname] = profile;
- Settings["PROFILE_MAP"] = profile_map;
- }
- return `next;
- }
- break;
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
- }
- return (symbol) id;
-}
-
-
- //
- // Select a profile to edit and populate
- // Settings["CURRENT_PROFILE"]: profile name
- // Settings["PROFILE_MAP"]: map containing the profile
- //
-define symbol SelectProfileForm( map profiles, string formhelp, string formtitle, string iconname ) {
- list profilelisting = [];
- integer indx = 0;
- foreach( string p, any ignore, (map) profiles, {
- profilelisting = add( profilelisting, `item( `id(p), p));
- indx = indx+1;
- });
-
- term contents_select_profile_form =
- `VBox(
- `VSpacing(2),
- `SelectionBox( `id(`profilelist), `opt(`notify), _("Profile Name"), profilelisting ),
- `VSpacing(3)
- );
-
- //
- // Create the Dialog Window and parse user input
- //
- Wizard::CreateDialog();
- Wizard::SetContents( formtitle, contents_select_profile_form, formhelp, false, true );
- Wizard::SetTitleIcon(iconname);
-
- map event = $[];
- any id = nil;
- string profilename = "";
- while( true )
- {
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
- if ( id == `next || id == `profilelist ) {
- profilename = tostring( UI::QueryWidget(`id(`profilelist), `CurrentItem) );
- if ( profilename != nil && profilename != "" ) {
- break;
- } else {
- Popup::Error(_("You must select a profile to edit"));
- continue;
- }
- } // TODO ELSE POPUP NO ENTRY SELECTED ERROR
- if(id == `abort || id == `cancel) {
- break;
- } else if(id == `back) {
- break;
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
- }
- if ( id == `next || id == `profilelist) {
- Settings["CURRENT_PROFILE"] = profilename;
- Settings["PROFILE_MAP"] = profiles[profilename]:nil;
- id = `next;
- }
- UI::CloseDialog();
- return (symbol) id;
- }
-
-}
-
--- a/src/include/subdomain/report_helptext.ycp
+++ /dev/null
@@ -1,158 +0,0 @@
-/* ------------------------------------------------------------------
-*
-* Copyright (C) 2002-2005 Novell/SUSE
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of version 2 of the GNU General Public
-* License published by the Free Software Foundation.
-*
- ------------------------------------------------------------------*/
-
-{
-
-textdomain "yast2-apparmor";
-
-string defs = _("Program Name Pattern:
When you enter a program name or pattern
-that matches the name of the binary executable of the program of
-interest, the report will display security events that have
-occurred for a specific program.
") +
-
-_("Profile Name Pattern: When you enter the name of the profile,
-the report will display the security events that are generated for
-the specified profile. You can use this to see what is being confined
-by a specific profile.
") +
-
-_("PID Number: Process ID number is a number that uniquely identifies
-one specific process or running program (this number is valid only
-during the lifetime of that process).
") +
-
-_("Severity Level: Select the lowest severity level for security
-events that you would like to be included in the report. The selected
-severity level, and above, will be included in the reports.
") +
-
-_("Detail: A source to which the profile has denied access.
-This includes capabilities and files. You can use this field to
-report the resources are not allowed to be accessed by profiles.
") +
-
-_("Mode: The Mode is the permission that the profile grants
-to the program or process to which it is applied. The options are:
-r (read) w (write) l (link) x (execute)
") +
-
-_("Access Type: The access type describes what is actually happening
-with the security event. The options are: PERMITTING, REJECTING,
-or AUDITING.
") +
-
-_("CSV or HTML: Enables you to export a CSV (comma separated
-values) or html file. The CSV file separates pieces of data in
-the log entries with commas using a standard data format for
-importing into table-oriented applications. You can enter a
-pathname for your exported report by typing in the full
-pathname in the field provided.");
-
-string setArchHelp = _("The Report Configuration dialog enables you to filter the archived
-report selected in the previous screen. To filter by Date Range:") +
-
-_("
- Click Filter By Date Range. The fields become active.
-- Enter the start and end dates that delineate the scope of the report.
- - Enter other filtering parameters. See below for definitions of parameters.
") +
-
-_("The following definitions help you to enter the filtering parameters in the
-Report Configuration Dialog:
") + defs;
-
-
-string types = _("Executive Security Summary: A combined report,
-consisting of one or more Security incident reports from
-one or more machines. This report provides a single view of
-security events on multiple machines.
") +
-
-_("Applications Audit Report: An auditing tool that
-reports which application servers are running and whether
-the applications are confined by AppArmor. Application
-servers are applications that accept incoming network connections.
") +
-
-_("Security Incident Report: A report that displays application
-security for a single host. It reports policy violations for locally
-confined applications during a specific time period. You can edit and
-customize this report, or add new versions.");
-
-string runHelp = _("The AppArmor On-Demand Report screen displays
-an instantly generated version of one of the following
-reports:
") + types;
-
-
-string filterCfHelp1 = setArchHelp;
-/* START Help Section
-************************************************************/
-
-string repGenHelpText = _("
Generate Reports Help
If there were, in fact,
-going to be any help for you (which, incidentally, there isn't going to be),
-then you would indeed find said help, here.
Thank you for your time,
-and have a nice day.
");
-
-
-
-string schedHelpText =
-_("The summary of scheduled reports page shows us when reports are scheduled to run.
-Reports can be set to run monthly, weekly, daily, or hourly. The default settings are
-daily at midnight. The reports can also be emailed, upon completion, to up to three
-email recipients.
") +
-
-_("In the Set Schedule section, you can schedule the following three types of security reports:
") + types;
-
-string archHelpText = _("
The View Archive Reports form enables you to view
-previously generated reports, located in the /var/log/apparmor/reports-archived
-directory. The checkboxes at the top of the form enable you to narrow-down
-the category of reports shown in the list to the following: SIR Reports, AUD
-Reports, or ESS Reports. To see report details, select a report and click the
-View button.
You can view reports from one or more systems if
-you move the reports to the /var/log/apparmor/reports-archived directory.
");
-
-string mainHelp = schedHelpText;
-
-
-list helpList = [ schedHelpText ];
-
-term defaultHelp = `RichText ( schedHelpText );
-term schedHelp = `RichText ( schedHelpText );
-term repGenHelp = `RichText ( repGenHelpText );
-term archHelp = `RichText ( archHelpText );
-term otherHelp = `RichText ( archHelpText );
-
-string repConfHelp = _("repConfHelp");
-
-string sirHelp = _("Security Incident Report (SIR): A report that displays security
-events of interest to an administrator. The SIR reports policy violations
-for locally confined applications during the specified time period. The SIR
-reports policy exceptions and policy engine state changes. These two types
-of security events are defined as follows:") +
-
-_("
- Policy Exceptions: When an application requests a resource
-that's not defined within its profile, a security event is generated.
-- Policy Engine State Changes: Enforces policy for applications and
-maintains its own state, including when engines start or stop, when a policy
-is reloaded, and when global security feature are enabled or disabled.
-Select the report from the archive, then View to see the report details.");
-
-
-string audHelp = _("Applications Audit Report (AUD): An auditing tool
-that reports which application servers are running and whether they are confined
-by AppArmor. Application servers are applications that accept incoming network
-connections. This report provides the host machine's IP Address, the date the
-Applications Audit Report ran, the name and path of the unconfined program or
-application server, the suggested profile or a placeholder for a profile for an
-unconfined program, the process ID number, The state of the program (confined or
-unconfined), and the type of confinement that the profile is performing
-(enforce/complain).
");
-
-string essHelp = _("Executive Security Summary (ESS): A combined report,
-consisting of one or more high-level reports from one or more machines. This
-report can provide a single view of security events on multiple machines if each
-machine's data is copied to the reports archive directory, which is
-/var/log/apparmor/reports-archived. This report provides the host
-machine's IP address, the start and end dates of the polled events, total number
-of rejects, total number of events, average of severity levels reported, and the
-highest severity level reported. One line of the ESS report represents a range
-of SIR reports.
");
-
-}
-
--- a/src/include/subdomain/reporting_archived_dialogs.ycp
+++ /dev/null
@@ -1,307 +0,0 @@
-/* ------------------------------------------------------------------
-*
-* Copyright (C) 2002-2005 Novell/SUSE
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of version 2 of the GNU General Public
-* License published by the Free Software Foundation.
-*
- ------------------------------------------------------------------*/
-
-{
-
-import "Wizard";
-import "Popup";
-import "Label";
-include "subdomain/report_helptext.ycp";
-include "subdomain/reporting_utils.ycp";
-textdomain "yast2-apparmor";
-
-// Global
-integer timeout_millisec = 20 * 1000;
-
-//define term turnReportPage (integer curPage) {
-define term turnArchReportPage (integer curPage, integer lastPage) {
-
- map Settings = $[ ];
- list reportList = [];
-
- string currentPage = tostring( curPage );
- string slastPage = tostring( lastPage );
- Settings["page"] = currentPage;
- Settings["turnArch"] = "1";
- Settings["turnPage"] = "1";
-
- reportList = getReportList("sir",Settings);
-
- // poor i18n
- string myLabel = _("Archived Security Incident Report - Page ") + currentPage + _(" of ") + slastPage;
-
- term odForm =
-
- `Frame( `id(`odframe), myLabel,
-
- `VBox(
- `HBox(
- `VSpacing(10),
- makeSirTable(reportList),
- `VSpacing(0.5)
- ),
- `HSpacing(`opt(`hstretch), 1.0),
- `VSpacing(0.5),
- `HBox(
- `PushButton(`id(`first), _("F&irst") ),
- `PushButton(`id(`prev), _("&Previous") ),
- `PushButton(`id(`psort), _("&Sort") ),
- `PushButton(`id(`fwd), _("&Forward") ),
- `PushButton(`id(`last), _("&Last") )
- ),
- `VSpacing(1)
- ));
-
- return odForm;
-}
-
-define term filterArchForm() {
-
- string expPath = "/var/log/apparmor/reports-exported";
-
- term arForm =
-
- `Top(`VBox(
- `Left( `CheckBox( `id(`bydate), `opt(`notify), _("Filter By Date Range") )),
- `Frame( `id(`bydate_frame), _(" Select Date Range ") ,
- `VBox(
- `Label( _("Enter Starting Date/Time") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`startHours), _("Hours"), 0, 23, 0),
- `IntField(`id(`startMins), _("Minutes"), 0, 59, 0),
- `IntField(`id(`startDay), _("Day"), 1, 31, 1),
- `IntField(`id(`startMonth), _("Month"), 1, 12, 1),
- `IntField(`id(`startYear), _("Year"), 2005, 2020, 2005)
- ),
- `VSpacing(1.0),
- `Label( _("Enter Ending Date") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`endHours), _("Hours"), 0, 23, 0),
- `IntField(`id(`endMins), _("Minutes"), 0, 59, 0),
- `IntField(`id(`endDay), _("Day"), 1, 31, 1),
- `IntField(`id(`endMonth), _("Month"), 1, 12, 1),
- `IntField(`id(`endYear), _("Year"), 2005, 2020, 2005)
- ),
- `VSpacing(1.0)
- )),
- `VSpacing( 1.0 ),
- `HBox(
- `HWeight( 4, `TextEntry(`id(`prog), _("Program name") )),
- `HWeight( 4, `TextEntry(`id(`prof), _("Profile name") )),
- `HWeight( 3, `TextEntry(`id(`pid), _("PID number") )),
- `HWeight( 2,
- `ComboBox(`id(`sev), _("Severity"), [
- _("All"), _("U"), "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"
- ]) ),
- `HSpacing( `opt(`hstretch), 5)
- ),
- `HBox(
- `HWeight( 3, `TextEntry(`id(`res), _("Detail") )),
- `HWeight( 3, `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), _("Access Type: R") ))),
- `HWeight( 3, `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), _("Mode: All") ))),
- `HSpacing( `opt(`hstretch), 5)
- ),
- `VSpacing( 0.5 ),
-
- `HBox(
- `VSpacing(0.5),
- `ComboBox(`id(`expType), `opt(`notify, `immediate), _("Export Type"), [
- _("None"), _("csv"), _("html"), _("Both")
- ]),
- `TextEntry(`id(`expPath), _("Location to store log."), expPath ),
- `Bottom( `VWeight( 1, `PushButton(`id(`accept), Label::AcceptButton()) )),
- `Bottom( `VWeight( 1, `PushButton(`id(`browse), _("&Browse")) ))
- )
- ));
-
- return arForm;
-}
-
-define map setArchFilter() {
-
- map Settings = $[];
-
- term archForm = filterArchForm();
- Wizard::SetContentsButtons( _("Report Configuration Dialog"), archForm,
- setArchHelp, Label::BackButton(), Label::NextButton() );
-
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
-
- string mode = "All";
- string sdmode = "R";
-
- map event = $[];
- any id = nil;
-
- while ( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `bydate ) {
-
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, true);
-
- } else if ( id == `next || id == `save ) {
-
- boolean bydate = (boolean) UI::QueryWidget(`id(`bydate), `Value);
-
- if ( bydate == true ) {
-
- integer startDay = (integer) UI::QueryWidget(`id(`startDay), `Value);
- integer startMonth = (integer) UI::QueryWidget(`id(`startMonth), `Value);
- integer startYear = (integer) UI::QueryWidget(`id(`startYear), `Value);
- integer startHours = (integer) UI::QueryWidget(`id(`startHours), `Value);
- integer startMins = (integer) UI::QueryWidget(`id(`startMins), `Value);
- integer endDay = (integer) UI::QueryWidget(`id(`endDay), `Value);
- integer endMonth = (integer) UI::QueryWidget(`id(`endMonth), `Value);
- integer endYear = (integer) UI::QueryWidget(`id(`endYear), `Value);
- integer endHours = (integer) UI::QueryWidget(`id(`endHours), `Value);
- integer endMins = (integer) UI::QueryWidget(`id(`endMins), `Value);
-
- // start_day & start_month are mutually exclusive
- if ( id == `startDay ) {
- UI::ChangeWidget(`id(`startMonth), `Value, 0);
- } else if ( id == `startMonth ) {
- UI::ChangeWidget(`id(`startDay), `Value, 0);
- }
-
- // start_day & start_month are mutually exclusive
- if ( id == `endDay ) {
- UI::ChangeWidget(`id(`endMonth), `Value, 0);
- } else if ( id == `endMonth ) {
- UI::ChangeWidget(`id(`endDay), `Value, 0);
- }
-
- if ( CheckDate(startDay,startMonth,startYear) == false ) {
- Popup::Error( _("Illegal start date entered. Please retry.") );
- continue;
- }
-
- if ( CheckDate(endDay,endMonth,endYear) == false ) {
- Popup::Error( _("Illegal end date entered. Please retry.") );
- continue;
- }
- ////////////////////////////////////////////////////////////
-
- string startday = tostring(startDay);
- string startmonth = tostring(startMonth);
- string startyear = tostring(startYear);
- string starthours = tostring(startHours);
- string startmins = tostring(startMins);
- string endday = tostring(endDay);
- string endmonth = tostring(endMonth);
- string endyear = tostring(endYear);
- string endhours = tostring(endHours);
- string endmins = tostring(endMins);
-
- Settings["startday"] = startday;
- Settings["startmonth"] = startmonth;
- Settings["startyear"] = startyear;
- Settings["endday"] = endday;
- Settings["endmonth"] = endmonth;
- Settings["endyear"] = endyear;
- Settings["starttime"] = starthours + ":" + startmins;
- Settings["endtime"] = endhours + ":" + endmins;
-
- }
-
- string expType = (string) UI::QueryWidget(`id(`exportType), `Value);
- string expPath = (string) UI::QueryWidget(`id(`exportPath), `Value);
-
- if ( expType != "" && expType != "None" ) {
-
- if ( expType == "csv" ) {
- Settings["exporttext"] = "true";
- } else if ( expType == "html" ) {
- Settings["exporthtml"] = "true";
- } else if ( expType == "both" ) {
- Settings["exporttext"] = "true";
- Settings["exporthtml"] = "true";
- }
- }
-
- string program_name = (string) UI::QueryWidget(`id(`prog), `Value);
- string profile = (string) UI::QueryWidget(`id(`prof), `Value);
- string pid = (string) UI::QueryWidget(`id(`pid), `Value);
- string sev = (string) UI::QueryWidget(`id(`sev), `Value);
- string res = (string) UI::QueryWidget(`id(`res), `Value);
- string sdmode = (string) UI::QueryWidget(`id(`sdmode), `Label);
- string mode = (string) UI::QueryWidget(`id(`mode), `Label);
- string exppath = (string) UI::QueryWidget(`id(`expPath), `Value);
-
- if (sdmode == "-") { sdmode = "All"; }
- if (mode == "-") { mode = "All"; }
-
- if ( program_name != "" ) { Settings["prog"] = program_name; }
- if ( profile != "" ) { Settings["profile"] = profile; }
- if ( pid != "" ) { Settings["pid"] = pid; }
- if ( sev != "" && sev != "All" ) { Settings["severity"] = sev; }
- if ( res != "" ) { Settings["resource"] = res; }
- if ( sdmode != "" ) { Settings["sdmode"] = sdmode; }
- if ( mode != "" ) { Settings["mode"] = mode; }
- if ( exppath != "" ) { Settings["exportPath"] = exppath; }
-
- id = nil;
- break;
-
- } else if ( id == `sdmode ) {
- sdmode = popUpSdMode();
- Settings["sdmode"] = sdmode;
- UI::ReplaceWidget(`id(`replace_sdmode), `PushButton(`id(`sdmode), _("Access Type: ") + sdmode) );
-
- } else if ( id == `mode ) {
- mode = popUpMode();
- Settings["mode"] = mode;
- UI::ReplaceWidget(`id(`replace_mode), `PushButton(`id(`mode), _("Mode: ") + mode) );
-
- } else if ( id == `abort || id == `cancel || id == `done ) {
- Settings["break"] = "abort";
- break;
- } else if ( id == `close || id == `back) {
- Settings["break"] = "back";
- break;
- }
- }
-
- return Settings;
-}
-
-define term viewArchForm(string tab, string logFile, map Settings) {
-
- Settings["archRep"] = "1";
- Settings["logFile"] = logFile;
- Settings["type"] = "archRep";
-
- integer curPage = 1;
- string currentPage = "1";
- Settings["currentPage"] = currentPage;
-
- integer isingle = Settings["single"]:1;
- string single = "1";
- if ( isingle != nil ) {
- single = tostring(isingle);
- }
- Settings["single"] = single;
-
- // mark - new
- any junk = SCR::Read(.logparse,Settings);
-
- integer lastPage = getLastPage("sirRep",Settings,"");
- term myPage = turnArchReportPage(curPage,lastPage);
-
- return myPage;
-}
-
-
-}
-
--- a/src/include/subdomain/reporting_dialogues.ycp
+++ /dev/null
@@ -1,2513 +0,0 @@
-/* ------------------------------------------------------------------
-*
-* Copyright (C) 2002-2005 Novell/SUSE
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of version 2 of the GNU General Public
-* License published by the Free Software Foundation.
-*
- ------------------------------------------------------------------*/
-{
-
-import "Wizard";
-import "Popup";
-import "Label";
-include "subdomain/reporting_utils.ycp";
-include "subdomain/report_helptext.ycp";
-include "subdomain/reporting_archived_dialogs.ycp";
-textdomain "yast2-apparmor";
-
-// Globalz
-//integer timeout_millisec = 20 * 1000;
-map Settings = $[ ];
-string defExpPath = "/var/log/apparmor/reports-exported";
-string oldExpPath = "/var/log/apparmor/reports-exported";
-string expPath = oldExpPath;
-
-// This map is to pull the string to send back to the backend agent on save
-map md_map= $[
- `md_00: _("All"),
- `md_01: "1", `md_02: "2", `md_03: "3",
- `md_04: "4", `md_05: "5", `md_06: "6",
- `md_07: "7", `md_08: "8", `md_09: "9",
- `md_10: "10", `md_11: "11", `md_12: "12",
- `md_13: "13", `md_14: "14", `md_15: "15",
- `md_16: "16", `md_17: "17", `md_18: "18",
- `md_19: "19", `md_20: "20", `md_21: "21",
- `md_22: "22", `md_23: "23", `md_24: "24",
- `md_25: "25", `md_26: "26", `md_27: "27",
- `md_28: "28", `md_29: "29", `md_30: "30",
- `md_31: "31" ];
-
-string modeToHumanString( string mode) {
- return ( mode == "All") ? _("All") : mode;
-}
-
-string humanStringToMode( string hs) {
- return ( hs == _("All")) ? "All" : hs ;
-}
-
-string typeToHumanString( string type ) {
- string ret = "";
-
- switch ( type )
- {
- case "Security.Incident.Report":
- ret = _("Security Incident Report");
- break;
- case "Applications.Audit":
- ret = _("Applications Audit Report");
- break;
- case "Executive.Security.Summary":
- ret = _("Executive Security Summary");
- break;
- default:
- ret = type;
- break;
- }
-
- return ret;
-}
-
-string humanStringToType( string hs ) {
- string ret = "";
-
- if( hs == _("Security Incident Report"))
- ret = "Security.Incident.Report";
- else if ( hs == _("Applications Audit Report"))
- ret = "Applications.Audit";
- else if ( hs == _("Executive Security Summary"))
- ret = "Executive.Security.Summary";
- else
- ret = hs;
-
- return ret;
-}
-
-// Grey out inappropriate paging buttons
-define void setPageButtons(integer curPage, integer lastPage) {
-
- if (lastPage <= 1 ) {
- UI::ChangeWidget(`id(`first), `Enabled, false);
- UI::ChangeWidget(`id(`last), `Enabled, false);
- UI::ChangeWidget(`id(`prev), `Enabled, false);
- UI::ChangeWidget(`id(`fwd), `Enabled, false);
- UI::ChangeWidget(`id(`goto), `Enabled, false);
-
- } else if (curPage <= 1 ) {
- UI::ChangeWidget(`id(`first), `Enabled, false);
- UI::ChangeWidget(`id(`prev), `Enabled, false);
- } else if ( curPage >= lastPage ) {
- UI::ChangeWidget(`id(`last), `Enabled, false);
- UI::ChangeWidget(`id(`fwd), `Enabled, false);
- } else {
- UI::SetFocus(`id(`goto));
- }
-
- return;
-}
-
-// return input from edit scheduled forms as map of strings
-define map getSchedSettings( map Settings ) {
-
- string name = (string) UI::QueryWidget(`id(`name), `Value);
- //integer iMonthdate = (integer) UI::QueryWidget(`id(`monthdate), `Value);
- any md = (any) UI::QueryWidget(`id(`monthdate), `Value);
- string monthdate = (string) md_map[md]:_("All");
- string weekday = (string) UI::QueryWidget(`id(`weekday), `Value);
- any iHours = (any) UI::QueryWidget(`id(`hour), `Value);
- any iMins = (any) UI::QueryWidget(`id(`mins), `Value);
- string expType = (string) UI::QueryWidget(`id(`expType), `Value);
- string email1 = (string) UI::QueryWidget(`id(`email1), `Value);
- string email2 = (string) UI::QueryWidget(`id(`email2), `Value);
- string email3 = (string) UI::QueryWidget(`id(`email3), `Value);
-
- //string monthdate = tostring( iMonthdate );
- string hour = tostring( iHours );
- string mins = tostring( iMins );
-
- if ( weekday == _("All") ) { weekday = "-"; }
- if ( monthdate == _("All") ) { monthdate = "-"; }
-
- // de-i18n
- if ( weekday == _("Mon") ) { weekday = "Mon"; }
- if ( weekday == _("Tue") ) { weekday = "Tue"; }
- if ( weekday == _("Weds") ) { weekday = "Weds"; }
- if ( weekday == _("Thu") ) { weekday = "Thu"; }
- if ( weekday == _("Fri") ) { weekday = "Fri"; }
- if ( weekday == _("Sat") ) { weekday = "Sat"; }
- if ( weekday == _("Sun") ) { weekday = "Sun"; }
-
- Settings["getconf"] = "";
- Settings["setconf"] = "1";
- Settings["name"] = name;
- Settings["monthdate"] = monthdate;
-
- Settings["weekday"] = weekday;
- Settings["hour"] = hour;
- Settings["mins"] = mins;
- if ( expType == _("csv") || expType == _("Both") ) {
- Settings["csv"] = "1";
- } else {
- Settings["csv"] = "0";
- }
-
- if ( expType == _("html") || expType == _("Both") ) {
- Settings["html"] = "1";
- } else {
- Settings["html"] = "0";
- }
-
- Settings["email1"] = email1;
- Settings["email2"] = email2;
- Settings["email3"] = email3;
-
- return Settings;
-}
-
-// Gets list of archived reports based on 'type'
-define list getArrayList(string type, string repPath) {
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["readSched"] = readSched;
- Settings["type"] = type;
-
- if ( repPath != "" ) {
- Settings["repPath"] = repPath;
- }
-
- list itemList = [];
-
- integer key = 1;
-
- if ( type == "sirRep" || type == "essRep" || type == "audRep" ) {
- list db = (list ) SCR::Read (.reports_parse, Settings);
-
- foreach ( map record, db, {
- any strName = record["name"]:nil;
- any strTime = record["time"]:nil;
- string name = tostring(strName);
- string mytime = tostring(strTime);
- itemList = add( itemList, `item( `id(key), record["name"]:nil, record["time"]:nil ));
- key = key + 1;
- });
-
- } else if (type == "schedRep") {
-
- Settings["getcron"] = "1";
-
- list db = (list ) SCR::Read (.reports_sched, Settings);
-
- foreach ( map record, db, {
- itemList = add( itemList, `item( `id(key), record["name"]:nil, record["hour"]:nil, record["mins"]:nil,
- record["wday"]:nil, record["mday"]:nil ));
- key = key + 1;
- });
-
- } else {
-
- Popup::Error( _("Unrecognized form request.") );
-
- }
-
- return itemList;
-}
-
-
-// Filter form for editing scheduled reports
-define term editFilterForm (map Settings) {
-
- /* debug */
- string prog = Settings["prog"]:"";
- string prof = Settings["prof"]:"";
- string pid = Settings["pid"]:"";
- string res = Settings["res"]:"";
- string sdmode = Settings["sdmode"]:"R";
- string mode = Settings["mode"]:"All";
- string sev = Settings["sev"]:"All";
-
- term eForm = `VBox(
-
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 5, `TextEntry(`id(`prog), _("Program name"), prog )),
- `HWeight( 5, `TextEntry(`id(`prof), _("Profile name"), prof )),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 5, `TextEntry(`id(`pid), _("PID number"), pid )),
- `HWeight( 5, `TextEntry(`id(`res), _("Detail"), res )),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 2,
- `ComboBox(`id(`sev), _("Severity"), [
- _("All"), _("U"), "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"
- ]) ),
- `VBox(
- `Label( _("Access Type: ") ),
- `Bottom( `HWeight( 4,
- `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode )))))
- ),
- `VBox(
- `Label( _("Mode: ") ),
- `Bottom( `HWeight( 4,
- `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )))))
- ),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 1 ),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`save), Label::SaveButton() )
- )
- );
-
- return eForm;
-}
-
-term schedFilterForm =
-
- `VBox(
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 5, `TextEntry(`id(`prog), _("Program name") )),
- `HWeight( 5, `TextEntry(`id(`prof), _("Profile name") )),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 5, `TextEntry(`id(`pid), _("PID number") )),
- `HWeight( 5, `TextEntry(`id(`res), _("Detail") ) ),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 0.5 ),
- `HBox(
- `HWeight( 2,
- `ComboBox(`id(`sev), _("Severity"), [
- _("All"), "U", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"
- ]) ),
-
- `VBox(
- `Label( _("Access Type: ") ),
- `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), "R" ))
- ),
- `VBox(
- `Label( _("Mode: ") ),
- `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), _("All") ))
- ),
-
- //`HWeight( 4, `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), _("Access Type: R") ))),
- //`HWeight( 4, `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), _("Mode: All") ))),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 1 ),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`save), Label::SaveButton() )
- )
- );
-
-term filterForm =
-
- `VBox(
- `Left( `CheckBox( `id(`bydate), `opt(`notify), _("Filter By Date Range") )),
- `Frame( `id(`bydate_frame), _(" Select Date Range "),
- `VBox(
- `Label( _("Enter Starting Date/Time") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`startHours), _("Hours"), 00, 23, 00),
- `IntField(`id(`startMins), _("Minutes"), 00, 59, 00),
- `IntField(`id(`startDay), _("Day"), 01, 31, 01),
- `IntField(`id(`startMonth), _("Month"), 01, 12, 01),
- `IntField(`id(`startYear), _("Year"), 2005, 2020, 2005)
- ),
- `VSpacing(1.0),
- `Label( _("Enter Ending Date") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`endHours), _("Hours"), 0, 23, 0),
- `IntField(`id(`endMins), _("Minutes"), 0, 59, 0),
- `IntField(`id(`endDay), _("Day"), 1, 31, 1),
- `IntField(`id(`endMonth), _("Month"), 1, 12, 1),
- `IntField(`id(`endYear), _("Year"), 2005, 2020, 2005)
- )
- ),
- `VSpacing(1.0),
- `HBox(
- `HWeight( 4, `TextEntry(`id(`prog), _("Program name")) ),
- `HWeight( 4, `TextEntry(`id(`prof), _("Profile name")) ),
- `HWeight( 3, `TextEntry(`id(`pid), _("PID number")) ),
- `HWeight( 2,
- `ComboBox(`id(`sev), _("Severity"), [
- _("All"), _("U"), "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"
- ]) ),
- `HSpacing( `opt(`hstretch), 5)
- ),
- `HBox(
- `HWeight( 3, `TextEntry(`id(`res), _("Detail") ) ),
-
- `VBox(
- `Label( _("Access Type: ") ),
- `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), "R" ))
- ),
- `VBox(
- `Label( _("Mode: ") ),
- `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), _("All") ))
- ),
-
-
- //`HWeight( 3, `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), _("Access Type: R") ))),
- //`HWeight( 3, `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), _("Mode: All") ))),
- `HSpacing( `opt(`hstretch), 5)
- ),
- `VSpacing( 0.5 ),
-
- `HBox(
- `VSpacing(0.5),
- // DWR MOD `ComboBox(`id(`expType), `opt(`notify, `immediate), _("Export Type"), [
- `ComboBox(`id(`expType), `opt(`notify), _("Export Type"), [
- _("None"), _("csv"), _("html"), _("Both")
- ]),
- `TextEntry(`id(`expPath), _("Location to store log."), expPath ),
- `Bottom( `VWeight( 1, `PushButton(`id(`browse), _("&Browse")) ))
- )
-
- ));
-
-// filter-defining form
-define term filterForm2(string name, map preFilters) {
-
- any aprog = preFilters["prog"]:nil;
- any aprof = preFilters["profile"]:nil;
- any apid = preFilters["pid"]:nil;
- any ares = preFilters["resource"]:nil;
- any amode = preFilters["mode"]:"All";
- any asdmode = preFilters["sdmode"]:"All";
-
- string prog = "";
- string prof = "";
- string pid = "";
- string res = "";
- string mode = "";
- string sdmode = "";
-
- if ( aprog != nil ) { prog = tostring(aprog); }
- if ( aprof != nil ) { prof = tostring(aprof); }
- if ( apid != nil ) { pid = tostring(apid); }
- if ( ares != nil ) { res = tostring(ares); }
- if ( amode != nil ) { mode = tostring(amode); }
- if ( asdmode != nil ) { sdmode = tostring(asdmode); }
- if (sdmode == "-") { sdmode = "All"; }
- if (mode == "-") { mode = "All"; }
-
- term ff2 =
- `Top(`VBox(
- `Left( `CheckBox( `id(`bydate), `opt(`notify), _("Filter By Date Range") )),
- `Frame( `id(`bydate_frame), _(" Select Date Range "),
- `VBox(
- `Label( _("Enter Starting Date/Time") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`startHours), _("Hours"), 0, 23, 0),
- `IntField(`id(`startMins), _("Minutes"), 0, 59, 0),
- `IntField(`id(`startDay), _("Day"), 1, 31, 1),
- `IntField(`id(`startMonth), _("Month"), 1, 12, 1),
- `IntField(`id(`startYear), _("Year"), 2005, 2020, 2005)
- ),
- `VSpacing(1.0),
- `Label( _("Enter Ending Date") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `IntField(`id(`endHours), _("Hours"), 0, 23, 0),
- `IntField(`id(`endMins), _("Minutes"), 0, 59, 0),
- `IntField(`id(`endDay), _("Day"), 1, 31, 1),
- `IntField(`id(`endMonth), _("Month"), 1, 12, 1),
- `IntField(`id(`endYear), _("Year"), 2005, 2020, 2005)
- ),
- `VSpacing(1.0)
- )),
- `VSpacing( 1.0 ),
- `HBox(
- `HWeight( 4, `TextEntry(`id(`prog), _("Program name"), prog) ),
- `HWeight( 4, `TextEntry(`id(`prof), _("Profile name"), prof) ),
- `HWeight( 3, `TextEntry(`id(`pid), _("PID number"), pid) ),
- `HWeight( 2,
- `ComboBox(`id(`sev), _("Severity"), [
- _("All"), _("U"), "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"
- ]) ),
- `HSpacing( `opt(`hstretch), 5)
- ),
- `HBox(
- `VSpacing(0.5),
- `TextEntry(`id(`res), _("Detail"), res),
- `VBox(
- `Label( _("Access Type: ") ),
- `ReplacePoint(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode )))
- ),
- `VBox(
- `Label( _("Mode: ") ),
- `ReplacePoint(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )))
- )
- ),
- `VSpacing( 0.5 ),
-
- `HBox(
- `VSpacing(0.5),
- `ComboBox(`id(`expType), `opt(`notify), _("Export Type"), [
- _("None"), _("csv"), _("html"), _("Both")
- ]),
- `TextEntry(`id(`expPath), _("Location to store log."), expPath ),
- `Bottom( `VWeight( 1, `PushButton(`id(`browse), _("&Browse")) ))
- )
- ));
-
- return ff2;
-
-}
-
-// Gets data for next or previous page of current report
-define term turnReportPage (string name, integer curPage, string slastPage, map Settings) {
-
- //map Settings = $[ ]; - 07-07
- list reportList = [];
-
- string currentPage = tostring( curPage );
- Settings["name"] = name;
- Settings["page"] = currentPage;
- Settings["turnPage"] = "1";
-
- reportList = getReportList("sir", Settings);
-
- // New map is a list, not a hash
-
- /* Old aa-eventd
- list db = (list ) SCR::Read (.logparse, Settings);
- integer key = 1;
- foreach ( map record, db, {
- reportList = add( reportList, `item( `id(key), record["host"]:nil,
- record["date"]:nil, record["prog"]:nil, record["profile"]:nil,
- record["pid"]:nil, record["severity"]:nil, record["mode"]:nil,
- record["resource"]:nil, record["sdmode"]:nil ));
- key = key + 1;
- });
- */
-
- string myLabel = _("On Demand Event Report - Page ") + currentPage + _(" of ") + slastPage;
-
- term odForm =
-
- `Frame( `id(`odpage), myLabel,
-
- `VBox(
- //`Label("AppArmor Event Report Data " + currentPage ),
- //`Label(myLabel),
-
- `HBox(
- `VSpacing(10),
- // New aa-eventd
- makeSirTable(reportList),
- /* Old aa-eventd
- `Table(`id(`table), `opt(`keepSorting, `immediate ), `header( _("Host"), _("Date"), _("Program"),
- _("Profile"), _("PID"), _("Severity"), _("Mode"), _("Detail"), _("Access Type") ), reportList),
- */
-
- `VSpacing(0.5)
- ),
- `HSpacing(`opt(`hstretch), 1.0),
- `VSpacing(0.5),
- `HBox(
- `PushButton(`id(`first), _("F&irst Page") ),
- `PushButton(`id(`prev), _("&Previous") ),
- `PushButton(`id(`psort), _("&Sort") ),
- `PushButton(`id(`fwd), _("&Forward") ),
- `PushButton(`id(`last), _("&Last Page") ),
- `PushButton(`id(`goto), _("&Go to Page") )
- ),
- `VSpacing(1)
- ));
-
- return odForm;
-}
-
-define symbol reportConfigForm() {
-
- term contents_report_config_form =
- `VBox(
- `VSpacing( 1 ),
- `Left( `CheckBox( `id(`bydate), `opt(`notify), _("Filter By Date Range") )),
- `Frame( `id(`bydate_frame), _(" Select Date Range ") ,
- `VBox(
- `Label( _("Enter Starting Date/Time") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`start_time), _("Time") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`start_day), _("Day") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`start_month), _("Month") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`start_year), _("Year") )),
- `HSpacing( `opt(`hstretch), 1)
- ),
- `VSpacing( 1.0 ),
- `Label( _("Enter Ending Date") ),
- `HBox(
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`end_time), _("Time") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`end_day), _("Day") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`end_month), _("Month") )),
- `HSpacing( `opt(`hstretch), 1),
- `HWeight( 1, `TextEntry(`id(`end_year), _("Year") )),
- `HSpacing( `opt(`hstretch), 1),
- `VSpacing( `opt(`vstretch), 2)
- )
- )),
- `VSpacing( 0.5 ),
- `Left(`CheckBox( `id(`byprog), `opt(`notify), _("Filter By Program Name") )),
- `HBox(`id(`pbox),
- `Left(`TextEntry(`id(`prog), _("Program name") )),
- `HSpacing( `opt(`hstretch), 45)
- ),
- `VSpacing( 0.5 ),
- `Left(`CheckBox( `id(`expLog), `opt(`notify), _("Export Report") )),
- `HBox(`id(`ebox),
- `Left(`TextEntry(`id(`exportName), _("Export File Location") )),
- `Label( _("Select Export Format") ),
- `Left(`CheckBox(`id(`exportText), _("CSV"), false)),
- `Left(`CheckBox(`id(`exportHtml), _("HTML"), true))
- )
- );
- Wizard::SetContentsButtons( _("Report Configuration Dialog"), contents_report_config_form, repConfHelp, Label::BackButton(), Label::NextButton() );
-
- Settings = $[ ];
- map event = $[];
- any id = nil;
- UI::ChangeWidget(`id(`pbox), `Enabled, false);
- UI::ChangeWidget(`id(`ebox), `Enabled, false);
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
- UI::ChangeWidget(`id(`exportName), `Value, "/tmp/export.log");
-
- while( true ) {
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
-
- integer start_day = (integer) UI::QueryWidget(`id(`start_day), `Value);
- integer start_month = (integer) UI::QueryWidget(`id(`start_month), `Value);
- integer start_year = (integer) UI::QueryWidget(`id(`start_year), `Value);
- integer end_day = (integer) UI::QueryWidget(`id(`end_day), `Value);
- integer end_month = (integer) UI::QueryWidget(`id(`end_month), `Value);
- integer end_year = (integer) UI::QueryWidget(`id(`end_year), `Value);
-
- if ( id == `byprog ) {
- boolean val = (boolean) UI::QueryWidget(`id(`byprog), `Value);
- if ( val == true ) {
- UI::ChangeWidget(`id(`pbox), `Enabled, true);
- UI::ChangeWidget(`id(`allevents), `Value, false);
- } else {
- UI::ChangeWidget(`id(`pbox), `Enabled, false);
- }
- } else if ( id == `bydate ) {
- boolean val = (boolean) UI::QueryWidget(`id(`bydate), `Value);
- if ( val == true ) {
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, true);
- UI::ChangeWidget(`id(`allevents), `Value, false);
- } else {
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
- }
- } else if ( id == `expLog ) {
- boolean val = (boolean) UI::QueryWidget(`id(`expLog), `Value);
- if ( val == true ) {
- UI::ChangeWidget(`id(`ebox), `Enabled, true);
- //UI::ChangeWidget(`id(`allevents), `Value, false);
- } else {
- UI::ChangeWidget(`id(`ebox), `Enabled, false);
- }
- } else if ( id == `next ) {
-
- // Setup the data structures.
- boolean bydate = (boolean) UI::QueryWidget(`id(`bydate), `Value);
- boolean byprog = (boolean) UI::QueryWidget(`id(`byprog), `Value);
- boolean allevents = (boolean) UI::QueryWidget(`id(`allevents), `Value);
- boolean expLog = (boolean) UI::QueryWidget(`id(`expLog), `Value);
-
- if ( expLog ) {
- string exportName = (string) UI::QueryWidget(`id(`exportName), `Value);
- any expText = (boolean) UI::QueryWidget(`id(`exportText), `Value);
- any expHtml = (boolean) UI::QueryWidget(`id(`exportHtml), `Value);
- string exportText = tostring( expText );
- string exportHtml = tostring( expHtml );
- Settings["exportname"] = exportName;
- Settings["exporttext"] = exportText;
- Settings["exporthtml"] = exportHtml;
- }
-
- if ( byprog ) {
- string program_name = (string) UI::QueryWidget(`id(`prog), `Value);
- Settings["prog"] = program_name;
- }
-
- if ( bydate ) {
-
- integer start_hour = (integer) UI::QueryWidget(`id(`startHour), `Value);
- integer start_min = (integer) UI::QueryWidget(`id(`startMin), `Value);
- integer startDay = (integer) UI::QueryWidget(`id(`startDay), `Value);
- integer startMonth = (integer) UI::QueryWidget(`id(`startMonth), `Value);
- integer startYear = (integer) UI::QueryWidget(`id(`startYear), `Value);
- integer end_hour = (integer) UI::QueryWidget(`id(`endHour), `Value);
- integer end_min = (integer) UI::QueryWidget(`id(`endMin), `Value);
- integer endDay = (integer) UI::QueryWidget(`id(`endDay), `Value);
- integer endMonth = (integer) UI::QueryWidget(`id(`endMonth), `Value);
- integer endYear = (integer) UI::QueryWidget(`id(`endYear), `Value);
- string start_time = tostring(start_hour) + ":" + tostring(start_min);
- string end_time = tostring(end_hour) + ":" + tostring(end_min);
-
- if ( CheckDate(startDay,startMonth,startYear) == false ) {
- Popup::Error( _("Illegal start date entered. Please retry.") );
- continue;
- }
-
- if ( CheckDate(endDay,endMonth,endYear) == false ) {
- Popup::Error( _("Illegal end date entered. Please retry.") );
- continue;
- }
-
- Settings["startday"] = tostring(startDay);
- Settings["startmonth"] = tostring(startMonth);
- Settings["startyear"] = tostring(startYear);
- Settings["endday"] = tostring(endDay);
- Settings["endmonth"] = tostring(endMonth);
- Settings["endyear"] = tostring(endYear);
- Settings["starttime"] = start_time;
- Settings["endtime"] = end_time;
- }
-
- } else if ( id == `abort || id == `back || id == `done ) {
- Popup::Message( _("Abort or Back") );
- break;
- }
-
- //break;
- }
- return (symbol) id;
-}
-
-// Main Report Form
-define symbol mainArchivedReportForm() {
-
- map reportdata = nil;
- reportdata = (map) SCR::Read (.logparse, Settings );
- list reportlist = [];
-
- foreach( integer key, map repdata, (map) reportdata, {
- reportlist = add( reportlist, `item( `id(key), repdata["date"]:nil, repdata["prof"]:nil, repdata["pid"]:nil, repdata["mesg"]:nil));
- });
-
- string help1 = _("AppArmor Security Events
- This table displays the events found that match your search criteria.");
-
-
- // DBG y2milestone("in MainReportForm");
- term contents_main_prof_form =
- `VBox(
- `Label( _("AppArmor Event Report Data") ),
- `HBox(
- `VSpacing(10),
- `Table(`id(`table), `opt(`notify, `immediate ), `header(_("Date"),
- _("Profile"), _("PID"), _("AppArmor Message") ), reportlist),
- `VSpacing(0.5)
- )
- );
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
- contents_main_prof_form, help1, Label::BackButton(), _("&Done") );
-
-
- map event = $[];
- any id = nil;
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `table ) {
-
- if ( event["EventReason"]:nil == "Activated" ) {
- // Widget activated in the table
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- }
-
- } else if ( id == `abort || id == `cancel || id == `done ) {
- break;
- } else if ( id == `back || id == `next ) {
- break;
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
- }
- return (symbol) id;
-}
-
-// This is the first and base reporting form
-define symbol mainReportForm() {
-
- term mainForm =
-
- `VBox(
- `Label( _("AppArmor Reporting") ),
- `VSpacing(2),
- `VBox(
- `Left(`CheckBox( `id(`schedrep), `opt(`notify), _("Schedule Reports"), true )),
- `Left(`CheckBox( `id(`viewrep), `opt(`notify), _("View Archived Reports") )),
- `Left(`CheckBox( `id(`runrep), `opt(`notify), _("Run Reports") ))
- ),
- `VSpacing(0.5)
- );
-
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"), mainForm, mainHelp, Label::BackButton(), Label::NextButton() );
-
- map event = $[];
- any id = nil;
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `schedrep ) {
- UI::ChangeWidget(`id(`viewrep), `Value, false);
- UI::ChangeWidget(`id(`runrep), `Value, false);
- } else if ( id == `viewrep ) {
- UI::ChangeWidget(`id(`schedrep), `Value, false);
- UI::ChangeWidget(`id(`runrep), `Value, false);
- } else if ( id == `runrep ) {
- UI::ChangeWidget(`id(`schedrep), `Value, false);
- UI::ChangeWidget(`id(`viewrep), `Value, false);
- } else if ( id == `abort || id == `cancel || id == `done ) {
- break;
- } else if ( id == `back ) {
- break;
- } else if ( id == `next ) {
-
- if ( UI::QueryWidget(`id(`schedrep), `Value) == true ) {
- id = `schedrep;
- } else if ( UI::QueryWidget(`id(`viewrep), `Value) == true ) {
- id = `viewrep;
- } else if ( UI::QueryWidget(`id(`runrep), `Value) == true ) {
- id = `runrep;
- }
-
- break;
-
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
- }
-
- return (symbol) id;
-}
-
-// Form used to select the type of archived report to list
-define term viewForm(map archType, list itemList, string repPath) {
-
- boolean sirRep = archType["sirRep"]:false;
- boolean audRep = archType["audRep"]:false;
- boolean essRep = archType["essRep"]:false;
-
- if ( repPath == "" || repPath == nil ) {
- repPath = "/var/log/apparmor/reports-archived/";
- }
-
- if ( audRep == false && essRep == false ) {
- sirRep = true;
- }
-
- term vForm =
- `ReplacePoint(`id(`viewform), `VBox(
- `Label( _("View Archived Reports") ),
- `HSpacing(60), // make the table and thus the dialog wide enough
- `VSpacing(1),
- `HBox(
- `Frame( `id(`radioSelect), _("Choose a Report Type"),
- `RadioButtonGroup(`id(`chooseRep), `HBox(
- `HStretch(),
- `RadioButton(`id(`sirRep), `opt(`notify, `immediate), _("SIR"), sirRep),
- `HSpacing(1),
- `RadioButton(`id(`audRep), `opt(`notify, `immediate), _("App Aud"), audRep),
- `HSpacing(1),
- `RadioButton(`id(`essRep), `opt(`notify, `immediate), _("ESS"), essRep),
- `HSpacing(1),
- `HStretch()
- )))
- ),
- `VSpacing(1),
- `Frame( `id(`repFrame), _("Location of Archived Reports"),
- `HBox(
- `Left(`Label(repPath)),
- `HSpacing(1),
- `Left(`PushButton(`id(`browse), _("&Browse"))),
- `HStretch()
- )
- ),
- `VSpacing(0.5),
- `VWeight( 10, `HBox(
- `VSpacing(1),
- `Table(`id(`table), `opt(`notify, `immediate), `header(_("Report"),
- _("Date") ), itemList ) )
- ),
- `VSpacing(1),
- `HBox(
- `VSpacing(1),
- `PushButton(`id(`view), _("&View") ),
- `PushButton(`id(`viewall), _("View &All") )
- )
- ));
-
- return vForm;
-}
-
-define map filterConfigForm(string name) {
-
- // Cheating way to set filters
- map opts = $[];
- opts["getSirFilters"] = "1";
- opts["name"] = name;
- opts["gui"] = "1";
- map preFilters = $[];
- preFilters = (map) SCR::Read( .logparse, opts );
-
- any asev = preFilters["severity"]:nil;
- string sev = "";
- if ( asev != nil ) { sev = tostring(asev); }
- if ( sev == "-" ) { sev = _("All"); }
-
- Wizard::SetContentsButtons( _("Report Configuration Dialog"),
- filterForm2(name,preFilters), filterCfHelp1, Label::BackButton(), Label::NextButton() );
-
- if ( sev != "" && sev != _("All") ) {
- if ( sev != "U" ) {
- integer isev = tointeger(sev);
- if ( isev < 10 ) {
- sev = "0" + sev;
- }
- }
-
- UI::ChangeWidget(`id(`sev), `Value, sev);
- }
-
- string mode = "All";
- string sdmode = "R";
-
- Settings = $[ ];
- map event = $[];
- any id = nil;
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
-
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil;
-
- if ( id == `bydate ) {
-
- boolean val = (boolean) UI::QueryWidget(`id(`bydate), `Value);
- if ( val == true ) {
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, true);
- } else {
- UI::ChangeWidget(`id(`bydate_frame), `Enabled, false);
- }
-
- } else if ( id == `abort || id == `done || id == `cancel) {
- Settings["break"] = "abort";
- break;
-
- } else if ( id == `back ) {
- Settings["break"] = "back";
- break;
-
- } else if ( id == `sdmode ) {
-
- sdmode = popUpSdMode();
-
- if ( sdmode != "" ) {
- Settings["sdmode"] = sdmode;
- UI::ReplaceWidget(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode) ) );
- }
-
- } else if ( id == `mode ) {
-
- mode = popUpMode();
-
- if ( mode != "" ) {
- Settings["mode"] = mode;
- UI::ReplaceWidget(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )));
- }
-
- } else if ( id == `browse ) {
-
- string selectFile = "";
- selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
-
- if ( selectFile != nil ) {
- UI::ChangeWidget(`id(`expPath), `Value, selectFile);
- }
-
- Settings["expPath"] = expPath;
-
- } else if ( id == `save || id == `next) {
-
- // Setup the data structures.
- boolean bydate = (boolean) UI::QueryWidget(`id(`bydate), `Value);
- boolean expText = false;
- boolean expHtml = false;
-
- if ( UI::QueryWidget(`id(`expLog), `Enabled) == true ) {
- expText = (boolean) UI::QueryWidget(`id(`exportText), `Value);
- expHtml = (boolean) UI::QueryWidget(`id(`exportHtml), `Value);
- }
-
- if ( expText == true ) {
- Settings["exporttext"] = "true";
- }
- if ( expHtml == true ) {
- Settings["exporthtml"] = "true";
- }
-
- string program_name = (string) UI::QueryWidget(`id(`prog), `Value);
- string profile = (string) UI::QueryWidget(`id(`prof), `Value);
- string pid = (string) UI::QueryWidget(`id(`pid), `Value);
- string sev = (string) UI::QueryWidget(`id(`sev), `Value);
- string res = (string) UI::QueryWidget(`id(`res), `Value);
- string sdmode = (string) UI::QueryWidget(`id(`sdmode), `Label);
- string mode = (string) UI::QueryWidget(`id(`mode), `Label);
- string exppath = (string) UI::QueryWidget(`id(`expPath), `Value);
-
- // de-i18n
- if ( sev == _("All") ) { sev = "All"; }
- if ( sev == _("U") ) { sev = "U"; }
-
- if (exppath != "" ) { Settings["exportPath"] = expPath; }
- if ( program_name != "" ) { Settings["prog"] = program_name; }
- if ( profile != "" ) { Settings["profile"] = profile; }
- if ( pid != "" ) { Settings["pid"] = pid; }
- if ( sev != "" && sev != "All" ) { Settings["severity"] = sev; }
- if ( res != "" ) { Settings["resource"] = res; }
- if ( sdmode != "" ) { Settings["sdmode"] = humanStringToMode( sdmode); }
- if ( mode != "" ) { Settings["mode"] = humanStringToMode( mode ); }
-
- if ( bydate == true ) {
-
- integer start_hour = (integer) UI::QueryWidget(`id(`startHour), `Value);
- integer start_min = (integer) UI::QueryWidget(`id(`startMin), `Value);
- integer startDay = (integer) UI::QueryWidget(`id(`startDay), `Value);
- integer startMonth = (integer) UI::QueryWidget(`id(`startMonth), `Value);
- integer startYear = (integer) UI::QueryWidget(`id(`startYear), `Value);
- integer end_hour = (integer) UI::QueryWidget(`id(`endHour), `Value);
- integer end_min = (integer) UI::QueryWidget(`id(`endMin), `Value);
- integer endDay = (integer) UI::QueryWidget(`id(`endDay), `Value);
- integer endMonth = (integer) UI::QueryWidget(`id(`endMonth), `Value);
- integer endYear = (integer) UI::QueryWidget(`id(`endYear), `Value);
-
- string start_time = tostring(start_hour) + ":" + tostring(start_min);
- string end_time = tostring(end_hour) + ":" + tostring(end_min);
-
- if ( CheckDate(startDay,startMonth,startYear) == false ) {
- Popup::Error( _("Illegal start date entered. Please retry.") );
- continue;
- }
-
- if ( CheckDate(endDay,endMonth,endYear) == false ) {
- Popup::Error( _("Illegal end date entered. Please retry.") );
- continue;
- }
-
- string start_day = tostring(startDay);
- string start_month = tostring(startMonth);
- string start_year = tostring(startYear);
- string end_day = tostring(endDay);
- string end_month = tostring(endMonth);
- string end_year = tostring(endYear);
-
- Settings["startday"] = tostring(start_day);
- Settings["startmonth"] = tostring(start_month);
- Settings["startyear"] = tostring(start_year);
- Settings["endday"] = tostring(end_day);
- Settings["endmonth"] = tostring(end_month);
- Settings["endyear"] = tostring(end_year);
- Settings["starttime"] = start_time;
- Settings["endtime"] = end_time;
-
- }
-
- string expType = (string) UI::QueryWidget(`id(`expType), `Value);
- string expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
-
- if ( expType == _("csv") ) {
- Settings["exporttext"] = "1";
- } else if ( expType == _("html") ) {
- Settings["exporthtml"] = "1";
- } else if ( expType == _("Both") ) {
- Settings["exporttext"] = "1";
- Settings["exporthtml"] = "1";
- }
-
- Settings["exportPath"] = expPath;
-
- break;
- }
- }
-
- return Settings;
-}
-
-define term displayEmptyRep(string type) {
-
- string myLabel = "";
- string myInfo = "";
-
- if ( type == "noDb" ) {
- myLabel = _("Events DB Not Initialized.");
- myInfo = _("The events database has not been populated. No records exist.");
- } else if ( type == "noList" ) {
- myLabel = _("Query Returned Empty List.");
- myInfo = _("The events database has no records that match the search query.");
- }
-
- term newPage =
-
- `Frame( `id(`newpage), myLabel,
-
- `VBox(
- //`Label(myLabel),
- `HBox(
- `VSpacing(10),
- `Label( myInfo ),
- `VSpacing(0.5)
- ),
- `HSpacing(`opt(`hstretch), 1.0),
- `VSpacing(1)
- ));
-
-
- return newPage;
-}
-
-define term displayRep(string type, integer curPage, string slastPage, list reportList ) {
-
- string myLabel = "";
- string currentPage = tostring(curPage);
- term myTable = nil;
-
- if (type == "onDemand" || type == "sir") {
- // Very poor i18n here
- myLabel = _("On Demand Event Report - Page ") + currentPage + _(" of ") + slastPage;
- myTable = makeSirTable(reportList);
-
- } else if (type == "archRep") {
-
- myLabel = _("Archived Event Report - Page ") + currentPage + _(" of ") + slastPage;
- myTable = makeSirTable(reportList);
-
- } else if (type == "aud" || type == "audRep" ) {
-
- myLabel = _("Applications Audit Report");
- myTable = `Table(`id(`table), `opt(`notify, `immediate ),
- `header(_("Host"), _("Date"), _("Program"),
- _("Profile"), _("PID"), _("State"), _("Type") ), reportList);
-
- } else if (type == "ess" || type == "essRep" ) {
- if (reportList == nil) {
- myLabel = _("Executive Security Summary");
- myTable = `Table(`id(`table), `opt(`notify),
- `header(_("Query Results")), _("No event information exists."));
-
- } else {
- myLabel = _("Executive Security Summary");
- myTable = `Table(`id(`table), `opt(`notify, `immediate ),
- `header(_("Host"), _("Start Date"),_("End Date"), _("Num Rejects"),
- _("Num Events"), _("Ave. Sev"), _("High Sev") ), reportList);
- }
- }
-
- term newPage =
-
- `Frame( `id(`newpage), myLabel,
-
- `VBox(
- `HBox(
- `VSpacing(10),
- myTable,
- `VSpacing(0.5)
- ),
- `HSpacing(`opt(`hstretch), 1.0),
- `VSpacing(0.5),
- `HBox(
- `PushButton(`id(`first), _("F&irst Page") ),
- `PushButton(`id(`prev), _("&Previous") ),
- `PushButton(`id(`psort), _("&Sort") ),
- `PushButton(`id(`fwd), _("&Forward") ),
- `PushButton(`id(`last), _("&Last Page") ),
- `PushButton(`id(`goto), _("&Go to Page") )
- ),
- `VSpacing(1)
- ));
-
- return newPage;
-}
-
-
-// View Archived Reports
-define symbol displayArchForm() {
-
- map archType = $[ ];
- archType["sirRep"] = true;
- archType["audRep"] = false;
- archType["essRep"] = false;
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["getcron"] = "0";
- Settings["readSched"] = "1";
- Settings["type"] = "sirRep";
- string type = Settings["type"]:nil;
-
- list itemList = [];
- itemList = getArrayList(type,"");
-
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
- viewForm(archType, itemList, ""), archHelpText, Label::BackButton(), _("&Done") );
-
- map event = $[];
- any archId = nil;
-
- string repPath = "";
- integer lastPage = 1;
- integer curPage = 1;
-
- string formHelp = runHelp;
-
-
- while( true ) {
-
- event = UI::WaitForEvent( );
-
- archId = event["ID"]:nil; // We'll need this often - cache it
-
- if (archId == `back || archId == `abort || archId == `done) {
- break;
- } else if ( archId == `close || archId == `cancel || archId == `next) {
- break;
-
- } else if ( archId == `repPath ) {
-
- repPath = (string) UI::QueryWidget(`id(`repPath), `Value);
- Settings["repPath"] = repPath;
- itemList = getArrayList(type,repPath);
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
- viewForm(archType, itemList, repPath), archHelpText, Label::BackButton(), _("&Done") );
-
- } else if ( archId == `browse ) {
-
- string selectFile = "";
- selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
-
- if ( selectFile != nil ) {
- UI::ChangeWidget(`id(`repPath), `Value, selectFile);
- // set new reppath
- repPath = selectFile;
- Settings["repPath"] = repPath;
- itemList = getArrayList(type,repPath);
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"),
- viewForm(archType, itemList, repPath), archHelpText, Label::BackButton(),
- _("&Done") );
- }
-
-
- } else if ( archId == `sirRep ) {
- formHelp = sirHelp;
- archType["sirRep"] = true;
- archType["audRep"] = false;
- archType["essRep"] = false;
- Settings["type"] = "sirRep";
- type = Settings["type"]:nil;
-
- itemList = getArrayList(type,repPath);
-
- Wizard::SetContentsButtons( _("View Archived SIR Report"),
- viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
-
- } else if ( archId == `audRep ) {
- formHelp = audHelp;
- archType["sirRep"] = false;
- archType["audRep"] = true;
- archType["essRep"] = false;
- Settings["type"] = "audRep";
- type = Settings["type"]:nil;
-
- itemList= getArrayList(type,"");
- Wizard::SetContentsButtons( _("View Archived AUD Report"),
- viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
-
- } else if ( archId == `essRep ) {
- formHelp = essHelp;
- archType["sirRep"] = false;
- archType["audRep"] = false;
- archType["essRep"] = true;
- Settings["type"] = "essRep";
- type = Settings["type"]:nil;
-
- itemList= getArrayList(type,"");
- Wizard::SetContentsButtons( _("View Archived ESS Report"),
- viewForm(archType,itemList,""), formHelp, Label::BackButton(), _("&Done"));
-
-
- } else if ( archId == `view || archId == `viewall || archId == `table) {
-
- if ( archId == `viewall ) {
- Settings["single"] = "0";
- } else {
- Settings["single"] = "1";
- }
-
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- string logFile = (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, "");
- string logPath = (string) UI::QueryWidget(`id(`repPath), `Value);
- list splitPath = splitstring (logPath, "/");
- string checkPath = splitPath[size(splitPath)-1]:"";
-
- string longLogName = "";
-
-
- // Cat strings & check for trailing "/" in path
- if ( logPath != "" ) {
- if ( checkPath != "" ) {
- longLogName = logPath + "/" + logFile;
- } else {
- longLogName = logPath + logFile;
- }
- }
-
- if ( type == "sirRep" ) {
-
- formHelp = sirHelp;
- map sirSettings = nil;
- sirSettings = setArchFilter();
- if ( archId == `viewall ) { sirSettings["single"] = 0; }
-
- // Force an exit if appropriate
- any breakCheck = sirSettings["break"]:nil;
-
- if ( breakCheck == "abort" ) {
- symbol myBreak = `abort;
- return myBreak;
-
- } else if ( breakCheck == "back" ) {
- symbol myBreak = `back;
- return myBreak;
- }
-
- if ( repPath != "" ) {
- sirSettings["repPath"] = repPath;
- }
-
- Wizard::SetContentsButtons( _("Security Incident Report"),
- viewArchForm(type,logFile,sirSettings), sirHelp, Label::BackButton(), _("&Done"));
-
- lastPage = getLastPage(type,Settings,""); // check 'name'
- setPageButtons(curPage,lastPage);
-
- } else if ( type == "audRep" ) {
-
- formHelp = audHelp;
- list reportList = [];
- integer key = 1;
- Settings["page"] = "1";
- Settings["audArch"] = "1";
- Settings["turnPage"] = "1";
- Settings["file"] = logFile;
-
- list db = (list ) SCR::Read (.reports_confined, Settings);
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil,
- repdata["date"]:nil, repdata["prog"]:nil, repdata["prof"]:nil,
- repdata["pid"]:nil, repdata["state"]:nil, repdata["type"]:nil ));
- key = key + 1;
- });
-
- lastPage = getLastPage(type,Settings,"");
- string slastPage = tostring(lastPage);
-
- Wizard::SetContentsButtons( _("Applications Audit Report"),
- displayRep(type,curPage,slastPage,reportList), formHelp, Label::BackButton(),
- _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else if ( type == "essRep" ) {
-
- formHelp = essHelp;
- list reportList = [];
- integer key = 1;
- Settings["file"] = logFile;
- Settings["essArch"] = "1";
-
- list db = (list ) SCR::Read (.reports_ess, Settings);
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil,
- repdata["startdate"]:nil, repdata["enddate"]:nil, repdata["numRejects"]:nil,
- repdata["numEvents"]:nil, repdata["sevMean"]:nil, repdata["sevHi"]:nil ));
- key = key + 1;
- });
-
- lastPage = getLastPage(type,Settings,"");
- string slastPage = tostring(lastPage);
-
- Wizard::SetContentsButtons( _("Executive Security Summary Report"),
- displayRep(type,curPage,slastPage,reportList), formHelp, Label::BackButton(),
- _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else {
- Popup::Error( _("No recognized report type selected. Try again.") );
- continue;
- }
-
- } else if ( archId == `goto ) {
-
- integer newPage = popUpGoto(lastPage);
-
- if ( newPage > 0 && newPage <= lastPage && newPage != curPage ) {
- curPage = newPage;
-
- term fwdForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), fwdForm, runHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
- }
-
- } else if ( archId == `psort ) {
-
- string sortKey = popUpSort(type);
-
- if ( sortKey != nil && sortKey != "" ) {
- curPage = 1;
- map sortCmd = $[];
- sortCmd["sortKey"] = sortKey;
- sortCmd["sort"] = "1";
- any junk = SCR::Write(.logparse, sortCmd);
- term fwdForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), fwdForm, runHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
- }
-
- } else if ( archId == `fwd ) {
-
- curPage = curPage +1;
- term fwdForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), fwdForm, formHelp, Label::BackButton(), _("&Done") );
-
- setPageButtons(curPage,lastPage);
-
-
- } else if ( archId == `prev ) {
-
- if ( curPage > 0 ) { curPage = curPage -1; }
- term prevForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), prevForm, formHelp, Label::BackButton(), _("&Done") );
-
- setPageButtons(curPage,lastPage);
-
- } else if ( archId == `first ) {
-
- curPage = 1;
- term firstForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), firstForm, formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else if ( archId == `last ) {
-
- curPage = lastPage;
- term lastForm = turnArchReportPage(curPage,lastPage);
- Wizard::SetContentsButtons( _("AppArmor Report"), lastForm, formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else {
- y2error("Unexpected return code: %1", archId);
- continue;
- }
- //break;
- }
-
- if (archId != `back && archId != `abort && archId != `done) {
- archId = `back;
- }
-
- return (symbol) archId;
-}
-
-// The main form for On-Demand reports, executed from the wizard by selecting 'Run Now'
-define symbol displayRunForm() {
-
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- string name = humanStringToType( (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, ""));
-
- string type = "";
-
- if (name == "Security.Incident.Report") {
- type = "sir";
- } else if (name == "Applications.Audit") {
- type = "aud";
- } else if ( name == "Executive.Security.Summary") {
- type = "ess";
- } else {
- type = "sir"; // All added reports are SIRs
- }
-
- if ( type != "aud" ) {
- boolean dbActivated = checkEventDb();
- if ( dbActivated == false ) {
- type = "noDb";
- }
- }
-
- list reportList = [];
- map Settings = $[ ];
- integer curPage = 1;
- integer lastPage = 1;
- string slastPage = "1";
-
- string formHelp = runHelp;
- map reportdata = nil;
-
- if (type == "sir") {
-
- Settings = filterConfigForm(name);
-
- // Force an exit if appropriate
- any breakCheck = Settings["break"]:nil;
-
- if ( breakCheck == "abort" ) {
- symbol myBreak = `abort;
- return myBreak;
-
- } else if ( breakCheck == "back" ) {
- symbol myBreak = `back;
- return myBreak;
- }
-
- formHelp = sirHelp;
- Settings["type"] = "onDemand";
- Settings["turnPage"] = "0";
-
- reportList = getReportList("sir",Settings);
- integer listSize = size(reportList);
- if ( listSize < 1 ) {
- type = "noList";
- }
-
- } else if ( type == "aud" ) {
-
- formHelp = audHelp;
- Settings["type"] = "onDemand";
- Settings["turnPage"] = "0";
-
- list db = (list ) SCR::Read (.reports_confined, Settings);
-
- integer key = 1;
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil,
- repdata["date"]:nil, repdata["prog"]:nil, repdata["prof"]:nil,
- repdata["pid"]:nil, repdata["state"]:nil, repdata["type"]:nil ));
- key = key + 1;
- });
-
- } else if ( type == "ess" ) {
-
- formHelp = essHelp;
- Settings["type"] = "onDemand";
- Settings["turnPage"] = "0";
- list db = (list ) SCR::Read (.reports_ess, Settings);
-
- if (db != nil) {
-
- integer key = 1;
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil,
- repdata["startdate"]:nil, repdata["enddate"]:nil,
- repdata["numRejects"]:nil, repdata["numEvents"]:nil, repdata["sevMean"]:nil,
- repdata["sevHi"]:nil ));
- key = key + 1;
- });
- }
-
- }
-
- if ( type == "noDb" ) {
- Wizard::SetContentsButtons( _("AppArmor On-Demand Report"), displayEmptyRep(type),
- formHelp, Label::BackButton(), _("&Done") );
- } else if ( type == "noList" ) {
- Wizard::SetContentsButtons( _("AppArmor On-Demand Report"), displayEmptyRep(type),
- formHelp, Label::BackButton(), _("&Done") );
- } else {
-
- lastPage = getLastPage(type,Settings,name);
- slastPage = tostring(lastPage);
-
- Wizard::SetContentsButtons( _("AppArmor On-Demand Report"),
- displayRep(type,curPage,slastPage,reportList), formHelp,
- Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
- }
-
- map event = $[];
- any id = nil;
-
- while( true ) {
-
- // Grey out inappropriate paging buttons
- if (curPage <= 1 ) {
- UI::ChangeWidget(`id(`prev), `Enabled, false);
- } else if ( curPage >= lastPage ) {
- UI::ChangeWidget(`id(`fwd), `Enabled, false);
- }
-
- event = UI::WaitForEvent( timeout_millisec );
- id = event["ID"]:nil; // We'll need this often - cache it
-
- // REDO
- if ( id == `schedrep ) {
- break;
- } else if ( id == `abort || id == `cancel || id == `back || id == `done) {
- break;
- } else if ( id == `next ) {
-
- break;
-
- } else if ( id == `goto ) {
-
- integer newPage = popUpGoto(lastPage);
-
- if ( newPage > 0 && newPage <= lastPage && newPage != curPage ) {
- curPage = newPage;
-
- term goForm = turnReportPage(name,curPage,slastPage,Settings);
- Wizard::SetContentsButtons( _("AppArmor - Run Reports"), goForm,
- formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
- }
-
- } else if ( id == `psort ) {
-
- string sortKey = popUpSort(type);
-
- if ( sortKey != nil && sortKey != "" ) {
-
- // branch added 08.01.2005
- curPage = 1;
- Settings["type"] = "onDemand";
- Settings["turnPage"] = "0";
- Settings["sortKey"] = sortKey;
-
- reportList = getReportList(type,Settings);
-
- Wizard::SetContentsButtons( _("AppArmor On-Demand Report"), displayRep(type,curPage,
- slastPage,reportList), formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- }
-
- } else if ( id == `prev ) {
-
- if ( curPage > 0 ) { curPage = curPage -1; }
- term prevForm = turnReportPage(name,curPage,slastPage,Settings);
- Wizard::SetContentsButtons( _("AppArmor - Run Reports"), prevForm,
- formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else if ( id == `fwd ) {
- curPage = curPage + 1;
- term fwdForm = turnReportPage(name,curPage,slastPage,Settings);
- Wizard::SetContentsButtons( _("AppArmor - Run Reports"), fwdForm,
- formHelp, Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else if ( id == `first ) {
-
- curPage = 1;
- slastPage = tostring(lastPage);
- term firstForm = turnReportPage(name,curPage,slastPage,Settings);
- Wizard::SetContentsButtons( _("AppArmor - Run Reports"), firstForm, formHelp,
- Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else if ( id == `last ) {
-
- curPage = lastPage;
- slastPage = tostring(lastPage);
- term lastForm = turnReportPage(name,curPage,slastPage,Settings);
- Wizard::SetContentsButtons( _("AppArmor - Run Reports"), lastForm, formHelp,
- Label::BackButton(), _("&Done") );
- setPageButtons(curPage,lastPage);
-
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
-
- }
-
- type = "";
- return (symbol) id;
-}
-
-define void addSchedForm() {
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["getcron"] = "1";
- Settings["readSched"] = "1";
- Settings["type"] = "schedRep";
-
- string expPath = "/var/log/apparmor/reports-exported";
-
- UI::OpenDialog(
-
- `ReplacePoint( `id(`addSchedRep), `VBox(
- `Label( _("Add Scheduled SIR") ),
- `VSpacing(1),
- `TextEntry(`id(`name), _("Report Name")),
- `VSpacing(1),
- `HBox(
- `ComboBox(`id(`monthdate), `opt(`notify), _("Day of Month"), [
- `item(`id(`md_00), _("All")),
- `item(`id(`md_01), "1"), `item(`id(`md_02), "2"), `item(`id(`md_03), "3"),
- `item(`id(`md_04), "4"), `item(`id(`md_05), "5"), `item(`id(`md_06), "6"),
- `item(`id(`md_07), "7"), `item(`id(`md_08), "8"), `item(`id(`md_09), "9"),
- `item(`id(`md_10), "10"), `item(`id(`md_11), "9"), `item(`id(`md_12), "12"),
- `item(`id(`md_13), "13"), `item(`id(`md_14), "14"), `item(`id(`md_15), "15"),
- `item(`id(`md_16), "16"), `item(`id(`md_17), "17"), `item(`id(`md_18), "18"),
- `item(`id(`md_19), "19"), `item(`id(`md_20), "20"), `item(`id(`md_21), "21"),
- `item(`id(`md_22), "22"), `item(`id(`md_23), "23"), `item(`id(`md_24), "24"),
- `item(`id(`md_25), "25"), `item(`id(`md_26), "26"), `item(`id(`md_27), "27"),
- `item(`id(`md_28), "28"), `item(`id(`md_29), "29"), `item(`id(`md_30), "30"),
- `item(`id(`md_31), "31") ]),
- `ComboBox(`id(`weekday), `opt(`notify), _("Day of Week"), [
- _("All"), _("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")
- ]),
- `IntField(`id(`hour), _("Hour"), 00, 23, 00),
- `IntField(`id(`mins), _("Minute"), 00, 59, 00)
- ),
- `VSpacing(1),
- `HBox(
- `VSpacing(1),
- `TextEntry(`id(`email1), `opt(`notify), _("Email Target 1"), ""),
- `TextEntry(`id(`email2), `opt(`notify), _("Email Target 2"), ""),
- `TextEntry(`id(`email3), `opt(`notify), _("Email Target 3"), "")
- ),
- `VSpacing(1),
- `HBox(
- `VSpacing(0.5),
- `ComboBox(`id(`expType), `opt(`notify), _("Export Type"), [
- _("None"), _("csv"), _("html"), _("Both")
- ]),
- `TextEntry(`id(`expPath), _("Location to store log."), expPath ),
- `Bottom( `VWeight( 1, `PushButton(`id(`browse), _("&Browse")) ))
- ),
- `VSpacing(1),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`next), Label::NextButton() )
- )
- )));
-
- string mode = "All";
- string sdmode = "R";
- integer timeout_millisec = 20 * 1000;
- map event = $[];
- any addInput = nil;
-
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- addInput = event["ID"]:nil; // We'll need this often - cache it
-
-
- if ( addInput == `monthdate && addInput != 0 ) {
- UI::ChangeWidget(`id(`weekday), `Value, _("All") );
- } else if ( addInput == `weekday && addInput != _("All") ) {
- UI::ChangeWidget(`id(`monthdate), `Value, _("All") );
- }
-
- if ( addInput == `next ) {
-
- // Check for valid path
- expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
- map fileTest = $[];
- fileTest["checkFile"] = "1";
- fileTest["file"] = expPath;
-
- any pathExists = SCR::Read(.reports_parse, fileTest);
- string spath = tostring(pathExists);
-
- if ( spath != "1" ) {
- Popup::Error(_("The specified directory does not exist."));
- UI::ChangeWidget(`id(`expPath), `Value, oldExpPath);
- } else {
-
- Settings["expPath"] = expPath;
- UI::ChangeWidget(`id(`expPath), `Value, expPath);
-
- string name = (string) UI::QueryWidget(`id(`name), `Value);
- string monthdate = (string) UI::QueryWidget(`id(`monthdate), `Value);
- string weekday = (string) UI::QueryWidget(`id(`weekday), `Value);
- any iHours = (any) UI::QueryWidget(`id(`hour), `Value);
- any iMins = (any) UI::QueryWidget(`id(`mins), `Value);
- string email1 = (string) UI::QueryWidget(`id(`email1), `Value);
- string email2 = (string) UI::QueryWidget(`id(`email2), `Value);
- string email3 = (string) UI::QueryWidget(`id(`email3), `Value);
-
- //string monthdate = tostring( iMonthdate );
- string hour = tostring( iHours );
- string mins = tostring( iMins );
-
- string expType = (string) UI::QueryWidget(`id(`expType), `Value);
-
- if ( expType == _("csv") || expType == _("Both") ) {
- Settings["csv"] = "1";
- }
-
- if ( expType == _("html") || expType == _("Both") ) {
- Settings["html"] = "1";
- }
-
- if ( weekday == _("All") ) { weekday = "-"; }
- if ( monthdate == _("All") ) { monthdate = "-"; }
-
- // de-i18n
- if ( weekday == _("Mon") ) { weekday = "Mon"; }
- if ( weekday == _("Tue") ) { weekday = "Tue"; }
- if ( weekday == _("Weds") ) { weekday = "Weds"; }
- if ( weekday == _("Thu") ) { weekday = "Thu"; }
- if ( weekday == _("Fri") ) { weekday = "Fri"; }
- if ( weekday == _("Sat") ) { weekday = "Sat"; }
- if ( weekday == _("Sun") ) { weekday = "Sun"; }
-
- Settings["add"] = "1";
- Settings["name"] = name;
- Settings["monthdate"] = monthdate;
- Settings["weekday"] = weekday;
- Settings["hour"] = hour;
- Settings["mins"] = mins;
- Settings["email1"] = email1;
- Settings["email2"] = email2;
- Settings["email3"] = email3;
-
- // Confirm reasonable input on report names
- string checkName = filterchars(name, "`~!@#$%^&*()[{]};:'\",<>?/\|");
- integer nameLength = size(name);
-
- if ( regexpmatch(name, " ") == true ) {
- Popup::Error( _("Only one contiguous space allowed in report names."));
- } else if ( checkName != "" ) {
- Popup::Error( _("These characters are not allowed in report names:
- \"`~!@#$%^&*()[{]};:'\",<>?/\|\"") );
- } else if ( nameLength > 128 ) {
- Popup::Error( _("Only 128 characters are allowed in report names."));
- } else {
- boolean uniqueName = findDupe(name);
- if ( uniqueName == true ) {
- UI::ReplaceWidget(`addSchedRep, schedFilterForm );
- } else {
- Popup::Error( _("Each report name should be unique.") );
- }
- }}
-
- } else if ( addInput == `sdmode ) {
-
- sdmode = popUpSdMode();
-
- if (sdmode != "") {
- Settings["sdmode"] = sdmode;
- UI::ReplaceWidget(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode) ));
- }
-
- } else if ( addInput == `mode ) {
-
- mode = popUpMode();
-
- if (mode != "") {
- Settings["mode"] = mode;
- UI::ReplaceWidget(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )) );
- }
-
- } else if (addInput == `save ) {
-
- string prog = (string) UI::QueryWidget(`id(`prog), `Value);
- string prof = (string) UI::QueryWidget(`id(`prof), `Value);
- string pid = (string) UI::QueryWidget(`id(`pid), `Value);
- string res = (string) UI::QueryWidget(`id(`res), `Value);
- string sdmode = (string) UI::QueryWidget(`id(`sdmode), `Label);
- string mode = (string) UI::QueryWidget(`id(`mode), `Label);
- string sev = (string) UI::QueryWidget(`id(`sev), `Value);
- string expType = (string) UI::QueryWidget(`id(`expType), `Value);
-
- if ( expType == "csv" ) {
- Settings["exporttext"] = "1";
- } else if ( expType == "html" ) {
- Settings["exporthtml"] = "1";
- } else if ( expType == "both" ) {
- Settings["exporttext"] = "1";
- Settings["exporthtml"] = "1";
- }
-
- if ( sev == _("All") ) { sev = "-"; }
-
- Settings["getcron"] = "";
- Settings["prog"] = prog;
- Settings["prof"] = prof;
- Settings["pid"] = pid;
- Settings["sev"] = sev;
- Settings["res"] = res;
- Settings["sdmode"] = humanStringToMode( sdmode );
- Settings["mode"] = humanStringToMode( mode );
-
- any error = (any) SCR::Write(.reports_sched, Settings);
-
- if (is(error, string)) {
- string erStr = tostring(error);
- Popup::Error("Error: " + erStr);
- }
-
- addInput = `close;
- break;
-
- } else if ( addInput == `accept ) {
-
- expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
- map fileTest = $[];
- fileTest["checkFile"] = "1";
- fileTest["file"] = expPath;
-
- any pathExists = SCR::Read(.reports_parse, fileTest);
- string spath = tostring(pathExists);
-
- if ( spath == "1" ) {
- Settings["expPath"] = expPath;
- UI::ChangeWidget(`id(`expPath), `Value, expPath);
- } else {
- Popup::Error(_("The specified directory does not exist."));
- }
-
- } else if ( addInput == `browse ) {
-
- string selectFile = "";
- selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
-
- if ( selectFile != nil ) {
- UI::ChangeWidget(`id(`expPath), `Value, selectFile);
- }
-
- Settings["expPath"] = expPath;
-
- } else if ( addInput == `cancel || addInput == `close ) {
-
- addInput = `close;
- break;
- }
- }
-
- UI::CloseDialog();
-
- return;
-}
-
-define void editSchedForm() {
-
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- string name = humanStringToType( (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, ""));
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["name"] = name;
- Settings["getcron"] = "";
- Settings["getrep"] = "1";
- Settings["readSched"] = "1";
- Settings["type"] = "schedRep";
-
- list itemList = [];
- integer key = 1;
-
- map db = nil;
- db = (map) SCR::Read (.reports_sched, Settings );
- string sname = name; // Don't know why this was pulled from db instead of name above
- any amday = db["mday"]:nil;
- any wday = db["wday"]:nil;
- any shour = db["hour"]:nil;
- any smins = db["mins"]:nil;
-
- string oldRepName = sname;
- string swday = "All";
- string monthdate = "All";
-
- if (amday != nil) { monthdate = tostring(amday); }
- if (wday != nil) { swday = tostring(wday); }
-
- integer ihour = 23;
- integer imins = 59;
- if (shour != nil) { ihour = tointeger(shour); }
- if (smins != nil) { imins = tointeger(smins); }
-
- // Get reports.conf info
- Settings["getrep"] = "";
- Settings["getconf"] = "1";
- map db2 = nil;
- db2 = (map) SCR::Read (.reports_sched, Settings );
-
- any aemail1 = db2["addr1"]:nil;
- any aemail2 = db2["addr2"]:nil;
- any aemail3 = db2["addr3"]:nil;
- any tmpPath = db2["exportpath"]:nil;
-
- string email1 = "";
- string email2 = "";
- string email3 = "";
-
- string expType = "";
- string expPath = "/var/log/apparmor/reports-exported";
- if ( tmpPath != nil ) {
- oldExpPath = tostring(tmpPath);
- expPath = oldExpPath;
- } else {
- oldExpPath = defExpPath;
- expPath = oldExpPath;
- }
-
- if (aemail1 != nil) { email1 = tostring(aemail1); }
- if (aemail2 != nil) { email2 = tostring(aemail2); }
- if (aemail3 != nil) { email3 = tostring(aemail3); }
-
- /* Get Filtering Info for Report */
- any aprog = db2["prog"]:nil;
- any aprof = db2["prof"]:nil;
- any apid = db2["pid"]:nil;
- any ares = db2["res"]:nil;
- any asev = db2["severity"]:nil;
- any asdmode = db2["sdmode"]:nil;
- any amode = db2["mode"]:nil;
- any acsv = db2["csv"]:nil;
- any ahtml = db2["html"]:nil;
-
- /* debug */
- if ( aprog != nil ) { Settings["prog"] = tostring(aprog); }
- if ( aprof != nil ) { Settings["prof"] = tostring(aprof); }
- if ( apid != nil ) { Settings["pid"] = tostring(apid); }
- if ( ares != nil ) { Settings["res"] = tostring(ares); }
- if ( asev != nil ) { Settings["sev"] = tostring(asev); }
- if ( asdmode != nil ) { Settings["sdmode"] = tostring(asdmode); }
- if ( asdmode == nil || asdmode == "-" ) {
- Settings["sdmode"] = "All";
- }
- if ( amode != nil ) { Settings["mode"] = tostring(amode); }
-
- if ( acsv != nil && ahtml != nil ) {
- expType = "Both";
- Settings["csv"] = "1";
- Settings["html"] = "1";
- } else if ( acsv != nil && ahtml == nil ) {
- expType = "csv";
- Settings["csv"] = "1";
- Settings["html"] = "";
- } else if ( acsv == nil && ahtml != nil ) {
- expType = "html";
- Settings["csv"] = "";
- Settings["html"] = "1";
- } else if ( acsv == nil && ahtml == nil ) {
- expType = "None";
- Settings["csv"] = "";
- Settings["html"] = "";
- }
-
- // Special handling for sev
- string formatSev = "";
- if ( asev != nil ) { formatSev = tostring(asev); }
- if ( formatSev != "" && formatSev != "U" && formatSev != "All" && formatSev != nil) {
- formatSev = "0" + formatSev;
- }
-
- term continueBtns =
-
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`fwd), _("N&ext") )
- );
-
-
- // We need secondary filters for SIR reports only
- if ( sname == "Executive.Security.Summary" || sname == "Applications.Audit" ) {
-
- continueBtns =
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`save), Label::SaveButton() )
- );
-
- }
-
- string edLabel = _("Edit Report Schedule for ") + typeToHumanString(sname);
-
- UI::OpenDialog(
-
- `ReplacePoint( `id(`editSchedRep),
-
- `VBox(
- `HBox( `Label(`id(`edname), edLabel) ),
- `VSpacing(1),
- `HBox(
- `ComboBox(`id(`monthdate), `opt(`notify), _("Day of Month"), [
- `item(`id(`md_00), _("All")),
- `item(`id(`md_01), "1"), `item(`id(`md_02), "2"), `item(`id(`md_03), "3"),
- `item(`id(`md_04), "4"), `item(`id(`md_05), "5"), `item(`id(`md_06), "6"),
- `item(`id(`md_07), "7"), `item(`id(`md_08), "8"), `item(`id(`md_09), "9"),
- `item(`id(`md_10), "10"), `item(`id(`md_11), "11"), `item(`id(`md_12), "12"),
- `item(`id(`md_13), "13"), `item(`id(`md_14), "14"), `item(`id(`md_15), "15"),
- `item(`id(`md_16), "16"), `item(`id(`md_17), "17"), `item(`id(`md_18), "18"),
- `item(`id(`md_19), "19"), `item(`id(`md_20), "20"), `item(`id(`md_21), "21"),
- `item(`id(`md_22), "22"), `item(`id(`md_23), "23"), `item(`id(`md_24), "24"),
- `item(`id(`md_25), "25"), `item(`id(`md_26), "26"), `item(`id(`md_27), "27"),
- `item(`id(`md_28), "28"), `item(`id(`md_29), "29"), `item(`id(`md_30), "30"),
- `item(`id(`md_31), "31")
- ]),
- `ComboBox(`id(`weekday), `opt(`notify), _("Day of Week"), [
- _("All"), _("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")
- ]),
- `IntField(`id(`hour), _("Hour"), 0, 23, ihour),
- `IntField(`id(`mins), _("Minute"), 0, 59, imins)
- ),
- `VSpacing(1),
- `HBox(
- `VSpacing(1),
- `TextEntry(`id(`email1), `opt(`notify), _("Email Target 1"), email1),
- `TextEntry(`id(`email2), `opt(`notify), _("Email Target 2"), email2),
- `TextEntry(`id(`email3), `opt(`notify), _("Email Target 3"), email3)
- ),
- `VSpacing(1),
- `HBox(
- `VSpacing(0.5),
-
- // DWR MOD `ComboBox(`id(`expType), `opt(`notify, `immediate), _("Export Type"), [
- `ComboBox(`id(`expType), `opt(`notify), _("Export Type"), [
- _("None"), _("csv"), _("html"), _("Both")
- ]),
- `TextEntry(`id(`expPath), _("Location to store log."), expPath ),
- `Bottom( `VWeight( 1, `PushButton(`id(`browse), _("&Browse")) ))
- ),
- `VSpacing(1),
- continueBtns
- )));
-
- /**************************************************/
- string mode = _("All");
- string sdmode = _("R");
-
- integer timeout_millisec = 20 * 1000;
- map event = $[];
- any editInput = nil;
- //map Settings = $[ ];
-
- //Cheap & easy way to give default value to ComboBox
- if (swday != _("All") ) {
- UI::ChangeWidget(`id(`weekday), `Value, swday);
- }
-
- if ( monthdate != _("All") ) {
- UI::ChangeWidget(`id(`monthdate), `Value, monthdate);
- }
-
- if ( expType != _("None") ) {
- UI::ChangeWidget(`id(`expType), `Value, expType);
- }
-
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
- editInput = event["ID"]:nil; // We'll need this often - cache it
-
- if ( editInput == `monthdate && editInput != 0 ) {
- UI::ChangeWidget(`id(`weekday), `Value, _("All") );
- } else if ( editInput == `weekday && editInput != _("All") ) {
- UI::ChangeWidget(`id(`monthdate), `Value, _("All") );
- }
-
- if ( editInput == `fwd ) {
-
- string email1 = (string) UI::QueryWidget(`id(`email1), `Value);
- string email2 = (string) UI::QueryWidget(`id(`email2), `Value);
- string email3 = (string) UI::QueryWidget(`id(`email3), `Value);
-
- string spath = "0";
-
- expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
- map fileTest = $[];
- fileTest["checkFile"] = "1";
- fileTest["file"] = expPath;
-
- any pathExists = SCR::Read(.reports_parse, fileTest);
- spath = tostring(pathExists);
- Settings["expPath"] = expPath;
-
- if ( spath == "1" ) {
-
- Settings = getSchedSettings(Settings);
- UI::ReplaceWidget(`editSchedRep, editFilterForm(Settings) );
-
- // Special handling for ComboBoxes (sev)
- if ( formatSev != "" ) { UI::ChangeWidget(`id(`sev), `Value, formatSev); }
-
- } else {
- Popup::Error(_("The specified directory does not exist."));
- UI::ChangeWidget(`id(`expPath), `Value, oldExpPath);
- }
-
- } else if ( editInput == `sdmode ) {
-
- sdmode = popUpSdMode();
-
- if ( sdmode != "" ) {
- Settings["sdmode"] = sdmode;
- UI::ReplaceWidget(`id(`replace_sdmode), `PushButton(`id(`sdmode), modeToHumanString( sdmode) ));
- }
-
- } else if ( editInput == `mode ) {
-
- mode = popUpMode();
- if ( mode != "" ) {
- Settings["mode"] = mode;
- UI::ReplaceWidget(`id(`replace_mode), `PushButton(`id(`mode), modeToHumanString( mode )));
- }
-
- } else if ( editInput == `browse ) {
-
- string selectFile = "";
- selectFile = UI::AskForExistingDirectory( "/", _("Select Directory"));
-
- if ( selectFile != nil ) {
- UI::ChangeWidget(`id(`expPath), `Value, selectFile);
- }
-
- Settings["expPath"] = expPath;
-
- } else if ( editInput == `close || editInput == `cancel ) {
- break;
- } else if ( editInput == `save ) {
-
- string spath = "0";
-
- if ( sname == "Executive.Security.Summary" || sname == "Applications.Audit" ) {
-
- expPath = (string) UI::QueryWidget(`id(`expPath), `Value);
- map fileTest = $[];
- fileTest["checkFile"] = "1";
- fileTest["file"] = expPath;
-
- any pathExists = SCR::Read(.reports_parse, fileTest);
- spath = tostring(pathExists);
- Settings["expPath"] = expPath;
- } else {
- // SIR Reports already checked
- spath = "1";
- }
-
- if ( spath != "1" ) {
- Popup::Error(_("The specified directory does not exist."));
- UI::ChangeWidget(`id(`expPath), `Value, oldExpPath);
- } else {
-
-
- if ( sname != "Executive.Security.Summary" && sname != "Applications.Audit" ) {
-
- string prog = (string) UI::QueryWidget(`id(`prog), `Value);
- string prof = (string) UI::QueryWidget(`id(`prof), `Value);
- string pid = (string) UI::QueryWidget(`id(`pid), `Value);
- string res = (string) UI::QueryWidget(`id(`res), `Value);
- string sdmode = (string) UI::QueryWidget(`id(`sdmode), `Label);
- string mode = (string) UI::QueryWidget(`id(`mode), `Label);
- string sev = (string) UI::QueryWidget(`id(`sev), `Value);
-
- Settings["prog"] = prog;
- Settings["prof"] = prof;
- Settings["pid"] = pid;
- Settings["sev"] = sev;
- Settings["res"] = res;
- Settings["sdmode"] = humanStringToMode( sdmode );
- Settings["mode"] = humanStringToMode( mode );
-
- } else {
-
- string email1 = (string) UI::QueryWidget(`id(`email1), `Value);
- string email2 = (string) UI::QueryWidget(`id(`email2), `Value);
- string email3 = (string) UI::QueryWidget(`id(`email3), `Value);
-
- Settings = getSchedSettings(Settings);
- }
-
- Settings["name"] = sname;
- Settings["getconf"] = "";
- Settings["setconf"] = "1";
-
- string expType = (string) UI::QueryWidget(`id(`expType), `Value);
-
- if ( expType == "csv" ) {
- Settings["exporttext"] = "1";
- } else if ( expType == "html" ) {
- Settings["exporthtml"] = "1";
- } else if ( expType == "both" ) {
- Settings["exporttext"] = "1";
- Settings["exporthtml"] = "1";
- }
-
- any error = (any) SCR::Write(.reports_sched, Settings);
-
- if (is(error, string)) {
- string erStr = tostring(error);
- Popup::Error( _("Error: ") + erStr);
- }
-
- break;
- }}
- // END - Save Dialog (editInput == `save)
- }
-
- UI::CloseDialog();
-
- //return (symbol) editInput;
- return;
-}
-
-define void delSchedForm() {
-
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- string name = humanStringToType( (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, ""));
-
- map Settings = $[ ];
- Settings["del"] = "1";
- Settings["name"] = name;
-
- UI::OpenDialog(
-
- `VBox(
- `VSpacing(0.5),
- `Label( _("Delete Confirmation") ),
- `VSpacing(1),
- `HBox(
- `HSpacing( `opt(`hstretch), 0.75 ),
- `Left(`HWeight( 0, `Label( _("Are you sure you want to delete: ") + name + _("?") )))
- ),
- `VSpacing(1),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`del), Label::DeleteButton() )
- )
- ));
-
- symbol delInput = `default;
-
- while ( delInput != `close ) {
-
- delInput = (symbol) UI::UserInput();
-
- if ( delInput == `del ) {
- SCR::Write(.reports_sched, Settings);
- //any error = (any) SCR::Write(.reportsched, Settings);
- break;
- } else if (delInput == `close || delInput == `cancel) {
- break;
- }
- }
-
- UI::CloseDialog();
-
- return;
-
-}
-
-// Forces update of the table of available scheduled reports
-define void updateSched() {
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["getcron"] = "1";
- Settings["readSched"] = "1";
- Settings["type"] = "schedRep";
-
- list itemList = [];
- integer key = 1;
-
- list db = (list ) SCR::Read (.reports_sched, Settings);
-
- foreach ( map record, db, {
- itemList = add( itemList, `item( `id(key), typeToHumanString( record["name"]:"" ), record["mday"]:nil, record["wday"]:nil,
- record["hour"]:nil, record["mins"]:nil ));
- key = key + 1;
- });
-
- term schedForm =
-
- `VBox(
- `Label( _("Schedule Reports") ),
- `VSpacing(2),
- `HBox(
- `VSpacing(10),
- `Table(`id(`table), `opt(`notify), `header(_("Report Name"),
- _("Day of Month"), _("Day of Week"), _("Hour"), _("Mins")), itemList)
- ),
- `VSpacing(0.5),
- `HBox(
- `PushButton(`id(`viewrep), _("View Archive") ),
- `PushButton(`id(`runrep), _("Run Now") )
- ),
- `HBox(
- `PushButton(`id(`add), Label::AddButton() ),
- `PushButton(`id(`edit), Label::EditButton() ),
- `PushButton(`id(`delete), Label::DeleteButton() )
- )
- );
-
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"), schedForm,
- mainHelp, Label::BackButton(), Label::NextButton() );
-
- return;
-}
-
-define symbol displaySchedForm() {
-
-// START - Move to separate Routine - START
-
- map Settings = $[ ];
- string readSched = "1";
- Settings["getcron"] = "1";
- Settings["readSched"] = "1";
- Settings["type"] = "schedRep";
-
- list itemList = [];
- integer key = 1;
-
- list db = (list ) SCR::Read (.reports_sched, Settings);
-
- foreach ( map record, db, {
- itemList = add( itemList, `item( `id(key), typeToHumanString( record["name"]:""), record["mday"]:nil, record["wday"]:nil,
- record["hour"]:nil, record["mins"]:nil ));
- key = key + 1;
- });
-
- term schedForm =
-
- `Frame( `id(`dosched), _("Schedule Reports"),
- `VBox(
- `VSpacing(2),
- `HBox(
- `VSpacing(10),
- `Table(`id(`table), `opt(`notify), `header(_("Report Name"),
- _("Day of Month"), _("Day of Week"), _("Hour"), _("Mins")),
- itemList)
- ),
- `VSpacing(0.5),
- `HBox(
- `PushButton(`id(`viewrep), _("View Archive") ),
- `PushButton(`id(`runrep), _("Run Now") )
- ),
- `HBox(
- `PushButton(`id(`add), Label::AddButton() ),
- `PushButton(`id(`edit), Label::EditButton() ),
- `PushButton(`id(`delete), Label::DeleteButton() )
- ))
- );
-
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"), schedForm,
- mainHelp, Label::BackButton(), _("&Done") );
-
- // Double-click tracking
- integer newRecord = nil;
- integer lastRecord = nil;
-
- map event = $[];
- any id = nil;
- while( true ) {
-
- event = UI::WaitForEvent( timeout_millisec );
-
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `schedrep ) {
-
- break;
-
- } else if ( id == `abort || id == `cancel || id == `done ) {
- break;
- } else if ( id == `back ) {
- break;
- } else if ( id == `runrep || id == `viewrep ) {
- break;
- } else if ( id == `next ) {
- id = `done;
- break;
- } else if ( id == `add ) {
- addSchedForm();
- Wizard::SetContentsButtons( _("AppArmor Security Event Report"), schedForm, mainHelp, Label::BackButton(), Label::NextButton() );
- updateSched();
- continue;
-
- } else if ( id == `edit ) {
- editSchedForm();
- updateSched();
- continue;
-
- } else if ( id == `delete ) {
-
- integer itemselected = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
- string repName = humanStringToType( (string) select((term) UI::QueryWidget(`id(`table), `Item(itemselected)), 1, ""));
-
- if ( repName == "Executive.Security.Summary" || repName == "Applications.Audit" || repName == "Security.Incident.Report" ) {
- Popup::Error( _("Cannot delete a stock report.") );
- } else {
-
- delSchedForm();
- updateSched();
- }
-
- continue;
-
- } else if ( id == `table ) {
-
- newRecord = ((integer) UI::QueryWidget(`id(`table), `CurrentItem) );
-
- if ( newRecord == lastRecord ) {
- //editSchedForm();
- //updateSched();
- id = `runrep;
- break;
- newRecord = 0;
- }
-
- lastRecord = newRecord;
-
- } else {
- y2error("Unexpected return code: %1", id);
- continue;
- }
- }
-
- return (symbol) id;
-}
-
-
-}
-
-
--- a/src/include/subdomain/reporting_utils.ycp
+++ /dev/null
@@ -1,609 +0,0 @@
-/* ------------------------------------------------------------------
-*
-* Copyright (C) 2002-2005 Novell/SUSE
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of version 2 of the GNU General Public
-* License published by the Free Software Foundation.
-*
- ------------------------------------------------------------------*/
-{
-
-import "Wizard";
-import "Popup";
-import "Label";
-include "subdomain/report_helptext.ycp";
-textdomain "yast2-apparmor";
-
-define boolean checkEventDb() {
-
- boolean dbActivated = false;
- map args = $[];
- args["checkDb"] = "1";
-
- any dbCheck = (any) SCR::Read( .reports_parse, args);
- integer dbOn = tointeger(dbCheck);
-
- if ( dbOn == 1 ) {
- dbActivated = true;
- }
-
- return dbActivated;
-}
-
-define boolean findDupe(string name) {
-
- boolean unique = false;
- map args = $[ ];
- args["name"] = name;
- args["getdupe"] = "1";
- any aDupe = (any) SCR::Read (.reports_sched, args );
-
- if ( aDupe == "" || aDupe == nil ) {
- unique = true; // bad, but try for a non-breaking failure
- } else if ( aDupe == 1 ) {
- unique = false;
- } else {
- unique = true;
- }
-
- return unique;
-}
-
-define string unI18n(string weekday) {
-
- if ( weekday == _("Mon") ) { weekday = "Mon"; }
- if ( weekday == _("Tue") ) { weekday = "Tue"; }
- if ( weekday == _("Wed") ) { weekday = "Wed"; }
- if ( weekday == _("Thu") ) { weekday = "Thu"; }
- if ( weekday == _("Fri") ) { weekday = "Fri"; }
- if ( weekday == _("Sat") ) { weekday = "Sat"; }
- if ( weekday == _("Sun") ) { weekday = "Sun"; }
-
- return weekday;
-}
-
-/* Possible 'type's for getLastPage() && getLastSirPage()
- - displayArchForm(): type = sirRep || audRep || essRep
- - displayRunForm(): type = sir || aud || ess
-*/
-
-// Return last page number of post-filtered report
-define integer getLastPage(string type, map Settings, string name) {
-
- if ( type == "sir" || type == "sirRep" ) {
- if ( name != nil && name != "" ) {
- Settings["name"] = name;
- } else {
- y2error(_("No name provided for retrieving SIR report page count."));
- return 1; // return a page count of 1
- }
- }
-
- Settings["type"] = type;
- Settings["getLastPage"] = "1";
- map page = $[];
- page = (map) SCR::Read (.reports_parse, Settings);
- integer lastPage = page["numPages"]:1;
-
- return lastPage;
-}
-
-define boolean CheckDate( integer day, integer month, integer year ) ``{
-
- list mdays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
- boolean ret = true;
-
- if (year == nil || month == nil || day == nil)
- return false;
-
- ret = ret && month>=1 && month<=12;
-
- if( year%4==0 && (year%100!=0 || year%400==0)) {
- mdays[1] = 29;
- }
-
- ret = ret && day>=1 && day<=mdays[month-1]:0;
- ret = ret && year>=1970 && year<2032;
- return( ret );
-
-}
-
-// Make the table for displaying report data
-define term makeSirTable (list reportList) {
- term myTable =
- `Table(`id(`table), `opt(`keepSorting, `immediate ), `header(_("Host"),
- _("Date"), _("Program"), _("Profile"), _("PID"), _("Severity"),
- _("Mode Request"), _("Mode Deny"), _("Detail"), _("Event Type"),
- _("Operation"), _("Attribute"), _("Additional Name"), _("Net Family"),
- _("Net Protocol"), _("Net Socket Type")), reportList
- );
- return myTable;
-}
-
-define integer popUpGoto(integer lastPage) {
-
- UI::OpenDialog(
- `VBox(
- `HBox(
- `TextEntry(`id(`gotoPage), _("Enter a Page to Move to."), "")
- ),
- `HBox(
- `PushButton(`id(`abort), `opt(`notify), Label::AbortButton() ),
- `PushButton(`id(`save), `opt(`notify), Label::SaveButton() )
- )
- )
- );
-
- map event = $[];
- any id = nil;
- integer igoto = nil;
-
- while( true ) {
-
- event = UI::WaitForEvent();
- id = event["ID"]:nil;
-
- if ( id == `abort || id == `close || id == `cancel ) {
-
- break;
-
- } else if ( id == `save ) {
-
- any agoto = UI::QueryWidget(`id(`gotoPage), `Value);
- igoto = tointeger(agoto);
-
- if ( igoto == nil || igoto < 1 || igoto > lastPage ) {
-
- Popup::Message("You must enter a value between 1 and " + lastPage + ".");
-
- } else {
-
- break;
-
- }
- }
- }
-
- UI::CloseDialog();
-
- return igoto;
-}
-
-define string getSortId(string type, any sortId) {
-
- string sortKey = "";
-
-
- if ( type == "aud" || type == "audRep") {
-
- if ( sortId == 0 ) {
- sortKey = "prog";
- } else if ( sortId == 1 ) {
- sortKey = "profile";
- } else if ( sortId == 2 ) {
- sortKey = "pid";
- } else if ( sortId == 3 ) {
- sortKey = "state";
- } else if ( sortId == 4 ) {
- sortKey = "type";
- }
-
- } else if (type == "ess" || type == "essRep" ) {
-
- if ( sortId == 0 ) {
- sortKey = "host";
- } else if ( sortId == 1 ) {
- //sortKey = "date";
- sortKey = "numRejects";
- } else if ( sortId == 2 ) {
- sortKey = "numEvents";
- } else if ( sortId == 3 ) {
- sortKey = "sevMean";
- } else if ( sortId == 4 ) {
- sortKey = "sevHi";
- }
-
- } else {
-
- if ( sortId == 0 ) {
- sortKey = "host";
- } else if ( sortId == 1 ) {
- //sortKey = "date";
- sortKey = "time";
- } else if ( sortId == 2 ) {
- sortKey = "prog";
- } else if ( sortId == 3 ) {
- sortKey = "profile";
- } else if ( sortId == 4 ) {
- sortKey = "pid";
- } else if ( sortId == 5 ) {
- sortKey = "resource";
- } else if ( sortId == 6 ) {
- sortKey = "severity";
- } else if ( sortId == 7 ) {
- sortKey = "sdmode";
- } else if ( sortId == 8 ) {
- sortKey = "mode";
- }
-
- }
-
- return sortKey;
-}
-
-// Get the name of the filter (header column) to sort by
-define string popUpSort(string type) {
-
- term btnList = nil;
-
- if ( type == "aud" || type == "audRep") {
- btnList =
- `VBox(
- `Left(`RadioButton(`id(0), _("Program") )),
- `Left(`RadioButton(`id(1), _("Profile") )),
- `Left(`RadioButton(`id(2), _("PID") )),
- `Left(`RadioButton(`id(3), _("State") )),
- `Left(`RadioButton(`id(4), _("Type") ))
- );
-
- } else if (type == "ess" || type == "essRep" ) {
- btnList =
- `VBox(
- `Left(`RadioButton(`id(0), _("Host") )),
- `Left(`RadioButton(`id(1), _("Num. Rejects") )),
- `Left(`RadioButton(`id(2), _("Num. Events") )),
- `Left(`RadioButton(`id(3), _("Ave. Sev") )),
- `Left(`RadioButton(`id(4), _("High Sev") ))
- );
- } else {
-
- btnList =
- `VBox(
- // Sorting by host is no longer meaningful (due to sql changes)
- //`Left(`RadioButton(`id(0), _("Host") )),
- `Left(`RadioButton(`id(1), _("Date") )),
- `Left(`RadioButton(`id(2), _("Program") )),
- `Left(`RadioButton(`id(3), _("Profile") )),
- `Left(`RadioButton(`id(4), _("PID") )),
- `Left(`RadioButton(`id(5), _("Detail") )),
- `Left(`RadioButton(`id(6), _("Severity") )),
- `Left(`RadioButton(`id(7), _("Access Type") )),
- `Left(`RadioButton(`id(8), _("Mode") ))
- );
- }
-
- UI::OpenDialog(
- `VBox(
- `HBox(
- //`HSpacing( `opt(`vstretch), 0.5),
- `RadioButtonGroup(`id(`sortKey),
- btnList
- )
- ),
- `HBox(
- `PushButton(`id(`abort), Label::AbortButton() ),
- `PushButton(`id(`save), Label::SaveButton() )
- )
- )
- );
-
- map event = $[];
- any id = nil;
- string sortKey = nil;
-
- while( true ) {
-
- event = UI::WaitForEvent();
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `abort || id == `cancel || id == `close) {
-
- break;
-
- } else if (id == `save ) {
-
- any sortId = UI::QueryWidget(`id(`sortKey), `CurrentButton);
-
- /* sortKey needs to match the hash reference names in parseEventLog()
- && sortRecords() in Immunix::Reports.pm */
-
- sortKey = getSortId(type,sortId);
- break;
-
- }
- }
-
- UI::CloseDialog();
-
- return sortKey;
-
-}
-
-// Mode
-define string popUpMode() {
-
- string checkMode = (string) UI::QueryWidget(`id(`mode), `Label);
- list splitMode = splitstring (checkMode, " ");
- string myMode = splitMode[size(splitMode)-1]:"All";
-
- UI::OpenDialog(
- `VBox(
- `HBox(
- `CheckBox(`id(`clear), `opt(`notify, `immediate ), _("All"), true),
- `CheckBox(`id(`read), `opt(`notify, `immediate ), _("Read"), false),
- `CheckBox(`id(`write), `opt(`notify, `immediate ), _("Write"), false),
- `CheckBox(`id(`link), `opt(`notify, `immediate ), _("Link"), false),
- `CheckBox(`id(`exec), `opt(`notify, `immediate ), _("Execute"), false),
- `CheckBox(`id(`mmap), `opt(`notify, `immediate ), _("MMap"), false)
- ),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton() ),
- `PushButton(`id(`save), Label::SaveButton() )
- )
- )
- );
-
- integer isall = search( myMode, "All");
- if ( isall != nil && isall >= 0 ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`read), `Value, true);
- UI::ChangeWidget(`id(`write), `Value, true);
- UI::ChangeWidget(`id(`link), `Value, true);
- UI::ChangeWidget(`id(`exec), `Value, true);
- UI::ChangeWidget(`id(`mmap), `Value, true);
- } else {
- if ( search( myMode, "r") != nil ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`read), `Value, true);
- }
- if ( search( myMode, "w") != nil ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`write), `Value, true);
- }
- if ( search( myMode, "l") != nil ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`link), `Value, true);
- }
- if ( search( myMode, "x") != nil ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`exec), `Value, true);
- }
- if ( search( myMode, "m") != nil ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`mmap), `Value, true);
- }
- }
-
- string mode = "";
- map event = $[];
- any id = nil;
-
- while( true ) {
-
- event = UI::WaitForEvent();
- id = event["ID"]:nil; // We'll need this often - cache it
-
- if ( id == `clear) {
-
- if ( UI::QueryWidget(`id(`clear), `Value) == true ) {
- UI::ChangeWidget(`id(`read), `Value, false);
- UI::ChangeWidget(`id(`write), `Value, false);
- UI::ChangeWidget(`id(`link), `Value, false);
- UI::ChangeWidget(`id(`exec), `Value, false);
- UI::ChangeWidget(`id(`mmap), `Value, false);
- mode = "All";
- }
-
- } else if ( id == `read || id == `write || id == `link || id == `exec || id == `mmap ) {
-
- if ( UI::QueryWidget(`id(`read), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`write), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`link), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`exec), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`mmap), `Value) == true ) {
- UI::ChangeWidget(`id(`link), `Value, false);
- }
-
- } else if ( id == `abort || id == `cancel || id == `close) {
- mode = myMode;
- break;
- } else if ( id == `save ) {
-
- if ( UI::QueryWidget(`id(`clear), `Value) == true ) {
- mode = "All";
- } else {
- list sdList = [];
- if ( UI::QueryWidget(`id(`read), `Value) == true ) { sdList = add(sdList, "r"); }
- if ( UI::QueryWidget(`id(`write), `Value) == true ) { sdList = add(sdList, "w"); }
- if ( UI::QueryWidget(`id(`link), `Value) == true ) { sdList = add(sdList, "l"); }
- if ( UI::QueryWidget(`id(`exec), `Value) == true ) { sdList = add(sdList, "x"); }
- if ( UI::QueryWidget(`id(`mmap), `Value) == true ) { sdList = add(sdList, "m"); }
-
- foreach ( string perm, sdList, { mode = mode + perm; });
- }
-
- break;
- }
- }
-
- UI::CloseDialog();
- return mode;
-}
-
-// Access Type - SD Mode
-define string popUpSdMode() {
-
- string checkMode = (string) UI::QueryWidget(`id(`sdmode), `Label);
- checkMode = filterchars(checkMode, "APRl");
- list splitMode = splitstring (checkMode, " ");
- string mySdMode = splitMode[size(splitMode)-1]:"R";
-
- UI::OpenDialog(
- `VBox(
- `HBox(
- `CheckBox(`id(`clear), `opt(`notify, `immediate ), _("All"), false),
- `CheckBox(`id(`permit), `opt(`notify, `immediate ), _("Permit"), false),
- `CheckBox(`id(`reject),`opt(`notify, `immediate ), _("Reject"), false),
- `CheckBox(`id(`audit),`opt(`notify, `immediate ), _("Audit"), false)
- ),
- `HBox(
- `PushButton(`id(`cancel), `opt(`notify), Label::CancelButton() ),
- `PushButton(`id(`save), `opt(`notify), Label::SaveButton() )
- )
- )
- );
-
- if ( mySdMode == "P") {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`permit), `Value, true);
-
- } else if ( mySdMode == "R") {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`reject), `Value, true);
-
- } else if ( mySdMode == "A") {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`audit), `Value, true);
-
- } else if ( mySdMode == "PR" ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`permit), `Value, true);
- UI::ChangeWidget(`id(`reject), `Value, true);
-
- } else if (mySdMode == "PA" ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`permit), `Value, true);
- UI::ChangeWidget(`id(`audit), `Value, true);
-
- } else if (mySdMode == "PRA" ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`permit), `Value, true);
- UI::ChangeWidget(`id(`reject), `Value, true);
- UI::ChangeWidget(`id(`audit), `Value, true);
-
- } else if (mySdMode == "RA" ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- UI::ChangeWidget(`id(`reject), `Value, true);
- UI::ChangeWidget(`id(`audit), `Value, true);
- } else if ( mySdMode == "All" ) {
- UI::ChangeWidget(`id(`clear), `Value, true);
- UI::ChangeWidget(`id(`permit), `Value, false);
- UI::ChangeWidget(`id(`reject), `Value, false);
- UI::ChangeWidget(`id(`audit), `Value, false);
- }
-
- string sdMode = "";
- map event = $[];
- any id = nil;
-
- while( true ) {
-
- event = UI::WaitForEvent();
- id = event["ID"]:nil;
-
- if ( id == `clear) {
-
- if ( UI::QueryWidget(`id(`clear), `Value) == true ) {
- UI::ChangeWidget(`id(`permit), `Value, false);
- UI::ChangeWidget(`id(`reject), `Value, false);
- UI::ChangeWidget(`id(`audit), `Value, false);
- sdMode = "All";
- }
-
- } else if ( id == `permit || id == `reject || id == `audit ) {
-
- if ( UI::QueryWidget(`id(`permit), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`reject), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- } else if ( UI::QueryWidget(`id(`audit), `Value) == true ) {
- UI::ChangeWidget(`id(`clear), `Value, false);
- }
-
- } else if ( id == `cancel ) {
-
- sdMode = mySdMode;
- break;
-
- } else if ( id == `save ) {
-
- if ( UI::QueryWidget(`id(`clear), `Value) == true ) {
- sdMode = "All";
- } else {
- sdMode = "";
- list mList = [];
- if ( UI::QueryWidget(`id(`permit), `Value) == true ) { mList = add(mList, "P"); }
- if ( UI::QueryWidget(`id(`reject), `Value) == true ) { mList = add(mList, "R"); }
- if ( UI::QueryWidget(`id(`audit), `Value) == true ) { mList = add(mList, "A"); }
-
- foreach ( string state, mList, { sdMode = sdMode + state; });
- }
-
- break;
- }
-
- }
-
- UI::CloseDialog();
- return sdMode;
-}
-
-/* For On Demand Reports
- - Returns list of terms corresponding to the type of report
-***********************************************************************/
-define list getReportList(string type, map Settings) {
-
- list reportList = [];
-
- if ( type == "aud" ) {
-
- list db = (list ) SCR::Read (.reports_confined, Settings);
- integer key = 1;
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil, repdata["date"]:nil,
- repdata["prog"]:nil, repdata["prof"]:nil, repdata["pid"]:nil, repdata["state"]:nil,
- repdata["type"]:nil ));
- key = key + 1;
- });
-
- } else if ( type == "ess" ) {
-
- list db = (list ) SCR::Read (.reports_ess, Settings);
- integer key = 1;
-
- foreach ( map repdata, db, {
- reportList = add( reportList, `item( `id(key), repdata["host"]:nil,
- repdata["startdate"]:nil, repdata["enddate"]:nil, repdata["numRejects"]:nil,
- repdata["numEvents"]:nil, repdata["sevMean"]:nil, repdata["sevHi"]:nil ));
- key = key + 1;
- });
-
- } else {
-
- list db = (list ) SCR::Read (.logparse, Settings);
- integer key = 0;
-
- foreach ( map record, db, {
- reportList = add( reportList, `item( `id(key),
- record["host"]:nil, record["date"]:nil, record["prog"]:nil,
- record["profile"]:nil, record["pid"]:nil, record["severity"]:nil,
- record["mode_req"]:nil, record["mode_deny"]:nil,
- record["resource"]:nil, record["sdmode"]:nil, record["op"]:nil,
- record["attr"]:nil, record["name_alt"]:nil, record["net_family"]:nil,
- record["net_proto"]:nil, record["net_socktype"]:nil
- ));
- key = key + 1;
- });
-
- }
-
- return reportList;
-}
-
-}
--- a/src/include/subdomain/sd-config.ycp
+++ /dev/null
@@ -1,415 +0,0 @@
-/* ------------------------------------------------------------------
-*
-* Copyright (C) 2002-2005 Novell/SUSE
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of version 2 of the GNU General Public
-* License published by the Free Software Foundation.
-*
- ------------------------------------------------------------------*/
-{
-include "subdomain/config_complain.ycp";
-include "subdomain/helps.ycp";
-include "subdomain/apparmor_ycp_utils.ycp";
-textdomain "yast2-apparmor";
-
-import "Label";
-
-define boolean changeAppArmorState(boolean aaEnabled) {
-
- any error = nil;
- string sdAction = "";
-
- if (aaEnabled == true) {
- sdAction = "subdomain:enable";
- } else {
- sdAction = "subdomain:disable";
- }
-
- error = SCR::Execute(.sdconf, sdAction);
-
- if ( error != nil && is(error, string) ) {
-
- string errorMsg = (string) error;
- string popError = _("This operation generated the following error. Please check your installation and AppArmor profile settings.");
- Popup::Message( popError+ "\n[" + errorMsg + "]");
- aaEnabled = ! aaEnabled;
-
- }
-
- return aaEnabled;
-}
-
-define void displayNotifyForm() {
-
- map settings = (map) SCR::Execute(.subdomain, "sd-notify-settings");
-
- map terse = settings["terse"]:$[];
- map summary = settings["summary"]:$[];
- map verbose = settings["verbose"]:$[];
-
- 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;
- 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;
- 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;
- any a_v_poop = verbose["verbose_unknown"]:"1";
- string v_poop = tostring(a_v_poop);
- if(v_poop == "0") {
- v_unknown = false;
- }
-
- list terse_items = [
- `item(`id(0), _("Disabled"), t_freq==0?true:false),
- `item(`id(60), _("1 minute"), t_freq==60?true:false),
- `item(`id(300), _("5 minutes"), t_freq==300?true:false),
- `item(`id(600), _("10 minutes"), t_freq==600?true:false),
- `item(`id(900), _("15 minutes"), t_freq==900?true:false),
- `item(`id(1800), _("30 minutes"), t_freq==1800?true:false),
- `item(`id(3600), _("1 hour"), t_freq==3600?true:false),
- `item(`id(86400), _("1 day"), t_freq==86400?true:false),
- `item(`id(604800), _("1 week"), t_freq==604800?true:false)
- ];
-
- list summary_items = [
- `item(`id(0), _("Disabled"), s_freq==0?true:false),
- `item(`id(60), _("1 minute"), s_freq==60?true:false),
- `item(`id(300), _("5 minutes"), s_freq==300?true:false),
- `item(`id(600), _("10 minutes"), s_freq==600?true:false),
- `item(`id(900), _("15 minutes"), s_freq==900?true:false),
- `item(`id(1800), _("30 minutes"), s_freq==1800?true:false),
- `item(`id(3600), _("1 hour"), s_freq==3600?true:false),
- `item(`id(86400), _("1 day"), s_freq==86400?true:false),
- `item(`id(604800), _("1 week"), s_freq==604800?true:false)
- ];
-
- list verbose_items = [
- `item(`id(0), _("Disabled"), v_freq==0?true:false),
- `item(`id(60), _("1 minute"), v_freq==60?true:false),
- `item(`id(300), _("5 minutes"), v_freq==300?true:false),
- `item(`id(600), _("10 minutes"), v_freq==600?true:false),
- `item(`id(900), _("15 minutes"), v_freq==900?true:false),
- `item(`id(1800), _("30 minutes"), v_freq==1800?true:false),
- `item(`id(3600), _("1 hour"), v_freq==3600?true:false),
- `item(`id(86400), _("1 day"), v_freq==86400?true:false),
- `item(`id(604800), _("1 week"), v_freq==604800?true:false)
- ];
-
-
- term event_config = `HVCenter(`VBox(`opt(`vstretch),
- `Frame( _("Security Event Notification"),
- `HBox(`HSpacing(1),
- `VBox(`opt(`vstretch),
- `VSpacing(1),
- `Frame( _("Terse Notification"),
- `VBox(`opt(`vstretch),
- `HBox(
- `ComboBox(`id(`terse_freq), _("Frequency"), terse_items),
- `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)
- )
- )
- ),
- `VSpacing(1),
- `Frame( _("Summary Notification"),
- `VBox(`opt(`vstretch),
- `HBox(
- `ComboBox(`id(`summary_freq), _("Frequency"), summary_items),
- `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)
- )
- )
- ),
- `VSpacing(1),
- `Frame( _("Verbose Notification"),
- `VBox(`opt(`vstretch),
- `HBox(
- `ComboBox(`id(`verbose_freq), _("Frequency"), verbose_items),
- `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)
- )
- )
- ),
- `VSpacing(1)
- ),
- `HSpacing(1)
- )
- )
- )
- );
-
- Wizard::CreateDialog();
- Wizard::SetContentsButtons(_("Security Event Notification"), event_config, helps["EventNotifyHelpText"]:"", Label::BackButton(), Label::OKButton());
- Wizard::DisableBackButton();
-
- any ntInput = nil;
- string notifyLabelValue = "";
-
- while( true ) {
- ntInput = UI::UserInput();
-
- if (ntInput == `next) {
-
- map answers = $[ ];
- map set_notify = $[ ];
- map summary = $[ ];
- map verbose = $[ ];
- map 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);
-
- 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) {
-
- 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;
- } else if ( ! checkEmailAddress( t_email ) ) {
- continue;
- }
-
- 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);
-
- if (t_unknown == true) {
- terse["terse_unknown"] = "1";
- } else {
- terse["terse_unknown"] = "0";
- }
-
- } else {
- terse["enable_terse"] = "no";
- }
-
- 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;
- } else if ( ! checkEmailAddress(s_email) ) {
- continue;
- }
-
- 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);
-
- if (s_unknown == true) {
- summary["summary_unknown"] = "1";
- } else {
- summary["summary_unknown"] = "0";
- }
-
- } 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;
- } else if (! checkEmailAddress(v_email) ) {
- continue;
- }
-
- 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);
-
- if (v_unknown == true) {
- verbose["verbose_unknown"] = "1";
- } else {
- verbose["verbose_unknown"] = "0";
- }
- } else {
- verbose["enable_verbose"] = "no";
- }
-
- 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 ) {
- notifyLabelValue = _("Notification is enabled");
- } else {
- notifyLabelValue = _("Notification is disabled");
- }
- }
-
- Wizard::CloseDialog();
- if ( (ntInput == `ok) || (ntInput == `next) ) {
- UI::ChangeWidget( `id(`notifyLabel), `Value, notifyLabelValue );
- }
- break;
- }
-
-}
-
-define symbol displayAppArmorConfig () {
-
- // AppArmor Status
- boolean aaEnabled = false;
- boolean ntIsEnabled = false;
- string subdomain = (string) SCR::Execute(.subdomain, "sd-status");
- string sdEnStr = _("AppArmor is disabled");
-
- if (subdomain == "enabled") {
- aaEnabled = true;
- sdEnStr = _("AppArmor is enabled");
- }
-
- // Notification Status
- string evnotify = (string) SCR::Execute(.subdomain, "sd-notify");
- string evEnStr = _("Notification is disabled");
- if (evnotify == "enabled") {
- ntIsEnabled = true;
- evEnStr = _("Notification is enabled");
- } else if (evnotify == "notinstalled") {
- evnotify = "disabled";
- }
-
- /* Network dialog caption */
- string caption = _("AppArmor Configuration");
- string help = _("AppArmor Status
This reports whether the AppArmor policy enforcement
-module is loaded and functioning.
") +
-
-_("Security Event Notification
Configure this tool if you want
-to be notified by email when access violations have occurred.
") +
-
-_("Profile Modes
Use this tool to change the way that AppArmor
-uses individual profiles.
");
-
- term contents =
- `HVCenter(
- `VBox(
- `VSpacing(1), `HSpacing(2),
- `HBox (
- `HSpacing( `opt(`hstretch), 2 ),
- `VBox(
- `Left(`CheckBox( `id(`aaState), `opt(`notify), _("&Enable AppArmor"), aaEnabled)),
- `VSpacing(1),
-
- `Frame( `id(`aaEnableFrame), _("Configure AppArmor"),
- `HBox (
- `HSpacing( `opt(`hstretch), 4 ),
- `VBox(
- `VSpacing(1),
- `Frame ( _("Security Event Notification"),
- `HBox(
- `VSpacing(1), `HSpacing(1),
- `HVCenter( `Label( `id(`notifyLabel), evEnStr )),
- `PushButton( `id(`ntconf), _("C&onfigure")),
- `VSpacing(1), `HSpacing(1)
- )
- ),
- `VSpacing(1), `HSpacing(20),
-
- `Frame ( _("Configure Profile Modes"),
- `HBox(
- `VSpacing(1), `HSpacing(1),
- `Left(`HVCenter( `Label( `id(`modesLabel), " " + _("Set profile modes") ))),
- `PushButton( `id(`modeconf), _("Co&nfigure") ),
- `VSpacing(1), `HSpacing(1)
- )
- ),
- `VSpacing(1)
- ),
- `HSpacing( `opt(`hstretch), 4 )
- ))),
- `HSpacing( `opt(`hstretch), 2 )
- ))
- );
-
- // May want to replace Wizard() with UI()
- Wizard::CreateDialog();
- Wizard::SetTitleIcon("apparmor/control_panel");
- Wizard::SetContentsButtons(caption, contents, help, Label::BackButton(), _("&Done"));
- Wizard::DisableBackButton();
-
- UI::ChangeWidget(`id(`aaEnableFrame), `Enabled, aaEnabled);
-
- while( true ) {
-
- symbol ret = (symbol) UI::UserInput();
-
- if ( ret == `abort || ret == `cancel || ret == `next) {
- break;
- } else if (ret == `aaState ) {
-
- // Set AppArmor state: enabled|disabled
- boolean requestedAaState = (boolean) UI::QueryWidget(`id(`aaState), `Value);
-
- aaEnabled = changeAppArmorState(requestedAaState);
-
- // These will match if the update was successful
- if ( aaEnabled == requestedAaState ) {
- UI::ChangeWidget(`id(`aaEnableFrame), `Enabled, aaEnabled);
- }
-
- } else if (ret == `ntconf ) {
- displayNotifyForm();
-
- } else if (ret == `modeconf ) {
-
- profileModeConfigForm();
-
- //displayAppArmorConfig();
-
- } else {
- y2error("Unexpected return code: " + tostring(ret));
- }
- }
-
- UI::CloseDialog();
- return nil;
-}
-
-/* EOF */
-}
--- /dev/null
+++ b/src/scrconf/aaconf.scr
@@ -0,0 +1,20 @@
+/**
+ * File:
+ * subdomain.scr
+ * Summary:
+ * SCR Agent for configuring subdomain
+ * Access:
+ * read/write
+ * Authors:
+ * David Drewelow
+ * See:
+ * libscr
+ * Example:
+ * Read(.cron,$[..])
+ *
+ * $Id: sdconf.scr 3715 2005-01-19 09:06:05Z sarnold $
+ *
+ */
+.sdconf
+
+`ag_sd_config ()
--- /dev/null
+++ b/src/scrconf/apparmor.scr
@@ -0,0 +1,20 @@
+/**
+ * File:
+ * subdomain.scr
+ * Summary:
+ * SCR Agent for configuring subdomain
+ * Access:
+ * read/write
+ * Authors:
+ * David Drewelow
+ * See:
+ * libscr
+ * Example:
+ * Read(.cron,$[..])
+ *
+ * $Id: subdomain.scr 3715 2005-01-19 09:06:05Z sarnold $
+ *
+ */
+.subdomain
+
+`ag_subdomain ()
--- /dev/null
+++ b/src/scrconf/apparmor_profiles.scr
@@ -0,0 +1,53 @@
+/**
+ * File:
+ * target.scr
+ * Summary:
+ * SCR Agent for interfacing with (shell) commands of the target system
+ * and reading/writing files.
+ * Access:
+ * read/write/execute
+ * Authors:
+ * Unknown
+ * See:
+ * libscr
+ * man bash
+ * source/y2a_system/doc/systemagent.txt
+ * Example:
+ * Execute (.target.bash, "uname -a")
+ * (0)
+ **
+ * Execute (.target.bash_output, "uname -a")
+ * (
+ * $[
+ * "exit":0,
+ * "stderr":"",
+ * "stdout":"Linux steiner 2.2.18 #1 Fri Jan 19 22:10:35 GMT 2001 i686 unknown\n"
+ * ]
+ * )
+ **
+ * Read(.target.dir, "/")
+ * (["usr", "tmp", "floppy", "var", "root", "opt", "home", "etc", ...])
+ **
+ * Write(.target.string, "/tmp/target.1", "Some Test\n")
+ * (true)
+ **
+ * Read(.target.string, "/tmp/target.1")
+ * ("Some Test\n")
+ *
+ * $Id: subdomain_profiles.scr 3715 2005-01-19 09:06:05Z sarnold $
+ *
+ * The target-agent is used for various actions on the target system.
+ *
+ * The Execute Interface can be used to execute some predefined commands
+ * like mount, umount, mkdir, remove, modprobe ... or arbitrary commands
+ * using the bash, bash_output or bash_background.
+ *
+ * The Read and Write interface can be used to access the target
+ * filesystem, most prominent reading or writing whole files using the
+ * "string" subpath.
+ *
+ * For more information see the agent's own documentation.
+ */
+.subdomain_profiles
+
+`ag_subdomain_profiles ()
--- a/src/scrconf/sdconf.scr
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * File:
- * subdomain.scr
- * Summary:
- * SCR Agent for configuring subdomain
- * Access:
- * read/write
- * Authors:
- * David Drewelow
- * See:
- * libscr
- * Example:
- * Read(.cron,$[..])
- *
- * $Id: sdconf.scr 3715 2005-01-19 09:06:05Z sarnold $
- *
- */
-.sdconf
-
-`ag_sd_config ()
--- a/src/scrconf/subdomain.scr
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * File:
- * subdomain.scr
- * Summary:
- * SCR Agent for configuring subdomain
- * Access:
- * read/write
- * Authors:
- * David Drewelow
- * See:
- * libscr
- * Example:
- * Read(.cron,$[..])
- *
- * $Id: subdomain.scr 3715 2005-01-19 09:06:05Z sarnold $
- *
- */
-.subdomain
-
-`ag_subdomain ()
--- a/src/scrconf/subdomain_profiles.scr
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * File:
- * target.scr
- * Summary:
- * SCR Agent for interfacing with (shell) commands of the target system
- * and reading/writing files.
- * Access:
- * read/write/execute
- * Authors:
- * Unknown
- * See:
- * libscr
- * man bash
- * source/y2a_system/doc/systemagent.txt
- * Example:
- * Execute (.target.bash, "uname -a")
- * (0)
- **
- * Execute (.target.bash_output, "uname -a")
- * (
- * $[
- * "exit":0,
- * "stderr":"",
- * "stdout":"Linux steiner 2.2.18 #1 Fri Jan 19 22:10:35 GMT 2001 i686 unknown\n"
- * ]
- * )
- **
- * Read(.target.dir, "/")
- * (["usr", "tmp", "floppy", "var", "root", "opt", "home", "etc", ...])
- **
- * Write(.target.string, "/tmp/target.1", "Some Test\n")
- * (true)
- **
- * Read(.target.string, "/tmp/target.1")
- * ("Some Test\n")
- *
- * $Id: subdomain_profiles.scr 3715 2005-01-19 09:06:05Z sarnold $
- *
- * The target-agent is used for various actions on the target system.
- *
- * The Execute Interface can be used to execute some predefined commands
- * like mount, umount, mkdir, remove, modprobe ... or arbitrary commands
- * using the bash, bash_output or bash_background.
- *
- * The Read and Write interface can be used to access the target
- * filesystem, most prominent reading or writing whole files using the
- * "string" subpath.
- *
- * For more information see the agent's own documentation.
- */
-.subdomain_profiles
-
-`ag_subdomain_profiles ()