OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / chown.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\" and Copyright (c) 1998 Andries Brouwer (aeb@cwi.nl)
5 .\" and Copyright (c) 2007, 2008 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" Modified by Michael Haardt <michael@moria.de>
28 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
29 .\" Modified 1996-07-09 by Andries Brouwer <aeb@cwi.nl>
30 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
31 .\" Modified 1997-05-18 by Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
32 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" 2007-07-08, mtk, added an example program; updated SYNOPSIS
34 .\" 2008-05-08, mtk, Describe rules governing ownership of new files
35 .\"     (bsdgroups versus sysvgroups, and the effect of the parent
36 .\"     directory's set-group-ID permission bit).
37 .\"
38 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
39 .\"         all rights reserved.
40 .\" Translated 1996-06-24, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
41 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Modified 2004-02-29, Yuichi SATO <ysato444@yahoo.co.jp>
43 .\" Updated & Modified Wed Dec 29 06:48:16 JST 2004 by Yuichi SATO
44 .\" Updated 2007-09-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
45 .\" Updated 2008-08-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
46 .\"
47 .TH CHOWN 2 2008-06-16 "Linux" "Linux Programmer's Manual"
48 .\"O .SH NAME
49 .SH Ì¾Á°
50 .\"O chown, fchown, lchown \- change ownership of a file
51 chown, fchown, lchown \- ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤òÊѹ¹¤¹¤ë
52 .\"O .SH SYNOPSIS
53 .SH ½ñ¼°
54 .B #include <unistd.h>
55 .sp
56 .BI "int chown(const char *" path ", uid_t " owner ", gid_t " group );
57 .br
58 .BI "int fchown(int " fd ", uid_t " owner ", gid_t " group );
59 .br
60 .BI "int lchown(const char *" path ", uid_t " owner ", gid_t " group );
61 .sp
62 .in -4n
63 .\"O Feature Test Macro Requirements for glibc (see
64 .\"O .BR feature_test_macros (7)):
65 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
66 .RB ( feature_test_macros (7)
67 »²¾È):
68 .in
69 .sp
70 .BR fchown (),
71 .BR lchown ():
72 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
73 .\"O .SH DESCRIPTION
74 .SH ÀâÌÀ
75 .\"O These system calls change the owner and group of a file.
76 .\"O The differ only in how the file is specified:
77 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô (owner) ¤È¥°¥ë¡¼¥×¤òÊѹ¹¤¹¤ë¡£
78 ¥·¥¹¥Æ¥à¥³¡¼¥ë´Ö¤Î°ã¤¤¤Ï¡¢¥Õ¥¡¥¤¥ë¤Î»ØÄê¤Î»ÅÊý¤À¤±¤Ç¤¢¤ë¡£
79 .IP * 2
80 .\"O .BR chown ()
81 .\"O changes the ownership of the file specified by
82 .\"O .IR path ,
83 .\"O which is dereferenced if it is a symbolic link.
84 .BR chown ()
85 ¤Ï
86 .I path
87 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î½êÍ­¸¢¤òÊѹ¹¤¹¤ë¡£
88 .I path
89 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Î¾ì¹ç¤Ï¡¢¥ê¥ó¥¯¤ÎŸ³«¤¬¹Ô¤ï¤ì¤ë¡£
90 .IP *
91 .\"O .BR fchown ()
92 .\"O changes the ownership of the file referred to by the open file descriptor
93 .\"O .IR fd .
94 .BR fchown ()
95 ¤Ï¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
96 .I fd
97 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤Î½êÍ­¸¢¤òÊѹ¹¤¹¤ë¡£
98 .IP *
99 .\"O .BR lchown ()
100 .\"O is like
101 .\"O .BR chown (),
102 .\"O but does not dereference symbolic links.
103 .BR lchown ()
104 ¤Ï
105 .BR chown ()
106 ¤ÈƱ¤¸¤À¤¬¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤òŸ³«¤·¤Ê¤¤ÅÀ¤¬°Û¤Ê¤ë¡£
107 .PP
108 .\"O Only a privileged process (Linux: one with the
109 .\"O .B CAP_CHOWN
110 .\"O capability) may change the owner of a file.
111 Æø¢¤ò»ý¤Ä¥×¥í¥»¥¹ (Linux ¤Ç¤Ï
112 .B CAP_CHOWN
113 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤Ä¥×¥í¥»¥¹) ¤À¤±¤¬
114 ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤òÊѹ¹¤Ç¤­¤ë¡£
115 .\"O The owner of a file may change the group of the file
116 .\"O to any group of which that owner is a member.
117 ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤Ï¡¢¤½¤Î½êÍ­¼Ô¤¬Â°¤·¤Æ¤¤¤ë¥°¥ë¡¼¥×¤Î¤¤¤º¤ì¤«¤Ë
118 ¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
119 .\"O A privileged process (Linux: with
120 .\"O .BR CAP_CHOWN )
121 .\"O may change the group arbitrarily.
122 Æø¢ (Linux ¤Ç¤Ï
123 .BR CAP_CHOWN )
124 ¤ò»ý¤Ä¥×¥í¥»¥¹¤Ï¡¢Ç¤°Õ¤Î¥°¥ë¡¼¥×¤ËÊѹ¹¤Ç¤­¤ë¡£
125
126 .\"O If the
127 .\"O .I owner
128 .\"O or
129 .\"O .I group
130 .\"O is specified as \-1, then that ID is not changed.
131 .I owner
132 ¤Þ¤¿¤Ï
133 .I group
134 ¤Ë \-1 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤½¤ì¤é¤Î ID ¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¡£
135
136 .\"O When the owner or group of an executable file are
137 .\"O changed by an unprivileged user the
138 .\"O .B S_ISUID
139 .\"O and
140 .\"O .B S_ISGID
141 .\"O mode bits are cleared.
142 .\"O POSIX does not specify whether
143 .\"O this also should happen when root does the
144 .\"O .BR chown ();
145 ÈóÆø¢¥æ¡¼¥¶¡¼¤Ë¤è¤ê¼Â¹Ô¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤Þ¤¿¤Ï¥°¥ë¡¼¥×¤¬
146 Êѹ¹¤µ¤ì¤¿¾ì¹ç¤Ï
147 .B S_ISUID
148 ¤È
149 .B ISGID
150 ¥â¡¼¥É¥Ó¥Ã¥È¤Ï¥¯¥ê¥¢¤µ¤ì¤ë¡£
151 POSIX ¤Ï¤³¤ÎÆ°ºî¤ä¥ë¡¼¥È¤¬
152 .BR chown ()
153 ¤ò¹Ô¤Ê¤Ã¤¿¾ì¹ç¤Ë¤Ä¤¤¤Æ¤ÏÆä˻ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
154 .\"O the Linux behavior depends on the kernel version.
155 Linux ¤Ë¤ª¤±¤ëÆ°ºî¤Ï¥«¡¼¥Í¥ë¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë°Í¸¤¹¤ë¡£
156 .\"O .\" In Linux 2.0 kernels, superuser was like everyone else
157 .\"O .\" In 2.2, up to 2.2.12, these bits were not cleared for superuser.
158 .\"O .\" Since 2.2.13, superuser is once more like everyone else.
159 .\" Linux 2.0 ¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Ç¤ÎÆ°ºî¤Ï
160 .\" Â¾¤Î¥æ¡¼¥¶¡¼¤Î¾ì¹ç¤ÈƱ¤¸¤Ç¤¢¤Ã¤¿¡£
161 .\" 2.2 ¤Ç¤Ï¡¢2.2.12 ¤Þ¤Ç¤Ï¡¢¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Î¾ì¹ç¤Ë¤Ï
162 .\" ¤³¤ì¤é¤Î¥Ó¥Ã¥È¤Ï¥¯¥ê¥¢¤µ¤ì¤Ê¤¯¤Ê¤Ã¤¿¡£
163 .\" 2.2.13 °Ê¹ß¤Ç¤Ï¡¢¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Ç¤ÎÆ°ºî¤Ï
164 .\" ºÆ¤Ó¾¤Î¥æ¡¼¥¶¡¼¤Î¾ì¹ç¤ÈƱ¤¸¤Ë¤Ê¤Ã¤¿¡£
165 .\"O In case of a non-group-executable file (i.e., one for which the
166 .\"O .B S_IXGRP
167 .\"O bit is not set) the
168 .\"O .B S_ISGID
169 .\"O bit indicates mandatory locking, and is not cleared by a
170 .\"O .BR chown ().
171 È󥰥롼¥×¼Â¹Ô¥Õ¥¡¥¤¥ë
172 .RB ( S_IXGRP
173 ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë) ¤Î¾ì¹ç¤Ë¤Ï
174 .B S_ISGID
175 ¥Ó¥Ã¥È¤Ï¶¯À©¥í¥Ã¥¯ (mandatory locking) ¤ò°ÕÌ£¤·¤Æ¤¤¤ë¡£
176 ¤½¤·¤Æ¤½¤ì¤Ï
177 .BR chown ()
178 ¤Ç¤Ï¥¯¥ê¥¢¤Ç¤­¤Ê¤¤¡£
179 .\"O .SH "RETURN VALUE"
180 .SH ÊÖ¤êÃÍ
181 .\"O On success, zero is returned.
182 .\"O On error, \-1 is returned, and
183 .\"O .I errno
184 .\"O is set appropriately.
185 À®¸ù¤¹¤ë¤È¡¢0 ¤òÊÖ¤¹¡£
186 ¼ºÇÔ¤¹¤ë¤È¡¢\-1 ¤òÊÖ¤·¡¢
187 .I errno
188 ¤ËŬÀÚ¤ÊÃͤòÀßÄꤹ¤ë¡£
189 .\"O .SH ERRORS
190 .SH ¥¨¥é¡¼
191 .\"O Depending on the file system, other errors can be returned.
192 .\"O The more general errors for
193 .\"O .BR chown ()
194 .\"O are listed below.
195 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¾¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë»ö¤¬¤¢¤ë¡£
196 .B chmod
197 ¤Ç°ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë¡£
198 .TP
199 .B EACCES
200 .\"O Search permission is denied on a component of the path prefix.
201 .\"O (See also
202 .\"O .BR path_resolution (7).)
203 .I path
204 ¤Î¹½À®Í×ÁǤ˸¡º÷µö²Ä (search permission) ¤¬¤Ê¤¤
205 .RB ( path_resolution (7)
206 ¤â»²¾È)¡£
207 .TP
208 .B EFAULT
209 .\"O .I path
210 .\"O points outside your accessible address space.
211 .I path
212 ¤¬³ä¤êÅö¤Æ¤é¤ì¤¿¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
213 .TP
214 .B ELOOP
215 .\"O Too many symbolic links were encountered in resolving
216 .\"O .IR path .
217 .I path
218 ¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
219 .TP
220 .B ENAMETOOLONG
221 .\"O .I path
222 .\"O is too long.
223 .I path
224 ¤¬Ä¹²á¤®¤ë¡£
225 .TP
226 .B ENOENT
227 .\"O The file does not exist.
228 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
229 .TP
230 .B ENOMEM
231 .\"O Insufficient kernel memory was available.
232 ¥«¡¼¥Í¥ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
233 .TP
234 .B ENOTDIR
235 .\"O A component of the path prefix is not a directory.
236 .I path
237 ¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
238 .TP
239 .B EPERM
240 .\"O The calling process did not have the required permissions
241 .\"O (see above) to change owner and/or group.
242 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë½êÍ­¼Ô¤Þ¤¿¤Ï¥°¥ë¡¼¥× (¤â¤·¤¯¤Ï¤½¤ÎξÊý) ¤òÊѹ¹¤¹¤ë¤¿¤á¤Ë
243 Í׵ᤵ¤ì¤ëµö²Ä (¾åµ­¤ò»²¾È) ¤¬¤Ê¤¤¡£
244 .TP
245 .B EROFS
246 .\"O The named file resides on a read-only file system.
247 »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤¬Æɤ߹þ¤ßÀìÍÑ (read-only) ¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¾å¤Ë¤¢¤ë¡£
248 .PP
249 .\"O The general errors for
250 .\"O .BR fchown ()
251 .\"O are listed below:
252 .BR fchown ()
253 ¤Ç°ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë:
254 .TP
255 .B EBADF
256 .\"O The descriptor is not valid.
257 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤¬Í­¸ú¤Ç¤Ê¤¤¡£
258 .TP
259 .B EIO
260 .\"O A low-level I/O error occurred while modifying the inode.
261 i ¥Î¡¼¥É (inode) ¤òÊѹ¹¤¹¤ëºÝ¤ËÄã¥ì¥Ù¥ë I/O ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
262 .TP
263 .B ENOENT
264 .\"O See above.
265 ¾åµ­¤ò»²¾È¡£
266 .TP
267 .B EPERM
268 .\"O See above.
269 ¾åµ­¤ò»²¾È¡£
270 .TP
271 .B EROFS
272 .\"O See above.
273 ¾åµ­¤ò»²¾È¡£
274 .\"O .SH "CONFORMING TO"
275 .SH ½àµò
276 4.4BSD, SVr4, POSIX.1-2001.
277
278 .\"O The 4.4BSD version can only be
279 .\"O used by the superuser (that is, ordinary users cannot give away files).
280 4.4BSD ÈǤǤϥ¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Î¤ß¤¬»ÈÍѤǤ­¤ë
281 (¤Ä¤Þ¤ê¡¢ÉáÄ̤Υ桼¥¶¡¼¤Ï¥Õ¥¡¥¤¥ë¤ò¼êÊü¤¹¤³¤È¤Ï¤Ç¤­¤Ê¤¤)¡£
282 .\"O .\" chown():
283 .\"O .\" SVr4 documents EINVAL, EINTR, ENOLINK and EMULTIHOP returns, but no
284 .\"O .\" ENOMEM.  POSIX.1 does not document ENOMEM or ELOOP error conditions.
285 .\" chown():
286 .\" SVr4 ¤Ë¤Ï EINVAL, EINTR, ENOLINK, EMULTIHOP ¤òÊÖ¤¹¤Èµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢
287 .\" ENOMEM ¤Ï¤Ê¤¤¡£
288 .\" POSIX.1 ¤Ë¤Ï ENOMEM, ELOOP ¤Ë¤Ä¤¤¤Æµ­ºÜ¤Ï¤Ê¤¤¡£
289 .\"O .\" fchown():
290 .\"O .\" SVr4 documents additional EINVAL, EIO, EINTR, and ENOLINK
291 .\"O .\" error conditions.
292 .\" fchown():
293 .\" SVr4 ¤Ë¤Ï¾¤Ë EINVAL, EIO, EINTR, ENOLINK ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤Îµ­ºÜ¤¬¤¢¤ë¡£
294 .\"O .SH NOTES
295 .SH Ãí°Õ
296 .\"O When a new file is created (by, for example,
297 .\"O .BR open (2)
298 .\"O or
299 .\"O .BR mkdir (2)),
300 .\"O its owner is made the same as the file system user ID of the
301 .\"O creating process.
302 .RB ( open (2)
303 ¤ä
304 .BR mkdir (2)
305 ¤Ê¤É¤Ë¤è¤ê) ¿·¤·¤¤¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤ë¤È¤­¡¢
306 ¤½¤Î½êÍ­¼Ô¤Ï¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¡¦¥æ¡¼¥¶ ID ¤È
307 Ʊ¤¸¤ËÀßÄꤵ¤ì¤ë¡£
308 .\"O The group of the file depends on a range of factors,
309 .\"O including the type of file system,
310 .\"O the options used to mount the file system,
311 .\"O and whether or not the set-group-ID permission bit is enabled
312 .\"O on the parent directory.
313 ¤½¤Î¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤Ï¤¤¤¯¤Ä¤«¤ÎÍ×°ø¤Ë¤è¤ê·èÄꤵ¤ì¤ë¡£
314 ¤½¤ÎÍ×°ø¤È¤·¤Æ¤Ï¡¢
315 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¼ïÎà¡¢¤½¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¥Þ¥¦¥ó¥È»þ¤Ë
316 »ÈÍѤµ¤ì¤¿¥ª¥×¥·¥ç¥ó¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ç set-group-ID µö²Ä¥Ó¥Ã¥È¤¬
317 Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤É¤¦¤«¡¢¤¬¤¢¤ë¡£
318 .\"O If the file system supports the
319 .\"O .I "\-o\ grpid"
320 .\"O (or, synonymously
321 .\"O .IR "\-o\ bsdgroups" )
322 .\"O and
323 .\"O .I "\-o\ nogrpid"
324 .\"O (or, synonymously
325 .\"O .IR "\-o\ sysvgroups" )
326 .\"O .BR mount (8)
327 .\"O options, then the rules are as follows:
328 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬
329 .BR mount (8)
330 ¥ª¥×¥·¥ç¥ó¤Î
331 .I "\-o\ grpid"
332 .RI ( "\-o\ bsdgroups"
333 ¤âƱµÁ¸ì) ¤È
334 .I "\-o\ nogrpid"
335 .RI ( "\-o sysvgroups"
336 ¤âƱµÁ¸ì) ¤ËÂбþ¤·¤Æ¤¤¤ë¾ì¹ç¡¢¥ë¡¼¥ë¤Ï°Ê²¼¤ÎÄ̤ê¤È¤Ê¤ë¡£
337 .IP * 2
338 .\"O If the file system is mounted with
339 .\"O .IR "\-o\ grpid" ,
340 .\"O then the group of a new file is made
341 .\"O the same as that of the parent directory.
342 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬
343 .I "\-o\ grpid"
344 ÉÕ¤­¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¿·¤·¤¤¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤Ï
345 ¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î¥°¥ë¡¼¥×¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
346 .IP *
347 .\"O If the file system is mounted with
348 .\"O .IR "\-o\ nogrpid"
349 .\"O and the set-group-ID bit is disabled on the parent directory,
350 .\"O then the group of a new file is made the same as the
351 .\"O process's file system GID.
352 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬
353 .I "\-o\ nogrpid"
354 ÉÕ¤­¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤ª¤ê¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï set-group-ID ¥Ó¥Ã¥È¤¬
355 ̵¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢¿·¤·¤¤¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤Ï
356 ¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à GID ¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
357 .IP *
358 .\"O If the file system is mounted with
359 .\"O .IR "\-o\ nogrpid"
360 .\"O and the set-group-ID bit is enabled on the parent directory,
361 .\"O then the group of a new file is made
362 .\"O the same as that of the parent directory.
363 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬
364 .I "\-o\ nogrpid"
365 ÉÕ¤­¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤ª¤ê¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï set-group-ID ¥Ó¥Ã¥È¤¬
366 Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢¿·¤·¤¤¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤Ï
367 ¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î¥°¥ë¡¼¥×¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
368 .PP
369 .\"O As at Linux 2.6.25,
370 .\"O the
371 .\"O .IR "\-o\ grpid"
372 .\"O and
373 .\"O .IR "\-o\ nogrpid"
374 .\"O mount options are supported by ext2, ext3, ext4, and XFS.
375 .\"O File systems that don't support these mount options follow the
376 .\"O .IR "\-o\ nogrpid"
377 .\"O rules.
378 Linux 2.6.25 ¤Ç¤Ï¡¢¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó
379 .I "\-o\ grpid"
380 ¤È
381 .I "\-o\ nogrpid"
382 ¤ËÂбþ¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ï
383 ext2, ext3, ext4, XFS ¤Ç¤¢¤ë¡£
384 ¤³¤ì¤é¤Î¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó¤ËÂбþ¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
385 .I "\-o\ nogrpid"
386 ¤Ë´Ø¤¹¤ë¥ë¡¼¥ë¤¬Å¬ÍѤµ¤ì¤ë¡£
387 .PP
388 .\"O The
389 .\"O .BR chown ()
390 .\"O semantics are deliberately violated on NFS file systems
391 .\"O which have UID mapping enabled.
392 .\"O Additionally, the semantics of all system
393 .\"O calls which access the file contents are violated, because
394 .\"O .BR chown ()
395 .\"O may cause immediate access revocation on already open files.
396 .\"O Client side
397 .\"O caching may lead to a delay between the time where ownership have
398 .\"O been changed to allow access for a user and the time where the file can
399 .\"O actually be accessed by the user on other clients.
400 .BR chown ()
401 Êý¼°¤Ï UID ¥Þ¥Ã¥Ô¥ó¥°¤ò»ÈÍѤ·¤¿
402 NFS ¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤ò¿¯³²¤¹¤ë¡£
403 ¤µ¤é¤Ë¥Õ¥¡¥¤¥ë¤ÎÆâÍƤ˥¢¥¯¥»¥¹¤¹¤ëÁ´¤Æ¤Î¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤ò¿¯³²¤¹¤ë¡£
404 ¤³¤ì¤Ï
405 .BR chown ()
406 ¤¬´û¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë
407 ¥¢¥¯¥»¥¹¤ò¤¿¤À¤Á¤Ë¼è¤ê¾Ã¤¹¤³¤È¤Ë¤è¤ë¡£
408 ¥¯¥é¥¤¥¢¥ó¥È¦¤Î¥­¥ã¥Ã¥·¥å¤Ë¤è¤ê½êÍ­¸¢¤¬Êѹ¹¤µ¤ì¤Æ
409 ¥æ¡¼¥¶¡¼¤Î¥¢¥¯¥»¥¹¤¬µö¤·¤¿»þÅÀ¤È¡¢¼ÂºÝ¤Ë¾¤Î¥¯¥é¥¤¥¢¥ó¥È¤Ç¥æ¡¼¥¶¡¼¤Ë¤è¤Ã¤Æ
410 ¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤Ç¤­¤ë»þÅÀ¤È¤Î´Ö¤Ë»þ´Öº¹¤¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
411
412 .\"O In versions of Linux prior to 2.1.81 (and distinct from 2.1.46),
413 .\"O .BR chown ()
414 .\"O did not follow symbolic links.
415 Linux ¤Î 2.1.81 ¤è¤êÁ°¤Î¥Ð¡¼¥¸¥ç¥ó (Æäˠ2.1.46 °ÊÁ°) ¤Ç¤Ï¡¢
416 .BR chown ()
417 ¤Ï¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤òÄÉÀפ·¤Ê¤¤¡£
418 .\"O Since Linux 2.1.81,
419 .\"O .BR chown ()
420 .\"O does follow symbolic links, and there is a new system call
421 .\"O .BR lchown ()
422 .\"O that does not follow symbolic links.
423 Linux 2.1.81 °Ê¹ß¤Ç¤Ï
424 .BR chown ()
425 ¤Ï¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤òÄÉÀפ·¡¢¿·¤¿¤Ê¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë
426 .BR lchown ()
427 ¤Ï¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤òÄÉÀפ·¤Ê¤¤¡£
428 .\"O Since Linux 2.1.86, this new call (that has the same semantics
429 .\"O as the old
430 .\"O .BR chown ())
431 .\"O has got the same syscall number, and
432 .\"O .BR chown ()
433 .\"O got the newly introduced number.
434 Linux 2.1.86 °Ê¹ß¤Ç¤Ï¤³¤Î¿·¤·¤¤¥³¡¼¥ë (¸Å¤¤
435 .BR chown ()
436 ¤ÈÁ´¤¯Æ±¤¸Æ°ºî¤ò¹Ô¤Ê¤¦) ¤ÏƱ¤¸¥·¥¹¥Æ¥à¥³¡¼¥ëÈÖ¹æ¤ò»ý¤Á
437 .BR chown ()
438 ¤Ï¿·¤·¤¯Æ³Æþ¤µ¤ì¤¿ÈÖ¹æ¤ò»ý¤Ä¡£
439 .\"O .SH EXAMPLE
440 .SH Îã
441 .PP
442 .\"O The following program changes the ownership of the file named in
443 .\"O its second command-line argument to the value specified in its
444 .\"O first command-line argument.
445 .\"O The new owner can be specified either as a numeric user ID,
446 .\"O or as a username (which is converted to a user ID by using
447 .\"O .BR getpwnam (3)
448 .\"O to perform a lookup in the system password file).
449 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢
450 Æó¤ÄÌܤΥ³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤ò¡¢
451 °ì¤ÄÌܤΥ³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿ÃͤËÊѹ¹¤¹¤ë¡£
452 ¿·¤·¤¤½êÍ­¼Ô¤Ï¡¢¿ô»ú¤Î¥æ¡¼¥¶ ID ¤«¥æ¡¼¥¶Ì¾¤Î¤¤¤º¤ì¤«¤Ç»ØÄê¤Ç¤­¤ë
453 (¥æ¡¼¥¶Ì¾¤Ç»ØÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢
454 .BR getpwnam (3)
455 ¤ò»È¤Ã¤Æ¥·¥¹¥Æ¥à¤Î¥Ñ¥¹¥ï¡¼¥É¥Õ¥¡¥¤¥ë¤Î¸¡º÷¤¬¹Ô¤ï¤ì¡¢
456 ¥æ¡¼¥¶ ID ¤Ø¤ÎÊÑ´¹¤¬¹Ô¤ï¤ì¤ë)¡£
457 .nf
458
459 #include <pwd.h>
460 #include <stdio.h>
461 #include <stdlib.h>
462 #include <unistd.h>
463
464 int
465 main(int argc, char *argv[])
466 {
467     uid_t uid;
468     struct passwd *pwd;
469     char *endptr;
470
471     if (argc != 3 || argv[1][0] == \(aq\\0\(aq) {
472         fprintf(stderr, "%s <owner> <file>\\n", argv[0]);
473         exit(EXIT_FAILURE);
474     }
475
476     uid = strtol(argv[1], &endptr, 10);  /* Allow a numeric string */
477
478     if (*endptr != \(aq\\0\(aq) {         /* Was not pure numeric string */
479         pwd = getpwnam(argv[1]);   /* Try getting UID for username */
480         if (pwd == NULL) {
481             perror("getpwnam");
482             exit(EXIT_FAILURE);
483         }
484
485         uid = pwd\->pw_uid;
486     }
487
488     if (chown(argv[2], uid, \-1) == \-1) {
489         perror("chown");
490         exit(EXIT_FAILURE);
491     } /* if */
492
493     exit(EXIT_SUCCESS);
494 } /* main */
495 .fi
496 .\"O .SH "SEE ALSO"
497 .SH ´ØÏ¢¹àÌÜ
498 .BR chmod (2),
499 .BR fchownat (2),
500 .BR flock (2),
501 .BR path_resolution (7),
502 .BR symlink (7)