NAME
chown, fchown, lchown - change ownership of a file
SYNOPSIS
#include
#include
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int lchown(const char *path, uid_t owner, gid_t group);
DESCRIPTION
The owner of the file specified by path or by fd is changed. Only the super-user may change the
owner of a file. The owner of a file may change the group of the file to any group of which that
owner is a member. The super-user may change the group arbitrarily.
If the owner or group is specified as -1, then that ID is not changed.
When the owner or group of an executable file are changed by a non-super-user, the S_ISUID and
S_ISGID mode bits are cleared. POSIX does not specify whether this also should happen when root does
the chown; the Linux behaviour depends on the kernel version. In case of a non-group-executable file
(with clear S_IXGRP bit) the S_ISGID bit indicates mandatory locking, and is not cleared by a chown.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
CHMOD(2) Linux Programmer's Manual CHMOD(2)
NAME
chmod, fchmod - change permissions of a file
SYNOPSIS
#include
#include
int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);
DESCRIPTION
The mode of the file given by path or referenced by fildes is changed.
Modes are specified by or'ing the following
S_ISUID 04000 set user ID on execution
S_ISGID 02000 set group ID on execution
S_ISVTX 01000 sticky bit
S_IRUSR (S_IREAD)
00400 read by owner
S_IWUSR (S_IWRITE)
00200 write by owner
S_IXUSR (S_IEXEC)
00100 execute/search by owner
S_IRGRP 00040 read by group
S_IWGRP 00020 write by group
S_IXGRP 00010 execute/search by group
S_IROTH 00004 read by others
S_IWOTH 00002 write by others
S_IXOTH 00001 execute/search by others
The effective UID of the process must be zero or must match the owner of the file.
If the effective UID of the process is not zero and the group of the file does not match the effec?
tive group ID of the process or one of its supplementary group IDs, the S_ISGID bit will be turned
off, but this will not cause an error to be returned.
Depending on the file system, set user ID and set group ID execution bits may be turned off if a file
is written. On some file systems, only the super-user can set the sticky bit, which may have a spe?
cial meaning (e.g., for directories, a file can only be deleted by the owner or the super-user).
On NFS file systems, restricting the permissions will immediately influence already open files,
because the access control is done on the server, but open files are maintained by the client.
Widening the permissions may be delayed for other clients if attribute caching is enabled on them.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
파일 핸들링에 전반에 관한 glibc 레퍼런스
http//database.sarang.net/study/glibc/9.htm
Re: c함수중에 디렉토리의 퍼미션을 변경하는 게 있나요.......
man 페이지에 의하면...
CHOWN(2) Linux Programmer's Manual CHOWN(2)
NAME
chown, fchown, lchown - change ownership of a file
SYNOPSIS
#include
#include
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int lchown(const char *path, uid_t owner, gid_t group);
DESCRIPTION
The owner of the file specified by path or by fd is changed. Only the super-user may change the
owner of a file. The owner of a file may change the group of the file to any group of which that
owner is a member. The super-user may change the group arbitrarily.
If the owner or group is specified as -1, then that ID is not changed.
When the owner or group of an executable file are changed by a non-super-user, the S_ISUID and
S_ISGID mode bits are cleared. POSIX does not specify whether this also should happen when root does
the chown; the Linux behaviour depends on the kernel version. In case of a non-group-executable file
(with clear S_IXGRP bit) the S_ISGID bit indicates mandatory locking, and is not cleared by a chown.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
CHMOD(2) Linux Programmer's Manual CHMOD(2)
NAME
chmod, fchmod - change permissions of a file
SYNOPSIS
#include
#include
int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);
DESCRIPTION
The mode of the file given by path or referenced by fildes is changed.
Modes are specified by or'ing the following
S_ISUID 04000 set user ID on execution
S_ISGID 02000 set group ID on execution
S_ISVTX 01000 sticky bit
S_IRUSR (S_IREAD)
00400 read by owner
S_IWUSR (S_IWRITE)
00200 write by owner
S_IXUSR (S_IEXEC)
00100 execute/search by owner
S_IRGRP 00040 read by group
S_IWGRP 00020 write by group
S_IXGRP 00010 execute/search by group
S_IROTH 00004 read by others
S_IWOTH 00002 write by others
S_IXOTH 00001 execute/search by others
The effective UID of the process must be zero or must match the owner of the file.
If the effective UID of the process is not zero and the group of the file does not match the effec?
tive group ID of the process or one of its supplementary group IDs, the S_ISGID bit will be turned
off, but this will not cause an error to be returned.
Depending on the file system, set user ID and set group ID execution bits may be turned off if a file
is written. On some file systems, only the super-user can set the sticky bit, which may have a spe?
cial meaning (e.g., for directories, a file can only be deleted by the owner or the super-user).
On NFS file systems, restricting the permissions will immediately influence already open files,
because the access control is done on the server, but open files are maintained by the client.
Widening the permissions may be delayed for other clients if attribute caching is enabled on them.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
파일 핸들링에 전반에 관한 glibc 레퍼런스
http//database.sarang.net/study/glibc/9.htm
댓글 달기