summaryrefslogtreecommitdiffstats
path: root/man2/chown.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/chown.2')
-rw-r--r--man2/chown.241
1 files changed, 22 insertions, 19 deletions
diff --git a/man2/chown.2 b/man2/chown.2
index 93558cacb..ff7c6dd1a 100644
--- a/man2/chown.2
+++ b/man2/chown.2
@@ -15,7 +15,7 @@
.\" (bsdgroups versus sysvgroups, and the effect of the parent
.\" directory's set-group-ID mode bit).
.\"
-.TH chown 2 2023-02-05 "Linux man-pages 6.03"
+.TH chown 2 2023-05-03 "Linux man-pages 6.05.01"
.SH NAME
chown, fchown, lchown, fchownat \- change ownership of a file
.SH LIBRARY
@@ -278,15 +278,6 @@ The file is marked immutable or append-only.
.B EROFS
The named file resides on a read-only filesystem.
.SH VERSIONS
-.BR fchownat ()
-was added in Linux 2.6.16;
-library support was added in glibc 2.4.
-.SH STANDARDS
-.BR chown (),
-.BR fchown (),
-.BR lchown ():
-4.4BSD, SVr4, POSIX.1-2001, POSIX.1-2008.
-.PP
The 4.4BSD version can be
used only by the superuser (that is, ordinary users cannot give away files).
.\" chown():
@@ -295,9 +286,21 @@ used only by the superuser (that is, ordinary users cannot give away files).
.\" fchown():
.\" SVr4 documents additional EINVAL, EIO, EINTR, and ENOLINK
.\" error conditions.
-.PP
-.BR fchownat ():
+.SH STANDARDS
+POSIX.1-2008.
+.SH HISTORY
+.TP
+.BR chown ()
+.TQ
+.BR fchown ()
+.TQ
+.BR lchown ()
+4.4BSD, SVr4, POSIX.1-2001.
+.TP
+.BR fchownat ()
POSIX.1-2008.
+Linux 2.6.16,
+glibc 2.4.
.SH NOTES
.SS Ownership of new files
When a new file is created (by, for example,
@@ -425,36 +428,36 @@ to perform a lookup in the system password file).
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+\&
int
main(int argc, char *argv[])
{
char *endptr;
uid_t uid;
struct passwd *pwd;
-
+\&
if (argc != 3 || argv[1][0] == \[aq]\e0\[aq]) {
fprintf(stderr, "%s <owner> <file>\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
uid = strtol(argv[1], &endptr, 10); /* Allow a numeric string */
-
+\&
if (*endptr != \[aq]\e0\[aq]) { /* Was not pure numeric string */
pwd = getpwnam(argv[1]); /* Try getting UID for username */
if (pwd == NULL) {
perror("getpwnam");
exit(EXIT_FAILURE);
}
-
+\&
uid = pwd\->pw_uid;
}
-
+\&
if (chown(argv[2], uid, \-1) == \-1) {
perror("chown");
exit(EXIT_FAILURE);
}
-
+\&
exit(EXIT_SUCCESS);
}
.EE