Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with or without Usr-Merge #113

Merged
merged 2 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions package/yast2-iscsi-client.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Apr 11 12:04:00 UTC 2022 - Stefan Hundhammer <shundhammer@suse.com>

- Use $PATH, not absolute paths for calling external programs
to allow for distros with or without usr-merge (/sbin -> /usr/sbin)
(bsc#1196086)
- 4.5.1

-------------------------------------------------------------------
Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-iscsi-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-iscsi-client
Version: 4.5.0
Version: 4.5.1
Release: 0
Summary: YaST2 - iSCSI Client Configuration
License: GPL-2.0-only
Expand Down
2 changes: 1 addition & 1 deletion src/clients/inst_iscsi-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def main

SCR.Execute(
path(".target.bash"),
"/usr/bin/mkdir -p /etc/iscsi; /usr/bin/touch /etc/iscsi/initiatorname.iscsi; /usr/bin/ln -s /etc/iscsi/initiatorname.iscsi /etc/initiatorname.iscsi"
"mkdir -p /etc/iscsi; touch /etc/iscsi/initiatorname.iscsi; ln -s /etc/iscsi/initiatorname.iscsi /etc/initiatorname.iscsi"
)
# check initiator name, create if not exists
IscsiClientLib.checkInitiatorName
Expand Down
2 changes: 1 addition & 1 deletion src/clients/iscsi-client_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def main
# write open-iscsi database of automatic connected targets
WFM.Execute(
path(".local.bash"),
"/usr/bin/test -d /etc/iscsi/ && " \
"test -d /etc/iscsi/ && " \
shundhammer marked this conversation as resolved.
Show resolved Hide resolved
"mkdir -p #{Installation.destdir.shellescape}/etc/iscsi && " \
"cp -a /etc/iscsi/* #{Installation.destdir.shellescape}/etc/iscsi/"
)
Expand Down
24 changes: 14 additions & 10 deletions src/modules/IscsiClientLib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class IscsiClientLibClass < Module
Yast.import "Arch"

# Script to configure iSCSI offload engines for use with open-iscsi
OFFLOAD_SCRIPT = "/sbin/iscsi_offload".freeze
#
# Relying on our secure $PATH (set in y2start), not making assumptions
# if the binary is in /sbin or in /usr/sbin (usr-merge in openSUSE!)
# (bsc#1196086, bsc#1196086)
OFFLOAD_SCRIPT = "iscsi_offload".freeze

def main
textdomain "iscsi-client"
Expand Down Expand Up @@ -215,7 +219,7 @@ def SetOffloadCard(new_card)
# @return [String] complete command
#
def GetAdmCmd(params, do_log = true)
ret = "LC_ALL=POSIX /sbin/iscsiadm #{params}"
ret = "LC_ALL=POSIX iscsiadm #{params}"
Builtins.y2milestone("GetAdmCmd: #{ret}") if do_log
ret
end
Expand Down Expand Up @@ -275,7 +279,7 @@ def getiBFT
return @ibft
end
ret = SCR.Execute(path(".target.bash_output"),
"/usr/bin/lsmod | /usr/bin/grep -q iscsi_ibft || /usr/sbin/modprobe iscsi_ibft")
"lsmod | grep -q iscsi_ibft || modprobe iscsi_ibft")
log.info "check and modprobe iscsi_ibft: #{ret}"

@ibft = nodeInfoToMap(getFirmwareInfo)
Expand Down Expand Up @@ -577,13 +581,13 @@ def start_services_initial
end

def restart_iscsid_initial
retcode = SCR.Execute(path(".target.bash"), "/usr/bin/pgrep iscsid")
retcode = SCR.Execute(path(".target.bash"), "pgrep iscsid")
Service.Stop("iscsid") if retcode == 0
start_iscsid_initial
end

def start_iscsid_initial
SCR.Execute(path(".target.bash"), "/usr/bin/pgrep iscsid || /sbin/iscsid")
SCR.Execute(path(".target.bash"), "pgrep iscsid || iscsid")
10.times do |i|
Builtins.sleep(1 * 1000)
cmd = SCR.Execute(path(".target.bash_output"), GetAdmCmd("-m session"))
Expand Down Expand Up @@ -640,7 +644,7 @@ def writeInitiatorName(new_value)
Builtins.y2milestone("%1 file exists, create backup", file)
SCR.Execute(
path(".target.bash"),
Builtins.sformat("/usr/bin/mv %1 /etc/iscsi/initiatorname.yastbackup", file.shellescape)
Builtins.sformat("mv %1 /etc/iscsi/initiatorname.yastbackup", file.shellescape)
)
end
ret = SCR.Write(
Expand All @@ -665,7 +669,7 @@ def writeInitiatorName(new_value)
def getReverseDomainName
host_fq = Hostname.SplitFQ(
Ops.get_string(
SCR.Execute(path(".target.bash_output"), "/usr/bin/hostname -f | /usr/bin/tr -d '\n'"),
SCR.Execute(path(".target.bash_output"), "hostname -f | tr -d '\n'"),
"stdout",
""
)
Expand Down Expand Up @@ -696,7 +700,7 @@ def checkInitiatorName
SCR.Execute(
path(".target.bash_output"),
Builtins.sformat(
"/usr/bin/grep -v '^#' %1 | /usr/bin/grep InitiatorName | /usr/bin/cut -d'=' -f2 | /usr/bin/tr -d '\n'",
"grep -v '^#' %1 | grep InitiatorName | cut -d'=' -f2 | tr -d '\n'",
file.shellescape
)
),
Expand All @@ -716,7 +720,7 @@ def checkInitiatorName
output = SCR.Execute(
path(".target.bash_output"),
Builtins.sformat(
"/sbin/iscsi-iname -p iqn.%1.%2:01 | tr -d '\n'",
"iscsi-iname -p iqn.%1.%2:01 | tr -d '\n'",
"`date +%Y-%m`",
getReverseDomainName.shellescape
),
Expand Down Expand Up @@ -1640,7 +1644,7 @@ def configure_offload_engines(cards)

# Current IP address of the given network interface
def ip_addr(dev_name)
cmd = "LC_ALL=POSIX /usr/bin/ifconfig #{dev_name.shellescape}" # FIXME: ifconfig is deprecated
cmd = "LC_ALL=POSIX ifconfig #{dev_name.shellescape}" # FIXME: ifconfig is deprecated
Builtins.y2milestone("GetOffloadItems cmd:%1", cmd)
out = SCR.Execute(path(".target.bash_output"), cmd)
Builtins.y2milestone("GetOffloadItems out:%1", out)
Expand Down
4 changes: 2 additions & 2 deletions test/iscsi_client_lib_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@

expect(Yast::SCR).to receive(:Execute).with(
Yast::Path.new(".target.bash"),
"LC_ALL=POSIX /sbin/iscsiadm -m discovery -I eth0 -I eth1 -t st -p magic"
"LC_ALL=POSIX iscsiadm -m discovery -I eth0 -I eth1 -t st -p magic"
)
expect(Yast::SCR).to receive(:Execute).with(
Yast::Path.new(".target.bash"),
"LC_ALL=POSIX /sbin/iscsiadm -m discovery -I eth0 -I eth1 -t st -p portal\\ 1"
"LC_ALL=POSIX iscsiadm -m discovery -I eth0 -I eth1 -t st -p portal\\ 1"
)

subject.autoyastWrite
Expand Down