Skip to content

Commit

Permalink
Merge b0a31f9 into 46112ac
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 20, 2018
2 parents 46112ac + b0a31f9 commit c3c2916
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 102 deletions.
7 changes: 7 additions & 0 deletions package/yast2-fcoe-client.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Dec 20 08:54:28 UTC 2018 - Josef Reidinger <jreidinger@suse.com>

- always use absolute path to binaries (bsc#1118291)
- properly escape shell arguments (bsc#1118291)
- 4.1.2

-------------------------------------------------------------------
Sun Nov 25 14:04:13 UTC 2018 - Stasiek Michalski <hellcp@mailbox.org>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-fcoe-client.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-fcoe-client
Version: 4.1.1
Version: 4.1.2
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
44 changes: 21 additions & 23 deletions src/clients/fcoe-client_auto.rb
Expand Up @@ -23,18 +23,20 @@
# Package: Configuration of fcoe-client
# Summary: Client for autoinstallation
# Authors: Gabriele Mohr <gs@suse.de>
#
#
# This is a client for autoinstallation. It takes its arguments,
# goes through the configuration and return the setting.
# Does not do any changes to the configuration.

# @param function to execute
# @param map/list of fcoe-client settings
# @return [Hash] edited settings, Summary or boolean on success depending on called function
# @example map mm = $[ "FAIL_DELAY" : "77" ];
# @example map ret = WFM::CallFunction ("fcoe-client_auto", [ "Summary", mm ]);
require "shellwords"

module Yast
#
# This is a client for autoinstallation. It takes its arguments,
# goes through the configuration and return the setting.
# Does not do any changes to the configuration.

# @param function to execute
# @param map/list of fcoe-client settings
# @return [Hash] edited settings, Summary or boolean on success depending on called function
# @example map mm = $[ "FAIL_DELAY" : "77" ];
# @example map ret = WFM::CallFunction ("fcoe-client_auto", [ "Summary", mm ]);
class FcoeClientAutoClient < Client
def main
Yast.import "UI"
Expand Down Expand Up @@ -153,9 +155,9 @@ def main
dev_name = card["dev_name"]
if card["fcoe_vlan"] == FcoeClient.NOT_CONFIGURED
if card["auto_vlan"] == "yes"
command = "fipvlan -c -s -f '-fcoe' #{dev_name}"
command = "/usr/sbin/fipvlan -c -s -f '-fcoe' #{dev_name.shellescape}"
else
command = "fipvlan -c -s #{dev_name}"
command = "/usr/sbin/fipvlan -c -s #{dev_name.shellescape}"
end

ifcfg_file = Builtins.sformat(
Expand All @@ -167,29 +169,25 @@ def main
# call 'ifup' for the interface (creates /proc/net/vlan/<vlan-interface>)
if FileUtils.Exists(ifcfg_file)
cmd_ifup = Builtins.sformat(
"ifup %1.%2",
Ops.get_string(card, "dev_name", ""),
Ops.get_string(card, "vlan_interface", "")
"/usr/sbin/ifup %1.%2",
Ops.get_string(card, "dev_name", "").shellescape,
Ops.get_string(card, "vlan_interface", "").shellescape
)
Builtins.y2milestone("Executing command: %1", cmd_ifup)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), cmd_ifup)
)
output = SCR.Execute(path(".target.bash_output"), cmd_ifup)
Builtins.y2milestone("Output: %1", output)

if Ops.get_integer(output, "exit", 255) == 0
# start FCoE
command = Builtins.sformat(
"fipvlan -s %1",
Ops.get_string(card, "dev_name", "")
"/usr/sbin/fipvlan -s %1",
Ops.get_string(card, "dev_name", "").shellescape
)
end
end

Builtins.y2milestone("Executing command: %1", command)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), command)
)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)

if Ops.get_integer(output, "exit", 255) != 0
Expand Down
29 changes: 10 additions & 19 deletions src/clients/fcoe-client_finish.rb
Expand Up @@ -28,6 +28,8 @@
# Authors:
# Gabriele Mohr <gs@suse.de>
#
require "shellwords"

require "yast2/systemd/socket"

module Yast
Expand Down Expand Up @@ -76,21 +78,10 @@ def main
if @netcards != []
Builtins.y2milestone("Copying files /etc/fcoe/* to destination")
# copy fcoe config files to destdir
destdir = File.join(Installation.destdir, "etc/fcoe")
WFM.Execute(
path(".local.bash"),
Ops.add(
Ops.add(
Ops.add(
Ops.add(
"test -d /etc/fcoe/ && mkdir -p '",
String.Quote(Installation.destdir)
),
"/etc/fcoe' && cp -a /etc/fcoe/* '"
),
String.Quote(Installation.destdir)
),
"/etc/fcoe/'"
)
"/usr/bin/test -d /etc/fcoe/ && /usr/bin/mkdir -p #{destdir.shellescape} && /usr/bin/cp -a /etc/fcoe/* #{destdir.shellescape}"
)
else
Builtins.y2milestone("Nothing to do")
Expand All @@ -111,9 +102,9 @@ def main
Ops.get_string(card, "vlan_interface", "")
)
command = Builtins.sformat(
"cp -a %1 '%2/etc/sysconfig/network'",
file_name,
String.Quote(Installation.destdir)
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)
Expand All @@ -123,9 +114,9 @@ def main
Ops.get_string(card, "dev_name", "")
)
command = Builtins.sformat(
"cp -a %1 '%2/etc/sysconfig/network'",
file_name,
String.Quote(Installation.destdir)
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)
Expand Down
2 changes: 1 addition & 1 deletion src/clients/inst_fcoe-client.rb
Expand Up @@ -59,7 +59,7 @@ def main
Builtins.y2milestone("fcoe-client module started during installation")

# create /etc/fcoe
SCR.Execute(path(".target.bash"), "mkdir -p /etc/fcoe")
SCR.Execute(path(".target.bash"), "/usr/bin/mkdir -p /etc/fcoe")

# FcoeClient::CheckInstalledPackages() not needed in inst-sys
# FcoeClient::DetectStartStatus() doesn't make sense in inst-sys
Expand Down
45 changes: 20 additions & 25 deletions src/include/fcoe-client/complex.rb
Expand Up @@ -24,6 +24,9 @@
# Summary: Dialogs definitions
# Authors: Gabriele Mohr <gs@suse.de>
#

require "shellwords"

module Yast
module FcoeClientComplexInclude
def initialize_fcoe_client_complex(include_target)
Expand Down Expand Up @@ -393,9 +396,9 @@ def HandleInterfacesDialog(id, event)
end

if card["auto_vlan"] == "yes" || vlan_interface == "0"
command = "fipvlan -c -s -f '-fcoe' #{dev_name}"
command = "/usr/sbin/fipvlan -c -s -f '-fcoe' #{dev_name.shellescape}"
else
command = "fipvlan -c -s #{dev_name}"
command = "/usr/sbin/fipvlan -c -s #{dev_name.shellescape}"
end

output = {}
Expand All @@ -420,9 +423,7 @@ def HandleInterfacesDialog(id, event)
# execute command, e.g. 'fipvlan -c -s eth3'

Builtins.y2milestone("Executing command: %1", command)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), command)
)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)

if Ops.get_integer(output, "exit", 255) != 0
Expand All @@ -439,7 +440,7 @@ def HandleInterfacesDialog(id, event)
# if /etc/sysconfig/network/ifcfg-<if>.<vlan> already exists
# call 'ifup' for the interface (creates /proc/net/vlan/<if>.<vlan>)
if FileUtils.Exists(ifcfg_file)
cmd_ifup = Builtins.sformat("ifup %1.%2", dev_name, vlan_interface)
cmd_ifup = Builtins.sformat("/usr/sbin/ifup %1.%2", dev_name.shellescape, vlan_interface.shellescape)
Builtins.y2milestone("Executing command: %1", cmd_ifup)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), cmd_ifup)
Expand All @@ -448,14 +449,12 @@ def HandleInterfacesDialog(id, event)

if Ops.get_integer(output, "exit", 255) == 0
# only start FCoE
command = Builtins.sformat("fipvlan -s %1", dev_name)
command = Builtins.sformat("/usr/sbin/fipvlan -s %1", dev_name.shellescape)
end
end

Builtins.y2milestone("Executing command: %1", command)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), command)
)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
if Ops.get_integer(output, "exit", 255) != 0
if !FcoeClient.TestMode
Expand Down Expand Up @@ -505,7 +504,7 @@ def HandleInterfacesDialog(id, event)
# and removes the interface properly (tested on SP2 RC1)
# TODO: Retest for SLES12
FcoeClient.AddRevertCommand(
Builtins.sformat("vconfig rem %1", fcoe_vlan_interface)
Builtins.sformat("/usr/sbin/vconfig rem %1", fcoe_vlan_interface.shellescape)
)
else
fcoe_vlan_interface = FcoeClient.NOT_CONFIGURED
Expand Down Expand Up @@ -605,19 +604,17 @@ def HandleInterfacesDialog(id, event)

# call fcoeadm -d <fcoe_vlan> first (bnc #719443)
command = Builtins.sformat(
"fcoeadm -d %1",
Ops.get_string(card, "cfg_device", "")
"/usr/sbin/fcoeadm -d %1",
Ops.get_string(card, "cfg_device", "").shellescape
)
Builtins.y2milestone("Calling %1", command)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), command)
)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)

if Ops.get_integer(output, "exit", 255) == 0 || FcoeClient.TestMode
command = Builtins.sformat(
"vconfig rem %1",
Ops.get_string(card, "fcoe_vlan", "")
"/usr/sbin/vconfig rem %1",
Ops.get_string(card, "fcoe_vlan", "").shellescape
)
Builtins.y2milestone("Calling %1", command)
output = Convert.to_map(
Expand Down Expand Up @@ -652,13 +649,11 @@ def HandleInterfacesDialog(id, event)

if del_cfg
command = Builtins.sformat(
"rm /etc/fcoe/cfg-%1",
Ops.get_string(card, "cfg_device", "")
"/usr/bin/rm /etc/fcoe/cfg-%1",
Ops.get_string(card, "cfg_device", "").shellescape
)
Builtins.y2milestone("Calling %1", command)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), command)
)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
else
Builtins.y2milestone(
Expand All @@ -671,8 +666,8 @@ def HandleInterfacesDialog(id, event)

if Ops.get_string(card, "vlan_interface", "") != "0"
command = Builtins.sformat(
"rm /etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "fcoe_vlan", "")
"/usr/bin/rm /etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "fcoe_vlan", "").shellescape
)
Builtins.y2milestone("Calling %1", command)
output = Convert.to_map(
Expand Down

0 comments on commit c3c2916

Please sign in to comment.