Author: jdsn
Date: Fri Feb 8 20:04:04 2008
New Revision: 44314
URL: http://svn.opensuse.org/viewcvs/yast?rev=44314&view=rev
Log:
merged yep support from SP2 branch, cleanup
Added:
trunk/registration/src/modules/RegisterCert.pm
Modified:
trunk/registration/src/clients/inst_suse_register.ycp
trunk/registration/src/clients/suse_register_auto.ycp
trunk/registration/src/config/registration.rnc
trunk/registration/src/modules/Makefile.am
trunk/registration/src/modules/Register.ycp
Modified: trunk/registration/src/clients/inst_suse_register.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/registration/src/clients/inst_suse_register.ycp?rev=44314&r1=44313&r2=44314&view=diff
==============================================================================
--- trunk/registration/src/clients/inst_suse_register.ycp (original)
+++ trunk/registration/src/clients/inst_suse_register.ycp Fri Feb 8 20:04:04 2008
@@ -33,6 +33,16 @@
import "Package";
import "PackageCallbacks";
+
+ // this operation MUST be first and run in any case, even if registration should be skipped (FATE #302966)
+ symbol confRegSrv = Register::configureRegistrationServer();
+ if (confRegSrv == `conferror || confRegSrv == `notrust || confRegSrv == `silentskip)
+ {
+ y2debug("Registration can not be run due to YEP configuration error.");
+ return `auto;
+ }
+
+
// no network - no suse_register
if (!Mode::normal())
{
@@ -110,6 +120,8 @@
the configuration on the opened Web site.");
+ string title_regularly_run = _("Regularly Synchronize with the Customer Center");
+
/* string for show information popup */
string transmit_info = _("Registration and Privacy Information");
@@ -170,8 +182,15 @@
the transmitted information in the log file <tt>~/.suse_register.log</tt>.
</p>");
-string help = help_title + help_para1 + help_para2 + (Register::display_forcereg ? help_para3:"") + help_para4;
+string help_para5 = _("<p>
+<b>Regularly Synchronize with the Customer Center</b> checks that your update
+sources are still valid and adds any new ones that may be available.
+It additionally sends any modifications to your included data to Novell, such
+as hardware information if <b>Hardware Information</b> is activated.
+This option does not remove any sources added manually.
+</p>");
+string help = help_title + help_para1 + help_para2 + (Register::display_forcereg ? help_para3:"") + help_para4;
/* further strings */
@@ -209,6 +228,9 @@
`VSpacing(0.5),
`Right( `PushButton(`id(`showinfo), nccc_sub_showbtn ) )
) ) ) ,
+ // active in SLE products only - merged here for consistency
+ //`VSpacing(0.5),
+ //`Left( `CheckBox(`id(`regularly_run), `opt(`notify), title_regularly_run, Register::register_regularly ) ),
`VSpacing(0.5)
)))
));
@@ -292,9 +314,9 @@
/* ^^ END CCC ERROR ^^ */
- /* vv CCC ERROR POPUP PLAINTEXT vv */
+ /* vv CCC ERROR POPUP PLAINTEXT vv */
term error_message_details_pt=
- `MinSize( 50, 15, `VBox(
+ `MinSize( 60, 20, `VBox(
`Left( `Label( `opt(`boldFont), error_msg ) ),
`VSpacing( 0.5 ),
`RichText(`id(`errordetail), `opt(`plainText), "" ),
@@ -501,7 +523,7 @@
if (Register::use_proxy)
{
- // (#165891)
+ // (#165891) - (#208651) fixed in Register.ycp
bcmd = " http_proxy='" + Register::http_proxy + "' " + bcmd;
bcmd = " https_proxy='" + Register::https_proxy + "' " + bcmd;
}
@@ -583,11 +605,12 @@
{
configure_status = (boolean) UI::QueryWidget(`id(`configure), `Value);
}
- else if (ret == `hwinfo || ret == `optional || ret == `forcereg)
+ else if (ret == `hwinfo || ret == `optional || ret == `forcereg || ret == `regularly_run )
{
Register::submit_hwdata = (boolean) UI::QueryWidget(`id(`hwinfo), `Value);
Register::submit_optional= (boolean) UI::QueryWidget(`id(`optional), `Value);
Register::force_registration = (boolean) UI::QueryWidget(`id(`forcereg), `Value);
+ Register::register_regularly = (boolean) UI::QueryWidget(`id(`regularly_run), `Value);
}
else if (ret == `showinfo)
{
Modified: trunk/registration/src/clients/suse_register_auto.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/registration/src/clients/suse_register_auto.ycp?rev=44314&r1=44313&r2=44314&view=diff
==============================================================================
--- trunk/registration/src/clients/suse_register_auto.ycp (original)
+++ trunk/registration/src/clients/suse_register_auto.ycp Fri Feb 8 20:04:04 2008
@@ -81,6 +81,16 @@
summary = Summary::CloseList(summary);
}
+ if ( Register::yep_server != "")
+ {
+ summary = Summary::AddHeader (summary, _("YEP Server Settings") );
+ summary = Summary::OpenList(summary);
+ summary = Summary::AddListItem (summary, sformat(_("YEP Server: %1"), Register::yep_server) );
+ if ( Register::yep_server_cert != "")
+ summary = Summary::AddListItem (summary, sformat(_("YEP Certificate: %1"), Register::yep_server_cert) );
+ summary = Summary::CloseList(summary);
+ }
+
return summary;
}
@@ -177,14 +187,24 @@
string help_text_caption = sformat("<p><b>%1</b></p>", caption);
string help_text_para1 = _("<p>Product registration includes your product in Novell's database, enabling you to get online updates and technical support. To register while installing automatically, select <b>Run Product Registration</b>. To simplify the procedure, include information from your system with <b>Hardware Profile</b> and <b>Optional Information</b>.</p>");
string help_text_para2 = _("<p>Get more information about the registration process with <tt>suse_register -h</tt>.</p>");
- string help_text_para3 = _("<p>Other information used for registration is shown in <b>Registration Data</b>. Add a new key and value pair by pressing <b>Add</b> then entering the appropriate values. These parameters are those that can be passed with <tt>suse_register -a</tt>. Get more information about them with <tt>suse_register -p</tt>. Remove a pair with <b>Delete</b> or modify an existing pair with <b>Edit</b>.</p>");
+ string help_text_para3 = _("<p>Other information used for registration is shown in <b>Registration Data</b>.<br>Add a new key and value pair by pressing <b>Add</b> and then entering the appropriate values. These parameters are the ones that can be passed with <tt>suse_register -a</tt>.<br>Get more information about them with <tt>suse_register -p</tt>. Remove a pair with <b>Delete</b> or modify an existing pair with <b>Edit</b>.</p>");
+
+ string help_text_para4 = _("<p>If your network deploys a custom YEP server, please set the URL of the YEP Server and the location of the YEP Certificate in <b>YEP Server Settings</b>. Please see your YEP manual for further assistance.</p>");
- string help_text = help_text_caption + help_text_para1 + help_text_para2 + help_text_para3;
- term contents = `VBox(
- `VBox (
- // Translators: Text for UI Label - capitalized
- `Left( `CheckBox(`id(`run), `opt(`notify), _("Run Product Registration"), false )),
+ string help_text = help_text_caption + help_text_para1 + help_text_para2 + help_text_para3 + help_text_para4;
+
+ term yepsettings = `VBox(
+ // Translators: Text for UI Label - capitalized
+ `Left( `Label(_("YEP Server Settings"))),
+ // Translators: Text for UI Label - capitalized
+ `TextEntry(`id(`yepurl), `opt(`hstretch, `notify), _("YEP Server"), ""),
+ // Translators: Text for UI Label - capitalized
+ `TextEntry(`id(`yepcert), `opt(`hstretch, `notify), _("YEP Certificate"), "")
+ );
+
+ term regsettings = `VBox(
+ `Left( `CheckBox(`id(`run), `opt(`notify), _("Run Product Registration"), false )),
`HBox( `HSpacing (3.0) , `VBox(
// Translators: Text for UI Label - capitalized
`Left( `Label( _("Include in Registration") ) ),
@@ -192,13 +212,18 @@
`Left( `CheckBox(`id(`sub_hw), `opt(`notify), _("Hardware Profile"), false )),
// Translators: Text for UI Label - capitalized
`Left( `CheckBox(`id(`sub_opt), `opt(`notify), _("Optional Information"), false ))
- ))
- ),
+ )
+ ),
+ `VSpacing(1));
+
+
+ term contents = `VBox(
+ `HBox ( regsettings, yepsettings ),
`VBox ( `VSpacing(0.5),
// Translators: Text for UI Label - capitalized
`Left( `Label( _("Registration Data to Use")) ),
`MinSize(10,5, `Table( `id(`table), `opt(`notify, `vstretch) , `header( _("Key"), _("Value")), [] )),
- `HBox(
+ `HBox(
`PushButton(`id(`add), _("Ad&d")),
`PushButton(`id(`edit), `opt(`disabled), _("&Edit")),
`PushButton(`id(`delete), `opt(`disabled), _("De&lete"))
@@ -226,6 +251,8 @@
UI::ChangeWidget(`id(`run), `Value, Register::do_registration);
UI::ChangeWidget(`id(`sub_hw ), `Value, Register::submit_hwdata);
UI::ChangeWidget(`id(`sub_opt), `Value, Register::submit_optional);
+ UI::ChangeWidget(`id(`yepurl), `Value, Register::yep_server);
+ UI::ChangeWidget(`id(`yepcert), `Value, Register::yep_server_cert);
integer items=size(table_items);
UI::ChangeWidget(`id(`edit), `Enabled, items > 0);
UI::ChangeWidget(`id(`delete), `Enabled, items > 0);
@@ -298,9 +325,35 @@
}
else if ( ret == `abort || ret == `cancel )
{
- if(Popup::ReallyAbort(true)) break;
- else continue;
- }
+ if(Popup::ReallyAbort(true)) break;
+ else continue;
+ }
+ else if ( ret == `next )
+ {
+ string yepServer = (string) UI::QueryWidget(`id(`yepurl), `Value);
+ string yepServerCert = (string) UI::QueryWidget(`id(`yepcert), `Value);
+
+ if ( (! regexpmatch(yepServer, "^https://.+") && yepServer != "" ) ||
+ ( yepServer == "" && yepServerCert != "" )
+ )
+ {
+ Popup::Message(_("YEP Server URL must start with https://"));
+ ret = nil;
+ }
+
+ if (! regexpmatch(yepServerCert, "^(https?|ftp)://.+") &&
+ ! regexpmatch(yepServerCert, "^floppy/.+") &&
+ ! regexpmatch(yepServerCert, "^/.+") &&
+ ! regexpmatch(yepServerCert, "^(ask|done)$") &&
+ yepServerCert != ""
+ )
+ {
+ Popup::Message(_("Location of YEP Certificate invalid.\nPlease see your YEP documentation."));
+ ret = nil;
+ }
+ Register::yep_server = yepServer;
+ Register::yep_server_cert = yepServerCert;
+ }
// refresh counter and buttons
items = size(table_items);
@@ -326,6 +379,8 @@
y2debug("submit_hwdata: %1", Register::submit_hwdata);
y2debug("submit_optional: %1", Register::submit_optional);
y2debug("registration_data: %1", Register::registration_data);
+ y2debug("yep_server: %1", Register::yep_server);
+ y2debug("yep_server_cert: %1", Register::yep_server_cert);
}
UI::CloseDialog();
Modified: trunk/registration/src/config/registration.rnc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/registration/src/config/registration.rnc?rev=44314&r1=44313&r2=44314&view=diff
==============================================================================
--- trunk/registration/src/config/registration.rnc (original)
+++ trunk/registration/src/config/registration.rnc Fri Feb 8 20:04:04 2008
@@ -2,10 +2,13 @@
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace config = "http://www.suse.com/1.0/configns"
-suse_register = element suse_register { do_registration? & submit_hwdata? & submit_optional? & registration_data? }
+suse_register = element suse_register { do_registration? & submit_hwdata? & submit_optional? & registration_data? & register_regularly? & yep_server? & yep_server_cert? }
do_registration = element do_registration { BOOLEAN }
submit_hwdata = element submit_hwdata { BOOLEAN }
submit_optional = element submit_optional { BOOLEAN }
+register_regularly = element register_regularly { BOOLEAN }
+yep_server = element yep_server { text }
+yep_server_cert = element yep_server_cert { text }
registration_data =
Modified: trunk/registration/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/registration/src/modules/Makefile.am?rev=44314&r1=44313&r2=44314&view=diff
==============================================================================
--- trunk/registration/src/modules/Makefile.am (original)
+++ trunk/registration/src/modules/Makefile.am Fri Feb 8 20:04:04 2008
@@ -2,7 +2,7 @@
# Makefile.am for registration/modules
#
-module_DATA = Register.ycp
+module_DATA = Register.ycp RegisterCert.pm
EXTRA_DIST = $(module_DATA)
Modified: trunk/registration/src/modules/Register.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/registration/src/modules/Register.ycp?rev=44314&r1=44313&r2=44314&view=diff
==============================================================================
--- trunk/registration/src/modules/Register.ycp (original)
+++ trunk/registration/src/modules/Register.ycp Fri Feb 8 20:04:04 2008
@@ -18,9 +18,12 @@
import "Misc";
import "Stage";
import "Label";
+import "Popup";
+import "URL";
+import "Linuxrc";
import "ProductFeatures";
import "SourceManager";
-
+import "RegisterCert";
// --------------------------------------------------------------
@@ -45,10 +48,13 @@
global boolean submit_hwdata = false;
global boolean force_registration = false;
global boolean display_forcereg = false;
+global boolean register_regularly = false; // (FATE #301822)
global boolean disable_w3m = false;
global boolean use_proxy = false;
global string http_proxy = "";
global string https_proxy = "";
+global string yep_server = ""; // (FATE #302966)
+global string yep_server_cert = ""; // (FATE #302966)
global map registration_data = $[];
@@ -78,6 +84,534 @@
}
+
+/*
+ * mountFloppy()
+ *
+ * mount a floppy disk
+ * @return map with status information
+ *
+ */
+map mountFloppy()
+{
+ // floppy mount support (FATE #303335)
+ list drives = (list) SCR::Read(.probe.floppy);
+
+ if ( size(drives) == 0 )
+ {
+ return $[ "mounted" : false ];
+ }
+
+ string fddevice = drives[0, "dev_name"]:"/dev/fd0";
+ string tmpdir = (string) SCR::Read(.target.tmpdir);
+ if (tmpdir == nil) tmpdir = "/tmp";
+ string mpoint = tmpdir + "/fd";
+
+ // create mount point directory
+ SCR::Execute(.target.mkdir, mpoint);
+
+ y2milestone("Trying to mount %1 as floppy drive to load the YEP certificate file from.", fddevice);
+
+ boolean result = (boolean) SCR::Execute(.target.mount, [fddevice, mpoint], "-o ro" );
+
+ return $[ "mounted" : result, "mpoint" : mpoint, "device" : fddevice ];
+}
+
+
+
+/*
+ * umountFloppy()
+ *
+ * umount a floppy disk
+ * @return void
+ *
+ */
+void umountFloppy(string mpoint)
+{
+ if (mpoint == nil || mpoint == "") return;
+ SCR::Execute(.target.umount, mpoint);
+}
+
+
+/*
+ * certificateError()
+ *
+ * report error messages if YEP certificate file is not found
+ * @return symbol yes, no or retry
+ *
+ */
+symbol certificateError(string heading, symbol type)
+{
+ if (heading == nil || heading == "") heading = _("Unknown error");
+
+ string errorrMessage = "";
+ string question = _("Do you want to skip Registration?");
+ string otherwise = sformat( _("If you select %1 the Registration will most likely fail.
+Otherwise you may copy the certificate file to the system manually
+and then specify its path by choosing %2."), deletechars(Label::ContinueButton(), "&"), deletechars(Label::FileName(), "&") );
+ string errorMessage = "";
+
+ if (type == `floppy)
+ {
+ errorMessage = _("Could not load the YEP certificate file from floppy disk.");
+ }
+ else if (type == `url)
+ {
+ errorMessage = _("Could not download the YEP certificate file from specified URL.");
+ }
+ else if (type == `file)
+ {
+ errorMessage = _("Could not find the YEP certificate file in specified path.");
+ }
+ else
+ {
+ errorMessage = _("Unknown error occurred while retrieving YEP certificate file");
+ }
+
+ errorMessage = errorMessage + "\n\n" + question + "\n\n" + otherwise;
+ return Popup::AnyQuestion3(heading, errorMessage, _("Skip"), Label::ContinueButton(), Label::FileName(), `focus_yes );
+}
+
+
+
+
+
+/*
+ * suseRegisterURL()
+ *
+ * get or set the suseRegisterURL
+ * @return current url
+ */
+string suseRegisterURL(string url)
+{
+ // nil, empty string, unparsable urls and non-https urls as parameter means 'get url' else 'set url'
+
+ string cururl = nil;
+ map urlmap = $[];
+ string suseRegisterConf = "/etc/suseRegister.conf";
+
+ SCR::RegisterAgent (.temporary_suseregister_agent, `ag_ini(
+ `IniAgent( suseRegisterConf,
+ $[
+ "options" : [ "line_can_continue", "global_values", "join_multiline", "comments_last", "flat" ],
+ "comments": [ "^[ \t]*#.*$", "^[ \t]*$" ],
+ "params" : [ $[ "match" : [ "([a-zA-Z0-9_-]+)[ \t]*=[ \t]*([^ \t]*)", "%s = %s" ] ] ]
+ ]
+ )));
+
+ // in case the yep server was already changed do not change it again (to support mobile PCs in different environments)
+ string mod = (string) SCR::Read(.temporary_suseregister_agent.yepurlmodified);
+ if ( mod == "true" )
+ {
+ url = nil;
+ y2milestone("YEP server has already been modified. I will not change it again.");
+ }
+
+ cururl = (string) SCR::Read(.temporary_suseregister_agent.url);
+ urlmap = URL::Parse(url);
+
+ if ( url != nil && url != "" && urlmap != $[] && urlmap["scheme"]:"" == "https" )
+ {
+ SCR::Write(.temporary_suseregister_agent.url, url);
+ cururl = (string) SCR::Read(.temporary_suseregister_agent.url);
+ if (url == cururl) SCR::Write(.temporary_suseregister_agent.yepurlmodified, "true");
+ }
+
+ SCR::UnregisterAgent (.temporary_suseregister_agent);
+ return cururl;
+}
+
+
+
+/*
+ * setupRegistrationServer()
+ *
+ * write YEP server settings to (FATE #302966)
+ * @return symbol that says if we can perform the registration
+ *
+ */
+symbol setupRegistrationServer(symbol mode)
+{
+ // in case yep_server is undefined nothing needs to be done
+ if (yep_server == nil || yep_server == "") return `ok;
+
+ boolean ay = false; // are we running in autoYaST mode?
+ boolean trust = false;
+ if (mode == `autoyast)
+ {
+ trust = true;
+ ay = true;
+ }
+
+ // check if yep_server is a valid url
+ map yep_server_parsed = URL::Parse(yep_server);
+ if (yep_server_parsed == $[] || yep_server_parsed["host"]:"" == "" || yep_server_parsed["scheme"]:"" != "https" )
+ {
+ y2milestone("The string '%1' could not be parsed and validated as URL to be used as YEP server.", yep_server);
+ if (ay) return `conferror;
+
+ string no_yep_server = sformat( _("The YEP server URL could not be validated as URL.
+Registration can not be performed. Please modify /etc/suseRegister.conf and run Registration manually.
+The YEP server URL that was configured was
+%1"), yep_server);
+ Popup::Message(no_yep_server);
+ return `conferror;
+ }
+
+
+ // write YEP server URL to /etc/suseRegister.conf
+ if (yep_server == suseRegisterURL(yep_server) )
+ { y2milestone("Setup custom YEP server as registration server successful: %1", yep_server); }
+ else
+ { y2error("Failed to setup custom YEP server as registration server: %1", yep_server); }
+
+
+
+ // ----------===============================================-------------- //
+
+ symbol certmode = nil;
+
+ // never ever load a certificate file for a *.novell.com yep server
+ if ( regexpmatch(yep_server_parsed["host"]:"", ".+\.novell\.com$")) { certmode = `none; }
+ else if (yep_server_cert == nil || yep_server_cert == "") { certmode = `url; }
+ else if ( regexpmatch(yep_server_cert, "^(https?|ftp)://.+") ) { certmode = `url; }
+ else if ( regexpmatch(yep_server_cert, "^floppy/.+") ) { certmode = `floppy; }
+ else if ( regexpmatch(yep_server_cert, "^/.+") ) { certmode = `path; }
+ else if ( regexpmatch(yep_server_cert, "^ask$") ) { certmode = `ask; }
+ else if ( regexpmatch(yep_server_cert, "^done$") ) { certmode = `done; }
+ else { certmode = `none; }
+
+
+ if (! contains([`none, `done, `url, `floppy, `ask, `path], certmode) )
+ {
+ y2error("No YEP certificate file retrieval-mode found to handle current configuration. This should not happen!");
+ return `conferror;
+ }
+
+ string certTmpFile = sformat("%1/__tmpYEPcert.crt", SCR::Read(.target.tmpdir));
+
+
+ if ( certmode == `url )
+ {
+ map certParse = URL::Parse(yep_server_cert);
+
+ // if no yep_server_cert is passed then we fall back to predefined yep_server_cert
+ if (yep_server_cert == nil || yep_server_cert == "" || certParse == $[])
+ {
+ map certUrl = yep_server_parsed;
+ certUrl["scheme"] = "http";
+ certUrl["port"] = "80";
+ certUrl["path"] = "/yep.crt";
+ yep_server_cert = URL::Build(certUrl);
+ certParse=certUrl;
+
+ }
+ y2milestone("Using %1 as URL to download the YEP certificate file.", yep_server_cert);
+
+ // download cert
+ string curlcmd = sformat("curl -f --connect-timeout 60 --max-time 120 '%1' -o %2", yep_server_cert, certTmpFile);
+ if ( SCR::Execute (.target.bash, curlcmd) != 0)
+ {
+ y2error("Could not download the YEP certificate file from specified URL %1", yep_server_cert);
+ if (ay) return `conferror;
+
+ // translators: this is a heading for an error message - so no punctuation
+ string urlError = _("Downloading YEP certificate file failed");
+ symbol errret = certificateError( urlError, `url);
+
+ certTmpFile = nil;
+ }
+ }
+
+ if (certmode == `floppy)
+ {
+ // mount and copy
+ map mf = mountFloppy();
+ if (!mf["mounted"]:false)
+ {
+ umountFloppy(mf["mpoint"]:"/dev/fd0");
+ y2error("Could not mount floppy disk to copy the YEP certificte file from. The device that was used was %1", mf["device"]:"");
+ if (ay)
+ {
+ y2error("No YEP certificate file available. As we are in autoYaST mode Registration will be skipped. Please run it manually.");
+ return `silentskip;
+ }
+ else
+ {
+ // translators: this is a heading for an error message - so no punctuation
+ string fdMountError = _("Could not mount floppy disk");
+ symbol errret = certificateError( fdMountError, `floppy);
+
+ if ( errret == `yes )
+ {
+ y2warning("No YEP certificate could be retrieved (floppy mount error). User selected to skip Registration.");
+ return `silentskip;
+ }
+ else if ( errret == `no )
+ {
+ y2warning("No YEP certificate could be retrieved (floppy mount error). User selected to NOT skip Registration. Most likely Registration will fail now.");
+ return `ok;
+ }
+ else { certmode = `ask; }
+ }
+ }
+ else
+ {
+ string fdpath = regexpsub( yep_server_cert , "^floppy/(.+)$","\\1");
+ string cp2tmp = sformat("/bin/cp -a %1 %2 ", mf["mpoint"]:"/media/floppy" + "/" + fdpath, certTmpFile );
+ if ( SCR::Execute (.target.bash, cp2tmp) != 0)
+ {
+ y2error("Could not copy the specified YEP certificate file from floppy disk.");
+ if (ay) return `silentskip;
+
+ // translators: this is a heading for an error message - so no punctuation
+ string fdCopyError = _("Could not read file floppy disk");
+ symbol errret = certificateError( fdCopyError, `floppy);
+
+ if ( errret == `yes )
+ {
+ y2warning("No YEP certificate could be retrieved (could not copy from floppy). User selected to skip Registration.");
+ return `silentskip;
+ }
+ else if ( errret == `no )
+ {
+ y2warning("No YEP certificate could be retrieved (could not copy from floppy). User selected to NOT skip Registration. Most likely Registration will fail now.");
+ return `ok;
+ }
+ else { certmode = `ask; }
+
+ }
+
+ umountFloppy(mf["mpoint"]:"/dev/fd0");
+ }
+
+ }
+
+ if (certmode == `path)
+ {
+ // try to copy cert if valid path, else ask // copy
+
+ string cp2tmp = sformat("/bin/cp -a %1 %2 ", yep_server_cert, certTmpFile );
+ if ( SCR::Execute(.target.bash, cp2tmp ) != 0 )
+ {
+ y2error("Could not copy local YEP certificate file");
+ if (ay) return `silentskip;
+
+ // translators: this is a heading for an error message - so no punctuation
+ string fileCopyError = _("Could find YEP certificate file in local path");
+ symbol errret = certificateError( fileCopyError, `file);
+ if ( errret == `yes )
+ {
+ y2warning("No YEP certificate could be retrieved (could not copy local file). User selected to skip Registration.");
+ return `silentskip;
+ }
+ else if ( errret == `no )
+ {
+ y2warning("No YEP certificate could be retrieved (could not copy local file). User selected to NOT skip Registration. Most likely Registration will fail now.");
+ return `ok;
+ }
+ else { certmode = `ask; }
+ }
+ }
+
+ if (certmode == `ask)
+ {
+ if (ay)
+ {
+ y2error("YEP certificate was configured to be asked for. AutoYaST does not support interactive dialogs. Registration will be skipped.");
+ return `silentskip;
+ }
+
+ string basepath = "/tmp";
+ string certFile = "";
+ string selectCertLabel = _("Select YEP certificate file");
+ boolean exitloop = false;
+
+ do
+ {
+ do
+ {
+ certFile = UI::AskForExistingFile(basepath, "*.crt", selectCertLabel);
+ } while (certFile == "");
+
+ if (certFile == nil)
+ {
+ string skipReg = _("Do you really want to cancel and thereby skip the Registration?");
+ if (Popup::YesNo(skipReg))
+ {
+ y2milestone("User selected to cancel manual certificate dialog and thereby skip registration");
+ return `conferror;
+ }
+ }
+
+ string cp2tmp = sformat("/bin/cp -a %1 %2 ", certFile , certTmpFile );
+ if (SCR::Execute(.target.bash, cp2tmp) == 0)
+ {
+ y2milestone("Found user specified YEP certificate file");
+ exitloop = true;
+ }
+ else
+ {
+ y2milestone("Could not copy local file as YEP certificate");
+ string fileErrorHeader = _("Could not copy certificate file");
+ string fileErrorMsg = _("Do you want to retry?");
+ if (!Popup::YesNoHeadline(fileErrorHeader, fileErrorMsg))
+ {
+ y2milestone("User selected to skip the setup of a YEP certificate");
+ return `conferror;
+ }
+ }
+
+ } while ( !exitloop );
+
+
+ }
+
+ if (certmode == `done)
+ {
+ y2milestone("User configured to do nothing to retrieve a YEP certificate file.");
+ y2milestone("I hope you know what you do. Registration will be run but may fail due to missing certificate.");
+ return `ok;
+ }
+
+ if (certmode == `none)
+ {
+ y2warning("The string that was passed to get the YEP certificate file does not match any handler.");
+ y2warning("The string was: %1", yep_server_cert);
+ y2warning("No certificate could be retrieved. Registration process will not be run!");
+ return `conferror;
+ }
+
+
+
+ // in autoYaST mode we automatically trust - we are done here
+ if ( trust || ay ) { return `ok; }
+
+ // ask user if he trusts the certificate
+ map cP = RegisterCert::parseCertificate(certTmpFile);
+ y2milestone("YEP certificate file information: %1", cP);
+
+ string trustQuestion = _("Do you want to trust this certificate?");
+ string trustMessage = _("This certificate will be used to connect to the YEP server.\nYou have to trust this certificate in order to continue with the Registration.");
+
+ string certInfo = "";
+ list issueList = (list) cP["ISSUER"]:[];
+ //translators: this is certificate context
+ certInfo = certInfo + _("<p><b>Issued For:</b></p>");
+ if (size (issueList) > 0)
+ {
+ certInfo = certInfo + "<pre>";
+ foreach (map keyval, (list