summaryrefslogtreecommitdiff
path: root/libudev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-08-29 16:10:24 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-08-29 16:10:24 +0200
commit39087d3bdd0b5195c2570a4f858b88a82d42a066 (patch)
treec28b10bee66ff2a04179299ef76596163f23da11 /libudev
parente20294e018ee1a8e3e6a4f5977a23728fdc08c0f (diff)
util_unlink_secure(): chmod() before chown()
Suggested by Florian Zumbiehl <florz@florz.de>.
Diffstat (limited to 'libudev')
-rw-r--r--libudev/libudev-util-private.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c
index 84dee559c4..cb8d2c8a2e 100644
--- a/libudev/libudev-util-private.c
+++ b/libudev/libudev-util-private.c
@@ -100,24 +100,16 @@ int util_delete_path(struct udev *udev, const char *path)
*/
int util_unlink_secure(struct udev *udev, const char *filename)
{
- int retval;
-
- retval = chown(filename, 0, 0);
- if (retval)
- err(udev, "chown(%s, 0, 0) failed: %m\n", filename);
-
- retval = chmod(filename, 0000);
- if (retval)
- err(udev, "chmod(%s, 0000) failed: %m\n", filename);
+ int err;
- retval = unlink(filename);
+ chmod(filename, 0000);
+ chown(filename, 0, 0);
+ err = unlink(filename);
if (errno == ENOENT)
- retval = 0;
-
- if (retval)
+ err = 0;
+ if (err)
err(udev, "unlink(%s) failed: %m\n", filename);
-
- return retval;
+ return err;
}
uid_t util_lookup_user(struct udev *udev, const char *user)