Author: openvasfelix Date: Thu Feb 11 09:41:25 2010 New Revision: 60794 URL: http://svn.opensuse.org/viewcvs/yast?rev=60794&view=rev Log: Extend module with a checkbox to influence sync cron job. * agents/openvas-security-scanner.scr: Use * /etc/sysconfig/openvas-scanner. * src/helps.ycp: Added help text regarding daily feed sync. * src/OpenvasSecurityScanner.ycp: Added global variable, read and write the daily_sync variable. * src/openvas-feed-sync.cron.daily: Made functional, cosmetics. * src/dialogs.ycp: Added checkbox for sync cron job configuration, check for empty user login name. Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/agents/openvas-security-scanner.scr branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/OpenvasSecurityScanner.ycp branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/dialogs.ycp branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/helps.ycp branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/openvas-feed-sync.cron.daily Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/agents/openvas-security-scanner.scr URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/agents/openvas-security-scanner.scr?rev=60794&r1=60793&r2=60794&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/agents/openvas-security-scanner.scr (original) +++ branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/agents/openvas-security-scanner.scr Thu Feb 11 09:41:25 2010 @@ -2,7 +2,7 @@ * File: * openvas_security_scanner.scr * Summary: - * SCR Agent for reading/writing /etc/openvas/openvas_security_scanner_config + * SCR Agent for reading/writing /etc/sysconfig/openvas-scanner * using the ini-agent * Access: * read/write @@ -17,8 +17,8 @@ * $**Id$ */ -.etc.openvas.openvas_security_scanner_config +.etc.sysconfig.openvas-scanner `ag_ini( - `SysConfigFile( "/etc/openvas/openvas_security_scanner.config") + `SysConfigFile( "/etc/sysconfig/openvas-scanner") ) Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/OpenvasSecurityScanner.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/OpenvasSecurityScanner.ycp?rev=60794&r1=60793&r2=60794&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/OpenvasSecurityScanner.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/OpenvasSecurityScanner.ycp Thu Feb 11 09:41:25 2010 @@ -57,6 +57,11 @@ global any feed_choice = ""; /** + * Whether or not the user choose to daily synchronize with feed via a cron job. + */ +global boolean daily_sync = false; + +/** * Hold the path to where to install the GSF files from. */ global string gsf_location = ""; @@ -174,10 +179,12 @@ Progress::NextStage (); sleep (sl); - feed_choice = SCR::Read (.etc.openvas.openvas_security_scanner_config.feed); + feed_choice = SCR::Read (.etc.sysconfig.openvas-scanner.feed); if (feed_choice == nil) feed_choice = "No Feed"; + daily_sync = (SCR::Read (.etc.sysconfig.openvas-scanner.daily_sync) == "yes"); + return true; } @@ -209,8 +216,10 @@ if (PollAbort ()) return false; Progress::NextStage (); /* Error message */ - if (!SCR::Write (.etc.openvas.openvas_security_scanner_config.feed, feed_choice) - || !SCR::Write (.etc.openvas.openvas_security_scanner_config, nil)){ + if (!SCR::Write (.etc.sysconfig.openvas-scanner.feed, feed_choice) + || !SCR::Write (.etc.sysconfig.openvas-scanner.daily_sync, daily_sync ? "yes" : "no") + || !SCR::Write (.etc.sysconfig.openvas-scanner, nil)){ + SCR::Write (.etc.sysconfig.openvas-scanner, nil); Report::Error (_("Cannot write OpenVAS Security Scanner settings.")); } @@ -417,6 +426,8 @@ /** * Deactivate the GSF, remove access key and synchronization script. + * + * @return TRUE is not aborted, false otherwise. */ global boolean DeactivateGSF () { /* Deactivate Greenbone Security Feed dialog caption */ Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/dialogs.ycp?rev=60794&r1=60793&r2=60794&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/dialogs.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/dialogs.ycp Thu Feb 11 09:41:25 2010 @@ -82,13 +82,20 @@ } // Disable the "Sync Now" button if no feed is selected / the OpenVAS service is disabled. + term feed_management_box = `VBox(); term sync_now_button = (no_feed_selected) ? `PushButton(`id(`feedsync_now), `opt(`disabled), _("&Synchronize with Feed now")) : `PushButton(`id(`feedsync_now), `opt(`notify), _("&Synchronize with Feed now")); + feed_management_box = add (feed_management_box, sync_now_button); + + term croncheckbox = `CheckBox(`id(`cronjob), `opt(`notify), _("Do a da&ily feed synchronization"), OpenvasSecurityScanner::daily_sync); + + feed_management_box = add (feed_management_box, croncheckbox); + integer w = 38; term contents = `VBox (`Frame ("Security Scanner Service", `MinSize (w, 0, radio_box)), `VSpacing (1), `Frame ("Professional Feed Subscriptions", `MinSize (w, 0, gsf_box)), `VSpacing (1), - `Frame ("Manual Feed Management", `MinSize (w, 0, `VBox (sync_now_button))), `VSpacing (1) ); + `Frame ("Feed Management", `MinSize (w, 0, feed_management_box)), `VSpacing (1) ); Wizard::SetContentsButtons (caption, contents, HELPS["configuration"]:"", @@ -117,6 +124,10 @@ else if (ret == `gsf) choice = "Greenbone Security Feed"; + /** @todo Check whether cronjob script is installed, not allow/ grey out choice otherwise. */ + ret = UI::QueryWidget (`id(`cronjob), `Value); + OpenvasSecurityScanner::daily_sync = (boolean) ret; + /* Check whether the feed-choice changed, do nothing if so */ if (OpenvasSecurityScanner::feed_choice == choice) ret = `write; @@ -232,7 +243,6 @@ * Dialog to create an (openvas) user. * * @return Yet unused next or abort. - * @todo Implement behaviour based on choice (return). */ any AddUserDialog () { string caption = _("Add User to OpenVAS Security Scanner"); @@ -244,7 +254,7 @@ contents = add (contents, `Password(`id(`user_pass_again), _("P&assword for user (again)"), "")); Wizard::SetContentsButtons (caption, contents, - HELPS["adduser"]:"", // @todo Create and reference help text + HELPS["adduser"]:"", // @todo Improve help text and label Label::BackButton(), Label::NextButton()); Wizard::DisableBackButton (); @@ -259,23 +269,27 @@ } else if (ret == `next) { - /* Assuming location is correct */ any login = UI::QueryWidget(`id(`user_login), `Value); any pw1 = UI::QueryWidget(`id(`user_pass), `Value); any pw2 = UI::QueryWidget(`id(`user_pass_again), `Value); + if (login == nil || login == "") + { + Popup::Message(_("User name must not be empty.")); + continue; + } if (pw1 == pw2) { string addUserCmd = "printf \"" + (string) login + "\n\n" + (string) pw1 + "\n" + (string) pw2 + "\n\n\" | openvas-adduser"; integer ret = (integer) SCR::Execute (.target.bash, addUserCmd); - if (ret != 0) Popup::Message ("Error creating user, try to create it yourself with openvas-adduser and inspect messages."); + if (ret != 0) Popup::Message (_("Error creating user, try to create it yourself with openvas-adduser and inspect messages.")); Wizard::RestoreBackButton (); return `next; } else { - Popup::Message("Must enter equal passwords"); + Popup::Message(_("Must enter equal passwords")); continue; } break; Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/helps.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/helps.ycp?rev=60794&r1=60793&r2=60794&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/helps.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/helps.ycp Thu Feb 11 09:41:25 2010 @@ -67,6 +67,10 @@ // Synchronize with Feed now + "</p><p><b>" + _("Synchronize with Feed now") + "</b>: " + _("Will immediately start a synchronize with the selected feed. Note that this option is not available if you just changed the feed. ") + // Do a daily feed synchronization + + "</p><p><b>" + _("Do a daily feed synchronization") + "</b>: " + + _("Will enable the daily feed synchronization with a cron job, if a feed was chosen and the service is enabled. Note that the openvas scanner service will then be restarted daily, too.") + // Next + "</p><p><b>" + _("Next") + "</b>: " + _("Click on \"Next\" to synchronize with a newly chosen feed.") @@ -133,9 +137,6 @@ <p><b>Password for user</b>: Type the password for the user here.</p> <p><b>Password for user (again)</b>: Type the password for the user here, again.</p> </p>") -/*_("Login of the user"), "")); - contents = add (contents, `Password(`id(`user_pass), _("Password for user"), "")); - contents = add (contents, `Password(`id(`user_pass_again), _("Password for user (again)"), ""));*/ ]; Modified: branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/openvas-feed-sync.cron.daily URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/openvas-feed-sync.cron.daily?rev=60794&r1=60793&r2=60794&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/openvas-feed-sync.cron.daily (original) +++ branches/SuSE-Code-11-SP1-Branch/openvas-security-scanner/src/openvas-feed-sync.cron.daily Thu Feb 11 09:41:25 2010 @@ -5,39 +5,43 @@ . /etc/sysconfig/openvas-scanner -# Check for missing binaries (stale symlinks should not happen) +# Check for missing binaries (stale symlinks should not happen). OPENVASSD_BIN=/usr/sbin/openvassd test -x $OPENVASSD_BIN || { echo "$OPENVASSD_BIN not installed"; exit 1; } -# Check for existence of needed config file and read it +# Check for existence of needed config file and read it. OPENVASSD_CONFIG=/etc/sysconfig/openvas-scanner test -r $OPENVASSD_CONFIG || { echo "$OPENVASSD_CONFIG not existing"; exit 1; } -# Read config +# Read config. . $OPENVASSD_CONFIG -# Check whether a feed was chosen via the YaST Module -[ -n "$feed" ] || { echo "No Feed subscription was chosen"; - exit 1; } +# Check whether a feed was chosen via the YaST Module. +[ -n "$feed" ] || exit 0; + +# "No Feed" chosen, exit successfully. +[ "$feed" = "No Feed" ] && exit 0; -# Check whether synchronization should take place -[ -n "$dailysync" ] || { echo "Not specified whether to synchronize or not"; +# Check whether synchronization should take place. +[ -n "$daily_sync" ] || { echo "Not specified whether to synchronize or not"; exit 1; } -# TODO Check value of dailysync, exit 0 if shouldnt sync +# Not chosen to do a daily sync, just exit successfully. +[ "$daily_sync" = "yes" ] || { + exit 0; } -# Check which feed was chosen and sync with feed +# Check which feed was chosen and sync with feed. feed_sync_script="" [ "$feed" = "OpenVAS NVT Feed" ] && [ -x /usr/sbin/openvas-nvt-sync ] && feed_sync_script=/usr/sbin/openvas-nvt-sync [ "$feed" = "Greenbone Security Feed" ] && [ -x /usr/sbin/greenbone-nvt-sync ] && feed_sync_script=/usr/sbin/greenbone-nvt-sync [ -n "$feed_sync_script" ] || { echo "Unknown feed chosen."; - exit 1 + exit 1; } $feed_sync_script -exit 0 +exit 0; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org