Writing to A NON-Existing File in "C"
Stephen J. Friedl
friedl at vsi.UUCP
Thu Apr 21 01:40:19 AEST 1988
In article <14020030 at hpisod2.HP.COM>, decot at hpisod2.HP.COM (Dave Decot) writes:
> Uh...I think a file's existence is independent of your user-id.
>
> It's perfectly acceptable to use access(2) the F_OK (0) value of amode
> it to determine whether files exist. Such calls succeed exactly when
> calls to stat(2) succeed.
Not quite -- parent directory modes will get in the way. In the
case where the real uid has no permission in a parent directory
component of a file but but the effective uid does, stat(2)
succeeds and access(2) fails. So,
access("/tmp/secret.dir/open.file", 0);
and
stat("/tmp/secret.dir/open.file", &stbuf);
are not guaranteed to return the same values if /tmp/secret.dir
is available to the set-user-id but not to me.
--
Steve Friedl V-Systems, Inc. Resident access(2) basher
friedl at vsi.com {backbones}!vsi.com!friedl attmail!vsi!friedl
More information about the Comp.unix.wizards
mailing list