Create hardlink as priviledged user
authorAnsgar Burchardt <ansgar@43-1.org>
Thu, 27 Jan 2011 20:25:02 +0000 (21:25 +0100)
committerAnsgar Burchardt <ansgar@43-1.org>
Thu, 27 Jan 2011 20:25:02 +0000 (21:25 +0100)
Apply patch from Kees Cook <kees@debian.org> to work with hardlink
restrictions.

Bug-Debian: http://bugs.debian.org/597130
Bug-Ubuntu: https://bugs.launchpad.net/bugs/598824
Signed-off-by: Ansgar Burchardt <ansgar@43-1.org>
atd.c

diff --git a/atd.c b/atd.c
index 176f431..2c497d9 100644 (file)
--- a/atd.c
+++ b/atd.c
@@ -249,7 +249,10 @@ run_file(const char *filename, uid_t uid, gid_t gid)
      * somebody else has already locked it (a second atd?); log the
      * fact and return.
      */
-    if (link(filename, newname) == -1) {
+    PRIV_START
+    rc = link(filename, newname);
+    PRIV_END
+    if (rc == -1) {
        if (errno == EEXIST) {
            free(mailname);
            free(newname);