Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: chmod.2: document EFTYPE
To:
OpenBSD tech <tech@openbsd.org>
Date:
Mon, 19 May 2025 04:58:38 +0000

Download raw body.

Thread
02.05.2025 23:50, Klemens Nanni пишет:
> Now it reads as if 'chmod +t file' wouldn't fail at all, but that's true only for root.
> sticky(8) correctly documents this, so bring chmod(2) up to speed.
> 
> This is sys/ufs/ufs/ufs_vnops.c ufs_chmod() since import:
> 
> 465	if (cred->cr_uid && !vnoperm(vp)) {
> 466		if (vp->v_type != VDIR && (mode & S_ISTXT))
> 467			return (EFTYPE);

Second attempt, disambiguating further and deduplicating text a bit:

     Mode ISVTX (the sticky bit) on a file has no effect, although the
     superuser can still set it.

     If it is set on a directory, ...

> Feedback? OK?

Index: chmod.2
===================================================================
RCS file: /cvs/src/lib/libc/sys/chmod.2,v
diff -u -p -r1.28 chmod.2
--- chmod.2	10 Sep 2015 17:55:21 -0000	1.28
+++ chmod.2	19 May 2025 04:56:56 -0000
@@ -84,16 +84,13 @@ from the following list:
 #define S_ISVTX 0001000    /* save swapped text even after use */
 .Ed
 .Pp
-If mode
+Mode
 .Dv ISVTX
 (the
 .Em sticky bit )
-is set on a file, it is ignored.
+on a file has no effect, although the superuser can still set it.
 .Pp
-If mode
-.Dv ISVTX
-(the
-.Em sticky bit )
+If it
 is set on a directory, an unprivileged user may not delete or rename
 files of other users in that directory.
 The sticky bit may be set by any user on a directory which the user owns
@@ -188,6 +185,9 @@ The named file resides on a read-only fi
 points outside the process's allocated address space.
 .It Bq Er EIO
 An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EFTYPE
+An unprivileged user attempted to set a file's mode to
+.Dv ISVTX .
 .El
 .Pp
 Additionally, the