Open System Services System Calls Reference Manual (G06.25+, H06.03+)

chown(2) OSS System Calls Reference Manual
NAME
chown - Changes the owner and group IDs of a le
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
int chown(
const char *path,
uid_t owner,
gid_t group);
PARAMETERS
path Species the name of the le whose owner ID, group ID, or both are to be
changed. If the nal component of the path parameter names a symbolic link,
the link is traversed, and pathname resolution continues.
When the path parameter refers to a symbolic link, the chown() function
changes the ownership of the le pointed to by the symbolic link.
owner Species a numeric value representing the owner ID.
group Species a numeric value representing the group ID.
DESCRIPTION
The chown() function changes the owner and group of a le.
A process can change the value of the owner ID of an OSS le only if the effective user ID of the
process gives the process appropriate privileges. A process can change the value of the le
group ID if the effective user ID of the process matches the owner ID of the le or the process
has appropriate privileges. A process without appropriate privileges can change the group ID of
a le only to the value of its effective group ID or to a value in its group list. However, if the
chown() function is successfully invoked on a le, the S_ISGID and S_ISUID bits of the
st_mode eld of the stat structure are cleared unless the user has appropriate privileges.
The _POSIX_CHOWN_RESTRICTED feature is enforced for a regular le in the Open Sys-
tem Services le system. Only processes with appropriate privileges can change owner IDs.
If the owner or group parameter is specied as -1 cast to the type of uid_t or gid_t, respectively,
the corresponding ID of the le is unchanged. To change only one attribute, specify the other as
-1.
Upon successful completion, the chown() function marks the st_ctime eld of the le for update.
Use on Guardian Objects
The chown() function can be used on Guardian disk les (that is, disk les in the /G le system).
Attempts to change the ownership of other types of Guardian les fail and set errno to [EIN-
VAL].
For Guardian disk les, Guardian security is used, and any user can ass le ownership to any
other user. A value other than -1 must be specied for the owner parameter (that is, an owner ID
must be specied). However, changing the owner ID also changes the group ID to the Guardian
group ID of the new owner (that is, bits <16:23> of the new access ID). The chown() function
cannot be used to set the group ID for a Guardian le except as a result of changing the owner
ID.
118 Hewlett-Packard Company 527186-003