]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: Add missing assert to chmod_and_chown_at()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 08:59:25 +0000 (09:59 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 09:19:18 +0000 (10:19 +0100)
src/basic/fs-util.c

index c70926c12cab0cccd1b7edf5acb6737f22c4d2f0..4d24cd59de96a7ffccb21ba30e0bc9746d5b8a24 100644 (file)
@@ -197,6 +197,8 @@ int readlink_and_make_absolute(const char *p, char **r) {
 int chmod_and_chown_at(int dir_fd, const char *path, mode_t mode, uid_t uid, gid_t gid) {
         _cleanup_close_ int fd = -1;
 
+        assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
+
         if (path) {
                 /* Let's acquire an O_PATH fd, as precaution to change mode/owner on the same file */
                 fd = openat(dir_fd, path, O_PATH|O_CLOEXEC|O_NOFOLLOW);