getpgrp.o getpid.o getppid.o getpriority.o getrlimit.o getrusage.o \
getsockname.o getsockopt.o gettimeofday.o getuid.o issetugid.o \
ioctl.o kill.o \
- ktrace.o lfs_bmapv.o lfs_markv.o lfs_segclean.o lfs_segwait.o link.o \
- listen.o lstat.o madvise.o mincore.o minherit.o mkdir.o mkfifo.o \
- mknod.o mlock.o \
+ ktrace.o lchown.o lfs_bmapv.o lfs_markv.o lfs_segclean.o lfs_segwait.o \
+ link.o listen.o lstat.o madvise.o mincore.o minherit.o mkdir.o \
+ mkfifo.o mknod.o mlock.o \
mount.o mprotect.o msgctl.o msgget.o msgrcv.o msgsnd.o msync.o \
munlock.o munmap.o nfssvc.o \
ntp_gettime.o ntp_adjtime.o \
+.\" $OpenBSD: chown.2,v 1.3 1997/01/26 05:10:33 downsj Exp $
.\" $NetBSD: chown.2,v 1.10 1995/10/12 15:40:47 jtc Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993, 1994
.\"
.\" @(#)chown.2 8.4 (Berkeley) 4/19/94
.\"
-.Dd April 19, 1994
+.Dd January 25, 1997
.Dt CHOWN 2
-.Os BSD 4
+.Os
.Sh NAME
.Nm chown ,
+.Nm lchown ,
.Nm fchown
-.Nd change owner and group of a file
+.Nd change owner and group of a file or link
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <unistd.h>
.Ft int
.Fn chown "const char *path" "uid_t owner" "gid_t group"
.Ft int
+.Fn lchown "const char *path" "uid_t owner" "gid_t group"
+.Ft int
.Fn fchown "int fd" "uid_t owner" "gid_t group"
.Sh DESCRIPTION
-The owner ID and group ID of the file
+The owner ID and group ID of the file (or link)
named by
.Fa path
or referenced by
to prevent accidental or mischievous creation of
set-user-id and set-group-id programs.
.Pp
+.Fn Lchown
+operates similarly to how
+.Fn chown
+operated on older systems, and does not follow symbolic links.
+It allows the owner and group of a symbolic link to be set.
+.Pp
.Fn Fchown
is particularly useful when used in conjunction
with the file locking primitives (see
.Va errno .
.Sh ERRORS
.Fn Chown
-will fail and the file will be unchanged if:
+or
+.Fn lchown
+will fail and the file or link will be unchanged if:
.Bl -tag -width Er
.It Bq Er ENOTDIR
A component of the path prefix is not a directory.
.Fn fchown
functions were changed to follow symbolic links in
.Bx 4.4 .
+.Pp
+The
+.Fn lchown
+function was added to OpenBSD due to the above.