bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openat, failing fchdir


From: Bruno Haible
Subject: Re: openat, failing fchdir
Date: Thu, 23 Dec 2010 13:08:14 +0100
User-agent: KMail/1.9.9

Bastien ROUCARIES wrote:
> If chdir is a problem, why not using a heavy weight approach (better safe
> than sorry particularly if gnulib is used for a lot of project):
> - fork and exec an helper for name resolution
> - pass fd using a socket
> 
> It is really heavy but it is on the safe side

I like your idea. It would be a safe way to implement openat().

How does "pass fd using a socket" actually work? There are apparently two
ways to do it [1]:
  - On Unix domain sockets, using sendmsg SCM_RIGHTS [2][3].
    Likely portable to glibc, MacOS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX,
    IRIX, OSF/1, Solaris, Cygwin, Haiku. But not to Interix, mingw, BeOS.
  - On SystemV streams, using ioctl I_SENDFD [4].
    Likely portable to glibc, AIX, HP-UX, IRIX, OSF/1, Solaris.

I don't care much about Interix and BeOS these days any more.

And on mingw, REPLACE_FCHDIR is 1, which means we assume that we use the
emulated fchdir, which associates a file name to every file descriptor
that maps to a directory. In this case, we could implement openat through
filename concatenation.

Bruno

[1] http://archives.neohapsis.com/archives/postfix/2000-09/1476.html
[2] http://linux.die.net/man/7/unix
[3] http://www.normalesup.org/~george/comp/libancillary/
[4] 
http://book.chinaunix.net/special/ebook/addisonWesley/APUE2/0201433079/ch17lev1sec4.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]