Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chown(1)

chmod(2)

CHOWN(2)  —  HP-UX

NAME

chown, fchown − change owner and group of a file

SYNOPSIS

int chown (path, owner, group)
char ∗path;
int owner, group; fchown (fd, owner, group)
int fd, owner, group;

DESCRIPTION

Path points to a path name naming a file.  Fd is a descriptor for a file.  The owner ID and group ID of the file are set to the numeric values contained in owner and group respectively.  A value of −1 can be specified in owner or group to leave unchanged the file’s owner ID or group ID respectively.  Note that owner and group should be less than or equal to 65535, since only the least significant 16 bits are used. 

Only processes with effective user ID equal to the file owner or super-user may change the ownership of a file.  If privilege groups are supported, the owner of a file may change the ownership only if he is a member of a privilege group allowing chown, as set up by setprivgrp. All users get chown privileges by default. 

The group ownership of a file can be changed to any group in the current process’s access list or to the real or effective group id of the current process.   If privilege groups are supported and the user is permitted the chown privilege, then the file can be given to any group. 

If chown is invoked on a regular file by other than the super-user, the set-user-ID and set-group-ID bits of the file mode will be cleared.  Whether chown preserves or clears these bits on files of other types is implementation-dependent. 

ERRORS

Chown will fail and the owner and group of the file will remain unchanged if one or more of the following are true:

­[EBADF] Fd is not a valid file descriptor. 

­[ENOTDIR] A component of the path prefix is not a directory. 

­[ENOENT] The named file does not exist. 

­[EACCES] Search permission is denied on a component of the path prefix. 

­[EPERM] The effective user ID is not super-user and one or more of the following conditions exist:

The effective user ID does not match the owner of the file. 

When changing the owner of the file, if the owner of the file is not a member of a privilege group allowing chown.

When changing the group of the file, if the owner of the file is not a member of a privilege group allowing chown and the group number is not in the current process’s access list. 

­[EROFS] The named file resides on a read-only file system. 

­[EFAULT] Path points outside the allocated address space of the process.  The reliable detection of this error will be implementation dependent. 

­[ENAMETOOLONG] The named file exceeds MAXPATHLEN characters. 

­[ELOOP] Too many symbolic links were encountered in translating the path name. 

DEPENDENCIES

Series 300 Diskless
Chown does not clear the set-user-ID bit of a directory, because that bit indicates that the directory is hidden (see cdf(4)).

When chown is called from a diskless node, the privilege groups checked are the ones set up on the root server. 

RETURN VALUE

Upon successful completion, a value of 0 is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

AUTHOR

Fchown was developed by the University of California, Berkeley. 

SEE ALSO

chown(1), chmod(2). 

Hewlett-Packard Company  —  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026