summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-06-23 01:04:22 +0200
committerGuillem Jover <guillem@debian.org>2019-10-30 22:02:42 +0100
commit8b0806e8df366f0b0b29c74b4856bbfcda632ed6 (patch)
treedc9c214e17d60f2c089e148a14d328e20a0368ef
parent1f5a2a27f755604065a36bd626d68360a41456b7 (diff)
downloaddpkg-8b0806e8df366f0b0b29c74b4856bbfcda632ed6.tar.gz
libdpkg: Clarify lock contender error message
Print the PID of the lock contender, switch the tense to past as the lock might not be locked anymore by the time we finish, and add a warning explaining that removing the lock file is never the correct solution.
-rw-r--r--debian/changelog3
-rw-r--r--lib/dpkg/file.c19
2 files changed, 19 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 206c0e6cf..ff6e3cdb5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium
to specify multiple packages. Closes: #926669
Based on a patch by Frank Schaefer <kelledin@gmail.com>.
* perl: Remove support for versioned GnuPG 2 program and packages.
+ * libdpkg: Clarify lock contender error message. Print the PID of the lock
+ contender, and add a warning explaining that removing the lock file is
+ never the correct solution.
* Perl modules:
- Dpkg::Source::Package: Verify original tarball signatures at build time.
* Documentation:
diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c
index 614d969e3..ceda51047 100644
--- a/lib/dpkg/file.c
+++ b/lib/dpkg/file.c
@@ -189,10 +189,23 @@ file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
lock_cmd = F_SETLK;
if (fcntl(*lockfd, lock_cmd, &fl) == -1) {
- if (errno == EACCES || errno == EAGAIN)
- ohshit(_("%s is locked by another process"), desc);
- else
+ const char *warnmsg;
+
+ if (errno != EACCES && errno != EAGAIN)
ohshite(_("unable to lock %s"), desc);
+
+ warnmsg = _("Note: removing the lock file is always wrong, "
+ "and can end up damaging the\n"
+ "locked area and the entire system. "
+ "See <https://wiki.debian.org/Teams/Dpkg/FAQ>.");
+
+ file_lock_setup(&fl, F_WRLCK);
+ if (fcntl(*lockfd, F_GETLK, &fl) == -1)
+ ohshit(_("%s was locked by another process\n%s"),
+ desc, warnmsg);
+
+ ohshit(_("%s was locked by another process with pid %d\n%s"),
+ desc, fl.l_pid, warnmsg);
}
push_cleanup(file_unlock_cleanup, ~0, 3, lockfd, filename, desc);