[yast-commit] r67501 - in /trunk/s390/src: dasd/dialogs.ycp modules/DASDController.ycp modules/ZFCPController.ycp zfcp/dialogs.ycp
Author: aschnell Date: Tue Feb 21 20:23:40 2012 New Revision: 67501 URL: http://svn.opensuse.org/viewcvs/yast?rev=67501&view=rev Log: - more input validation Modified: trunk/s390/src/dasd/dialogs.ycp trunk/s390/src/modules/DASDController.ycp trunk/s390/src/modules/ZFCPController.ycp trunk/s390/src/zfcp/dialogs.ycp Modified: trunk/s390/src/dasd/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/dasd/dialogs.ycp?rev=67501&r1=67500&r2=67501&view=diff ============================================================================== --- trunk/s390/src/dasd/dialogs.ycp (original) +++ trunk/s390/src/dasd/dialogs.ycp Tue Feb 21 20:23:40 2012 @@ -45,6 +45,7 @@ return ret ? `next : `abort; } + /** * Write settings dialog * @return `abort if aborted and `next otherwise @@ -56,6 +57,7 @@ return ret ? `next : `abort; } + /** * Get the list of items for the table of DASD devices * @param min_chan integer minimal channel number @@ -112,6 +114,7 @@ return items; } + /** * Draw the DASD dialog */ Modified: trunk/s390/src/modules/DASDController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/DASDController.ycp?rev=67501&r1=67500&r2=67501&view=diff ============================================================================== --- trunk/s390/src/modules/DASDController.ycp (original) +++ trunk/s390/src/modules/DASDController.ycp Tue Feb 21 20:23:40 2012 @@ -253,14 +253,14 @@ GetFilteredDevices() { list<string> min_strs = splitstring(filter_min, "."); - integer min_css = tointeger("0x" + min_strs[0]:"0"); - integer min_lcss = tointeger("0x" + min_strs[1]:"0"); - integer min_chan = tointeger("0x" + min_strs[2]:"0"); + integer min_css = tointeger("0x" + min_strs[0]:""); + integer min_lcss = tointeger("0x" + min_strs[1]:""); + integer min_chan = tointeger("0x" + min_strs[2]:""); list<string> max_strs = splitstring(filter_max, "."); - integer max_css = tointeger("0x" + max_strs[0]:"0"); - integer max_lcss = tointeger("0x" + max_strs[1]:"0"); - integer max_chan = tointeger("0x" + max_strs[2]:"0"); + integer max_css = tointeger("0x" + max_strs[0]:""); + integer max_lcss = tointeger("0x" + max_strs[1]:""); + integer max_chan = tointeger("0x" + max_strs[2]:""); map<integer, map<string, any> > ret = GetDevices(); @@ -271,10 +271,10 @@ max_css, max_lcss, max_chan); ret = filter(integer k, map<string, any> d, ret, { - list<string> tmp_strs = splitstring(d["channel"]:"0.0.0000", "."); - integer tmp_css = tointeger("0x" + tmp_strs[0]:"0"); - integer tmp_lcss = tointeger("0x" + tmp_strs[1]:"0"); - integer tmp_chan = tointeger("0x" + tmp_strs[2]:"0"); + list<string> tmp_strs = splitstring(d["channel"]:"", "."); + integer tmp_css = tointeger("0x" + tmp_strs[0]:""); + integer tmp_lcss = tointeger("0x" + tmp_strs[1]:""); + integer tmp_chan = tointeger("0x" + tmp_strs[2]:""); return tmp_css >= min_css && tmp_lcss >= min_lcss && tmp_chan >= min_chan && tmp_css <= max_css && tmp_lcss <= max_lcss && tmp_chan <= max_chan; @@ -307,7 +307,7 @@ { integer ret = nil; foreach(integer index , map<string, any> d, devices, { - if (d["channel"]:"0.0.0000" == channel) + if (d["channel"]:"" == channel) ret = index; }); return ret; @@ -370,7 +370,7 @@ disks = filter (map<string, any> d, disks, { return tolower(d["device"]:"") == "dasd"; }); disks = maplist (map<string,any> d, disks, { - string channel = d["sysfs_bus_id"]:"0.0.0000"; + string channel = d["sysfs_bus_id"]:""; d["channel"] = channel; boolean active = d["resource", "io", 0, "active"]:false; Modified: trunk/s390/src/modules/ZFCPController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/ZFCPController.ycp?rev=67501&r1=67500&r2=67501&view=diff ============================================================================== --- trunk/s390/src/modules/ZFCPController.ycp (original) +++ trunk/s390/src/modules/ZFCPController.ycp Tue Feb 21 20:23:40 2012 @@ -263,14 +263,14 @@ GetFilteredDevices() { list<string> min_strs = splitstring(filter_min, "."); - integer min_css = tointeger("0x" + min_strs[0]:"0"); - integer min_lcss = tointeger("0x" + min_strs[1]:"0"); - integer min_chan = tointeger("0x" + min_strs[2]:"0"); + integer min_css = tointeger("0x" + min_strs[0]:""); + integer min_lcss = tointeger("0x" + min_strs[1]:""); + integer min_chan = tointeger("0x" + min_strs[2]:""); list<string> max_strs = splitstring(filter_max, "."); - integer max_css = tointeger("0x" + max_strs[0]:"0"); - integer max_lcss = tointeger("0x" + max_strs[1]:"0"); - integer max_chan = tointeger("0x" + max_strs[2]:"0"); + integer max_css = tointeger("0x" + max_strs[0]:""); + integer max_lcss = tointeger("0x" + max_strs[1]:""); + integer max_chan = tointeger("0x" + max_strs[2]:""); map<integer, map<string, any> > ret = GetDevices(); @@ -281,10 +281,10 @@ max_css, max_lcss, max_chan); ret = filter(integer k, map<string, any> d, ret, { - list<string> tmp_strs = splitstring(d["channel"]:"0.0.0000", "."); - integer tmp_css = tointeger("0x" + tmp_strs[0]:"0"); - integer tmp_lcss = tointeger("0x" + tmp_strs[1]:"0"); - integer tmp_chan = tointeger("0x" + tmp_strs[2]:"0"); + list<string> tmp_strs = splitstring(d["channel"]:"", "."); + integer tmp_css = tointeger("0x" + tmp_strs[0]:""); + integer tmp_lcss = tointeger("0x" + tmp_strs[1]:""); + integer tmp_chan = tointeger("0x" + tmp_strs[2]:""); return tmp_css >= min_css && tmp_lcss >= min_lcss && tmp_chan >= min_chan && tmp_css <= max_css && tmp_lcss <= max_lcss && tmp_chan <= max_chan; @@ -317,7 +317,7 @@ { integer ret = nil; foreach(integer index , map<string, any> d, devices, { - if (d["channel"]:"0.0.0000" == channel) + if (d["channel"]:"" == channel) ret = index; }); return ret; Modified: trunk/s390/src/zfcp/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/zfcp/dialogs.ycp?rev=67501&r1=67500&r2=67501&view=diff ============================================================================== --- trunk/s390/src/zfcp/dialogs.ycp (original) +++ trunk/s390/src/zfcp/dialogs.ycp Tue Feb 21 20:23:40 2012 @@ -44,6 +44,7 @@ return ret ? `next : `abort; } + /** * Write settings dialog * @return `abort if aborted and `next otherwise @@ -69,9 +70,9 @@ list<term> items = []; items = maplist(integer k, map<string, any> d, devices, { - string channel = d["detail", "controller_id"]:"unknown"; - string wwpn = d["detail", "wwpn"]:"unknown"; - string fcp_lun = d["detail", "fcp_lun"]:"unknown"; + string channel = d["detail", "controller_id"]:""; + string wwpn = d["detail", "wwpn"]:""; + string fcp_lun = d["detail", "fcp_lun"]:""; return `item(`id(k), channel, wwpn, fcp_lun); }); @@ -225,7 +226,7 @@ else { items = maplist (map<string, any> c, ZFCPController::GetControllers(), { - string channel = c["sysfs_bus_id"]:"0.0.0000"; + string channel = c["sysfs_bus_id"]:""; return channel; }); } @@ -266,16 +267,55 @@ { ret = (symbol) UI::UserInput(); - if (ret == `get_wwpn){ - list<string> items = ZFCPController::GetWWPNs((string)UI::QueryWidget(`channel, `Value)); - UI::ChangeWidget(`wwpn, `Items, items); - ret=nil; - } - else if (ret == `get_lun){ - list<string> items = ZFCPController::GetLUNs((string)UI::QueryWidget(`channel, `Value), (string)UI::QueryWidget(`wwpn, `Value)); - UI::ChangeWidget(`fcp_lun, `Items, items); - ret=nil; - } + if (ret == `get_wwpn) + { + string channel = (string) UI::QueryWidget(`channel, `Value); + + if (!ZFCPController::IsValidChannel(channel)) + { + // error popup + Popup::Error(_("Not a valid channel.")); + UI::SetFocus(`channel); + ret = nil; + continue; + } + + channel = ZFCPController::FormatChannel(channel); + + list<string> items = ZFCPController::GetWWPNs(channel); + UI::ChangeWidget(`wwpn, `Items, items); + ret = nil; + } + else if (ret == `get_lun) + { + string channel = (string) UI::QueryWidget(`channel, `Value); + string wwpn = (string) UI::QueryWidget(`wwpn, `Value); + + if (!ZFCPController::IsValidChannel(channel)) + { + // error popup + Popup::Error(_("Not a valid channel.")); + UI::SetFocus(`channel); + ret = nil; + continue; + } + + if (!ZFCPController::IsValidWWPN(wwpn)) + { + // error popup + Report::Error(_("The entered WWPN is invalid.")); + UI::SetFocus(`wwpn); + ret = nil; + continue; + } + + channel = ZFCPController::FormatChannel(channel); + wwpn = ZFCPController::FormatWWPN(wwpn); + + list<string> items = ZFCPController::GetLUNs(channel, wwpn); + UI::ChangeWidget(`fcp_lun, `Items, items); + ret = nil; + } else if (ret == `abort || ret == `cancel) { // yes-no popup @@ -378,16 +418,16 @@ { foreach(integer index, selected, { map d = ZFCPController::devices[index]:$[]; - string channel = d["detail", "controller_id"]:"unknown"; - string wwpn = d["detail", "wwpn"]:"unknown"; - string fcp_lun = d["detail", "fcp_lun"]:"unknown"; + string channel = d["detail", "controller_id"]:""; + string wwpn = d["detail", "wwpn"]:""; + string fcp_lun = d["detail", "fcp_lun"]:""; ZFCPController::DeactivateDisk(channel, wwpn, fcp_lun); }); - + ZFCPController::ProbeDisks(); } } - + return `next; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn2.opensuse.org