.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Modified by Michael Haardt .\" Modified 1993-07-21 by Rik Faith .\" Modified 1997-01-12 by Michael Haardt .\" : NFS details .\" Modified 2004-06-23 by Michael Kerrisk .\" .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara .\" all rights reserved. .\" Translated 1996-06-24, Yosiaki Yanagihara .\" Modified 1998-05-11, HANATAKA Shinya .\" Updated & Modified 2001-06-25, Yuichi SATO .\" Updated & Modified 2004-12-29, Yuichi SATO .\" Updated 2008-08-09, Akihiro MOTOKI , LDP v3.05 .\" .TH CHMOD 2 2010-09-26 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O chmod, fchmod \- change permissions of a file chmod, fchmod \- ファイルのモードを変更する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "int chmod(const char *" path ", mode_t " mode ); .br .BI "int fchmod(int " fd ", mode_t " mode ); .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .ad l .PD 0 .BR fchmod (): .RS 4 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .br .\"O || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L .PD .ad .\"O .SH DESCRIPTION .SH 説明 .\"O These system calls change the permissions of a file. .\"O They differ only in how the file is specified: これらのシステムコールはファイルのアクセス許可 (permission) を変更する。 システムコール間の違いは、ファイルの指定の仕方だけである。 .IP * 2 .\"O .BR chmod () .\"O changes the permissions of the file specified whose pathname is given in .\"O .IR path , .\"O which is dereferenced if it is a symbolic link. .BR chmod () は、 .I path で指定されたパス名を持つファイルの許可を変更する。 .I path がシンボリック・リンクの場合は、リンクの展開が行われる。 .IP * .\"O .BR fchmod () .\"O changes the permissions of the file referred to by the open file descriptor .\"O .IR fd . .BR fchmod () は、オープンされたファイルディスクリプタ .I fd により参照されるファイルの許可を変更する。 .PP .\"O The new file permissions are specified in .\"O .IR mode , .\"O which is a bit mask created by ORing together zero or .\"O more of the following: 新しいファイル許可は .I mode で指定される。 .I mode は、以下に示す値の 0 個以上の OR (論理和) をとって作成される ビットマスクである。 .TP 18 .BR S_ISUID " (04000)" .\"O set-user-ID (set process effective user ID on .\"O .BR execve (2)) set-user-ID .RB ( execve (2) 時にプロセスの実効ユーザ ID にセットされる) .TP .BR S_ISGID " (02000)" .\"O set-group-ID (set process effective group ID on .\"O .BR execve (2); .\"O mandatory locking, as described in .\"O .BR fcntl (2); .\"O take a new file's group from parent directory, as described in .\"O .BR chown (2) .\"O and .\"O .BR mkdir (2)) set-group-ID (以下の場合に .RB ( execve (2) 実行時にプロセスの実効グループ ID にセットされる、 強制ロック (mandatory locking) を行う .RB ( fcntl (2) の説明を参照)、 新しいファイルのグループとして親ディレクトリと同じものを使う .RB ( chown (2) と .BR ( mkdir (2) の説明を参照) .TP .BR S_ISVTX " (01000)" .\"O sticky bit (restricted deletion flag, as described in .\"O .BR unlink (2)) スティッキー・ビット (sticky bit) (削除制限フラグ、 .BR unlink (2) の説明を参照) .TP .BR S_IRUSR " (00400)" .\"O read by owner 所有者による読み取り .TP .BR S_IWUSR " (00200)" .\"O write by owner 所有者による書き込み .TP .BR S_IXUSR " (00100)" .\"O execute/search by owner ("search" applies for directories, .\"O and means that entries within the directory can be accessed) 所有者による実行 (execute) / 検索 (search) (「検索」はディレクトリに対して適用されるもので、 そのディレクトリ内のエントリーへアクセスできるかを意味する) .TP .BR S_IRGRP " (00040)" .\"O read by group グループによる読み取り .TP .BR S_IWGRP " (00020)" .\"O write by group グループによる書き込み .TP .BR S_IXGRP " (00010)" .\"O execute/search by group グループによる実行 / 検索 .TP .BR S_IROTH " (00004)" .\"O read by others 他人 (others) による読み取り .TP .BR S_IWOTH " (00002)" .\"O write by others 他人による書き込み .TP .BR S_IXOTH " (00001)" .\"O execute/search by others 他人による実行 / 検索 .PP .\"O The effective UID of the calling process must match the owner of the file, .\"O or the process must be privileged (Linux: it must have the .\"O .B CAP_FOWNER .\"O capability). 呼び出したプロセスの実効 (effective) UID がファイルの所有者と一致するか、 そのプロセスが特権を持たなければならない (Linux では .B CAP_FOWNER ケーパビリティ (capability) を持たなければならない)。 .\"O If the calling process is not privileged (Linux: does not have the .\"O .B CAP_FSETID .\"O capability), and the group of the file does not match .\"O the effective group ID of the process or one of its .\"O supplementary group IDs, the .\"O .B S_ISGID .\"O bit will be turned off, .\"O but this will not cause an error to be returned. 呼び出したプロセスに特権がなく (Linux では .B CAP_FSETID ケーパビリティがなく)、かつファイルのグループ ID が プロセスの実効グループ ID または補助的なグループ ID にマッチしない場合、 .B S_ISGID ビットはオフにされるが、これによってエラーが返されることはない。 .\"O As a security measure, depending on the file system, .\"O the set-user-ID and set-group-ID execution bits .\"O may be turned off if a file is written. 安全のための処置として、 ファイル・システムによっては、ファイルの書き込みを行う時に セット・ユーザー ID とセット・グループ ID ビットと実行ビットが オフにされることがある。 .\"O (On Linux this occurs if the writing process does not have the .\"O .B CAP_FSETID .\"O capability.) (Linux では、書き込みプロセスが .B CAP_FSETID ケーパビリティを持っていない場合に、これが起こる。) .\"O On some file systems, only the superuser can set the sticky bit, .\"O which may have a special meaning. .\"O For the sticky bit, and for set-user-ID and set-group-ID bits on .\"O directories, see .\"O .BR stat (2). ファイル・システムの中には、スーパー・ユーザーだけが 特別の意味を持つスティッキー・ビットを設定できるものがある。 スティッキー・ビットとディレクトリに対する セット・ユーザー (グループ)・ID ビットについては、 .BR stat (2) を見よ。 .\"O On NFS file systems, restricting the permissions will immediately influence .\"O already open files, because the access control is done on the server, but .\"O open files are maintained by the client. .\"O Widening the permissions may be .\"O delayed for other clients if attribute caching is enabled on them. NFS ファイルシステム上では、パーミッションを制限すると、 既にオープンされているファイルに対してすぐに影響が及ぶ。 これはアクセス制御がサーバー上で行われているが、 オープンされているファイルはクライアント側で管理されているためである。 クライアント側でファイル属性のキャッシュが有効になっている場合に、 パーミッションの制限を緩くすると、 他のクライアントに情報が伝わるのが遅れるかもしれない。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, zero is returned. .\"O On error, \-1 is returned, and .\"O .I errno .\"O is set appropriately. 成功すると、0 を返す。失敗すると、\-1を返し、 .I errno に適切な値を設定する。 .\"O .SH ERRORS .SH エラー .\"O Depending on the file system, other errors can be returned. .\"O The more general errors for .\"O .BR chmod () .\"O are listed below: ファイル・システムによっては他のエラーを返す場合がある。 .BR chmod () で一般的なエラーを以下に挙げる。 .TP .B EACCES .\"O Search permission is denied on a component of the path prefix. .\"O (See also .\"O .BR path_resolution (7).) パス名の構成要素に検索許可がない .RB ( path_resolution (7) も見よ)。 .TP .B EFAULT .\"O .I path .\"O points outside your accessible address space. .I path が割り当てられたアドレス空間外を指している。 .TP .B EIO .\"O An I/O error occurred. I/O エラーが発生した。 .TP .B ELOOP .\"O Too many symbolic links were encountered in resolving .\"O .IR path . .I path を解決する際に遭遇したシンボリック・リンクが多過ぎる。 .TP .B ENAMETOOLONG .\"O .I path .\"O is too long. .I path が長過ぎる。 .TP .B ENOENT .\"O The file does not exist. ファイルが存在しない。 .TP .B ENOMEM .\"O Insufficient kernel memory was available. カーネルに十分なメモリがない。 .TP .B ENOTDIR .\"O A component of the path prefix is not a directory. パス名の構成要素がディレクトリではない。 .TP .B EPERM .\"O The effective UID does not match the owner of the file, .\"O and the process is not privileged (Linux: it does not have the .\"O .B CAP_FOWNER .\"O capability). 実効 UID がファイルの所有者と一致せず、プロセスに特権がない (Linux では .B CAP_FOWNER ケーパビリティを持たない)。 .TP .B EROFS .\"O The named file resides on a read-only file system. ファイルが読み込み専用 (read only) のファイル・システム上にある。 .PP .\"O The general errors for .\"O .BR fchmod () .\"O are listed below: .BR fchmod () で一般的なエラーを挙げる: .TP .B EBADF .\"O The file descriptor .\"O .I fd .\"O is not valid. ファイル・ディスクリプター .I fd が有効でない。 .TP .B EIO .\"O See above. 上記を参照。 .TP .B EPERM .\"O See above. 上記を参照。 .TP .B EROFS .\"O See above. 上記を参照。 .\"O .SH "CONFORMING TO" .SH 準拠 4.4BSD, SVr4, POSIX.1-2001. .\"O .SH "SEE ALSO" .SH 関連項目 .BR chown (2), .BR execve (2), .BR fchmodat (2), .BR open (2), .BR stat (2), .BR path_resolution (7)