Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jan 2012 04:23:22 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: access(FULLPATH, xxx);
Message-ID:  <20120114042322.b234d352.freebsd@edvax.de>
In-Reply-To: <20120114000513.GA17888@thought.org>
References:  <20120114000513.GA17888@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 13 Jan 2012 16:05:18 -0800, Gary Kline wrote:
> 
> excuse this slip of memory, but do you need the full path PLUS  the
> filename to use access? or just the filename?
> 
> say that i'm i n ~/tmp/foob and want to deetermine  wheether i can
> access file foob.  do i need to use "access("home/kline/tmp/foob", F_OK)"
> or will "access("foob", F_OK)"  do the trick?  i have already rub 
> "chdir("~/tmp")" in main(). please note.

According to what I read from "man 2 access" I would
assume it has to be an absolute path. When you read
to the faccessat() function, you'll see:

	The faccessat() system call is equivalent to
	access() except in the case where path specifies
	a relative path.  In this case the file whose
	accessibility is to be determined is located
	relative to the directory associated with the
	file descriptor fd instead of the current
	working directory.  If faccessat() is passed
	the special value AT_FDCWD in the fd parameter,
	the current working directory is used and the
	behavior is identical to a call to access().

Also see "SECURITY CONSIDERATIONS" later on.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120114042322.b234d352.freebsd>