Skip to content

Commit 71a591c

Browse files
committed
Improve error message for missing transaction lock
Give the user a hint that running rpm as root will fix the issue. Resolves: rpm-software-management#3886
1 parent 7c66fe3 commit 71a591c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/rpmlock.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ rpmlock rpmlockNew(const char *lock_path, const char *descr)
124124
if (!lock) {
125125
rpmlog(RPMLOG_ERR, _("can't create %s lock on %s (%s)\n"),
126126
descr, lock_path, strerror(errno));
127+
if (errno == ENOENT && geteuid() != 0)
128+
rpmlog(RPMLOG_ERR, _("\trun rpm with write permission to the rpmdb once to create the lock file\n"));
127129
}
128130
return lock;
129131
}

tests/rpmdb.at

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,21 @@ RPMTEST_SETUP_RW([rpmdb --rebuilddb and verify empty database])
587587
AT_KEYWORDS([rpmdb])
588588
RPMTEST_CHECK([
589589
RPMDB_RESET
590+
RPMTEST_USER
590591
runroot rpmdb --rebuilddb
591592
runroot ls `rpm -E "%{_dbpath}/.rpm.lock"`
592593
runroot rpmdb --verifydb
593594
runroot ls `rpm -E "%{_dbpath}/.rpm.lock"`
595+
runroot rm `rpm -E "%{_dbpath}/.rpm.lock"`
596+
runroot_user rpm -qa
594597
],
595598
[0],
596599
[/var/lib/rpm-testsuite/.rpm.lock
597600
/var/lib/rpm-testsuite/.rpm.lock
598601
],
599-
[])
602+
[error: can't create transaction lock on /var/lib/rpm-testsuite/.rpm.lock (No such file or directory)
603+
error: run rpm with write permission to the rpmdb once to create the lock file
604+
])
600605
RPMTEST_CLEANUP
601606

602607
# ------------------------------

0 commit comments

Comments
 (0)