Bug 2129382

Summary: [targetcli] Creating fileio backstore without specifying file_or_dev full path can be problematic
Product: Red Hat Enterprise Linux 9 Reporter: Martin Hoyer <mhoyer>
Component: targetcliAssignee: Maurizio Lombardi <mlombard>
Status: CLOSED MIGRATED QA Contact: Martin Hoyer <mhoyer>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.1CC: sostapov
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-23 12:56:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Hoyer 2022-09-23 14:22:36 UTC
Description of problem:
When creating a fileio backstore, users are allowed to specify file_or_dev without full path.
The file location is then determined by the directory the command is being run from (or where the targetcli shell was started).

If restoreconfig is then started from another directory, targetcli will create another file with the same name on that location.
One example is when file is created in any other directory than root, rebooting the OS with target service enabled will create a new file under / 

# cd /home/
# targetcli backstores/fileio create name=test size=100M file_or_dev=testfile
Created fileio test with size 104857600

# cat /etc/target/saveconfig.json
-snip-
"dev": "testfile",
"name": "test",
-snip-

I would suggest to update targetcli to always save full path to json or at least print warning.

Version-Release number of selected component (if applicable):
targetcli-2.1.53-7.el9.noarch
python3-configshell-1.1.28-7.el9.noarch
python3-rtslib-2.1.75-1.el9.noarch

How reproducible:
100%

Steps to Reproduce:
1. change directory to anything other than /
2. create fileio backstore without full path
3. run targetcli restoreconfig from other directory

Actual results:
new file created

Expected results:
users not being able to make this mistake

Comment 2 RHEL Program Management 2023-09-23 12:55:00 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 3 RHEL Program Management 2023-09-23 12:56:19 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.