Date: Tue, 12 Aug 2008 00:02:13 +0200 From: =?ISO-8859-2?Q?Nejc_=A9koberne?= <nejc@skoberne.net> To: freebsd-fs@freebsd.org Cc: Mitar <mitar@tnode.com>, Weiss <weiss@druga.org> Subject: fchroot on unionfs Message-ID: <48A0B6E5.3000000@skoberne.net>
next in thread | raw e-mail | index | archive | help
Hi, I have a strange problem with Apache not seeing the lower layer of unionfs. Using ktrace on Apache I have written this C code: #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> int main() { int fd; char buf[512]; /* This is what apache does */ fd=open(".",O_RDONLY,0); fchdir(fd); close(fd); /* This is how Apache calls open */ fd=open("/etc/hosts",O_RDONLY,0x1b6); if(fd < 0) { printf("error %d,%d\n",fd,errno); perror(NULL); exit(-1); } read(fd, buf, 511); buf[511]=0; printf("%s",buf); close(fd); return(0); } So without fchdir() call this program just displays (first 511 bytes) of /etc/hosts. If I uncomment fchdir() call with precedent open(".",...) call, I get this: root@web:~# ./a No such file or directory error -1,2 and also if I list the /etc directory with a php script, I see only those files in /etc which are on the upper layer of unionfs. I stumbled upon this problem while trying to figure out why apache can't resolve hostnames I have defined in /etc/hosts. I have this: FreeBSD web.jail 7.0-STABLE FreeBSD 7.0-STABLE #5: Sun Aug 10 09:54:42 CEST 2008 root@server.domain.com:/usr/src/sys/amd64/compile/SERVER amd64 So I am running a jail on a unionfs. Everything works now (after MFCing the unix sockets patch from HEAD to the 7-STABLE (MySQL didn't work)), so I currently have only this problem. I also tried to grep the Apache source code for fchdir, but the call seems to be made implicitely somehow (grep returned no matches). Thanks, Nejc
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48A0B6E5.3000000>