Module Name: src
Committed By: christos
Date: Tue Apr 23 22:12:48 UTC 2024
Modified Files:
src/usr.sbin/makefs: walk.c
Log Message:
makefs: Fix symlink permission bits
Permission bits for symlinks are taken straight from `lstat()`. However, the
actual bits presented to the user are filesystem/kernel specific. For example,
Linux with ext2/3/4 will use 0777 for symlinks, whereas NetBSD/FFS will
show 0755. As far as `makefs` is in the loop, the target filesystem will likely
be FFS, so use 0755.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/makefs/walk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makefs/walk.c
diff -u src/usr.sbin/makefs/walk.c:1.34 src/usr.sbin/makefs/walk.c:1.35
--- src/usr.sbin/makefs/walk.c:1.34 Tue Apr 23 18:12:16 2024
+++ src/usr.sbin/makefs/walk.c Tue Apr 23 18:12:48 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: walk.c,v 1.34 2024/04/23 22:12:16 christos Exp $ */
+/* $NetBSD: walk.c,v 1.35 2024/04/23 22:12:48 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: walk.c,v 1.34 2024/04/23 22:12:16 christos Exp $");
+__RCSID("$NetBSD: walk.c,v 1.35 2024/04/23 22:12:48 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -154,6 +154,15 @@ walk_dir(const char *root, const char *d
} else {
if (lstat(path, &stbuf) == -1)
err(EXIT_FAILURE, "Can't lstat `%s'", path);
+ /* As symlink permission bits vary between filesystems
+ (ie. 0755 on FFS/NetBSD, 0777 for ext[234]/Linux),
+ force them to 0755. */
+ if (S_ISLNK(stbuf.st_mode)) {
+ stbuf.st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
+ stbuf.st_mode |= S_IRWXU
+ | S_IRGRP | S_IXGRP
+ | S_IROTH | S_IXOTH;
+ }
}
#ifdef S_ISSOCK
if (S_ISSOCK(stbuf.st_mode & S_IFMT)) {