Bug 1727393

Summary: lshw SQLite dump fails unless using absolute path
Product: Red Hat Enterprise Linux 8 Reporter: Jeff Bastian <jbastian>
Component: lshwAssignee: lijiang
Status: CLOSED ERRATA QA Contact: Jeff Bastian <jbastian>
Severity: low Docs Contact:
Priority: low    
Version: 8.1CC: lijiang, ruyang
Target Milestone: rc   
Target Release: 8.3   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: lshw-B.02.19.2-2.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 1702735 Environment:
Last Closed: 2020-11-04 01:57:49 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:
Bug Depends On: 1702735    
Bug Blocks: 1674330    

Description Jeff Bastian 2019-07-05 20:36:54 UTC
+++ This bug was initially created as a clone of Bug #1702735 +++

Description of problem:
lshw fails to create a SQLite database unless you give it a full and absolute path to the dump file.

[root@localhost ~]# lshw -dump lshw.sql >/dev/null
                            
[root@localhost ~]# file lshw.sql
lshw.sql: cannot open `lshw.sql' (No such file or directory)

[root@localhost ~]# lshw -dump /root/lshw.sql >/dev/null
                            
[root@localhost ~]# file lshw.sql
lshw.sql: SQLite 3.x database, last written using SQLite version 3026000


Version-Release number of selected component (if applicable):
lshw-B.02.18-21.el8

How reproducible:
always

Steps to Reproduce:
1. lshw -dump lshw.sql

Actual results:
lshw fails to create a SQLite database file named lshw.sql

Expected results:
The output is saved to a SQLite database named lshw.sql

Additional info:
lshw is trying to create the database dump in /sys/bus/pnp/devices according to strace:

[root@localhost ~]# strace -e trace=file -o lshw.trace lshw -dump lshw.sql >/dev/null

[root@localhost ~]# grep lshw.sql lshw.trace
execve("/usr/sbin/lshw", ["lshw", "-dump", "lshw.sql"], 0x7ffdf2697a60 /* 42 vars */) = 0
lstat("lshw.sql", 0x7ffe34364af0)       = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/sys/bus/pnp/devices/lshw.sql", O_RDWR|O_CREAT|O_CLOEXEC, 0644) = -1 EACCES (Permission denied)
openat(AT_FDCWD, "/sys/bus/pnp/devices/lshw.sql", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

Comment 2 lijiang 2020-02-11 03:31:16 UTC
This is too late for rhel8.2, I would move it to rhel8.3. Thanks.

Comment 8 Jeff Bastian 2020-08-05 22:11:42 UTC
Verified with lshw-B.02.19.2-2.el8

[root@intel-chiefriver-03 ~]# rpm -q lshw
lshw-B.02.19.2-2.el8.x86_64

[root@intel-chiefriver-03 ~]# ls lshw*
ls: cannot access 'lshw*': No such file or directory

[root@intel-chiefriver-03 ~]# lshw -dump lshw.sql >/dev/null

[root@intel-chiefriver-03 ~]# ls lshw*
lshw.sql

[root@intel-chiefriver-03 ~]# file lshw.sql 
lshw.sql: SQLite 3.x database, last written using SQLite version 3026000

[root@intel-chiefriver-03 ~]# sqlite3 -cmd .dump lshw.sql
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE META(key TEXT PRIMARY KEY COLLATE NOCASE, value BLOB);
INSERT INTO META VALUES('schema',1.0);
INSERT INTO META VALUES('application','org.ezix.lshw');
INSERT INTO META VALUES('creator','lshw/B.02.19.2');
INSERT INTO META VALUES('OS','Red Hat Enterprise Linux release 8.3 Beta (Ootpa) ; Linux 4.18.0-229.el8.x86_64+debug ; glibc 2.28');
INSERT INTO META VALUES('platform','x86_64');
CREATE TABLE nodes(path TEXT PRIMARY KEY, id TEXT NOT NULL COLLATE NOCASE, parent TEXT COLLATE NOCASE, class TEXT NOT NULL COLLATE NOCASE, enabled BOOL, claimed BOOL, description TEXT, vendor TEXT, product TEXT, version TEXT, serial TEXT, businfo TEXT, physid TEXT, slot TEXT, size INTEGER, capacity INTEGER, clock INTEGER, width INTEGER, dev TEXT);
INSERT INTO nodes VALUES('/','intel-chiefriver-03.khw1.lab.eng.bos.redhat.com',NULL,'system',1,1,'Laptop','Intel Corporation','2012 Client Platform (To be filled by O.E.M.)','To be filled by O.E.M.','To be filled by O.E.M.',NULL,NULL,NULL,NULL,NULL,NULL,64,NULL);
INSERT INTO nodes VALUES('/0','core','/','bus',1,1,'Motherboard','Intel Corporation','Emerald Lake 2','To be filled by O.E.M.','To be filled by O.E.M.',NULL,'0','To be filled by O.E.M.',NULL,NULL,NULL,NULL,NULL);
INSERT INTO nodes VALUES('/0/42','memory','/0','memory',1,1,'System Memory',NULL,NULL,NULL,NULL,NULL,'42','System board or motherboard',4294967296,NULL,NULL,NULL,NULL);
INSERT INTO nodes VALUES('/0/42/0','bank:0','/0/42','memory',1,1,'SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)','Hynix/Hyundai','HMT351S6BFR8C-PB',NULL,'29834EFF',NULL,'0','ChannelA-DIMM0',4294967296,NULL,1600000000,64,NULL);
INSERT INTO nodes VALUES('/0/42/1','bank:1','/0/42','memory',1,1,'DIMM [empty]','[Empty]','[Empty]',NULL,'[Empty]',NULL,'1','ChannelB-DIMM0',NULL,NULL,NULL,NULL,NULL);
INSERT INTO nodes VALUES('/0/4','cache:0','/0','memory',1,1,'L1 cache',NULL,NULL,NULL,NULL,NULL,'4',NULL,32768,32768,NULL,NULL,NULL);
INSERT INTO nodes VALUES('/0/5','cache:1','/0','memory',1,1,'L2 cache',NULL,NULL,NULL,NULL,NULL,'5',NULL,262144,262144,NULL,NULL,NULL);
...
...
...
INSERT INTO resources VALUES('/0/100/1f.3','irq','18');
INSERT INTO resources VALUES('/0/100/1f.3','memory','b2230000-b22300ff');
INSERT INTO resources VALUES('/0/100/1f.3','ioport','7000(size=32)');
CREATE VIEW unclaimed AS SELECT * FROM nodes WHERE NOT claimed;
CREATE VIEW disabled AS SELECT * FROM nodes WHERE NOT enabled;
COMMIT;
SQLite version 3.26.0 2018-12-01 12:34:55
Enter ".help" for usage hints.
sqlite> .quit

Comment 11 errata-xmlrpc 2020-11-04 01:57:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (lshw bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4533