* lib/chown.c (rpl_chown): Use issymlink instead of readlink.
* modules/chown (Depends-on): Add issymlink.
+2025-08-14 Bruno Haible <bruno@clisp.org>
+
+ chown: Use issymlink.
+ * lib/chown.c (rpl_chown): Use issymlink instead of readlink.
+ * modules/chown (Depends-on): Add issymlink.
+
2025-08-14 Bruno Haible <bruno@clisp.org>
issymlink, issymlinkat: New modules.
If the file is a symlink, open the file (following symlinks), and
fchown the resulting descriptor. Although the open might fail
due to lack of permissions, it's the best we can easily do. */
- char linkbuf[1];
- if (0 <= readlink (file, linkbuf, sizeof linkbuf))
+ if (issymlink (file) > 0)
{
int open_flags = O_NONBLOCK | O_NOCTTY | O_CLOEXEC;
int fd = open (file, O_RDONLY | open_flags);
Depends-on:
unistd-h
fstat [test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1]
+issymlink [test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1]
open [test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1]
stat [test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1]
bool [test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1]