Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Dec 2003 19:41:46 +0200
From:      "Emil Filipov" <tie@einet.bg>
To:        <questions@FreeBSD.org>
Subject:   Problems with Freebsd 5.1, jail and php mail() function (straced)
Message-ID:  <00e501c3c3fc$1fa99c10$6e00a8c0@filipov>

next in thread | raw e-mail | index | archive | help
Hi,

I have a FreeBSD 5.1 box with jails. Some of them are 'builded' (with =
make world and make distribution), others I have created 'by hand' by =
copying files in the jail until things start to work.

In one such 'handmade' jail I have deployed ftpd, apache with php,ssmtp. =
Everything seems to be working fine except for the php mail() function.=20

As usual when there is no log message or warning giving a hint what is =
missing, I tried to strace the process.Started with creating a simple =
enough .php page, taken directly from a php manual:
<?php
        mail("tie@einet.bg", "My Subject", "Line 1\nLine 2\nLine 3");
        ?>
I tested it out of the jail environment and it worked. Tested it in a =
'builded' jail - also works.Strace is normal.
While trying to strace it while executing within such 'handmade' jail I =
get some output I have never seen:


# strace -ffp 43685
accept(16,


{...}, 0xbfbffb6c)           =3D 0
syscall_416(0x1e, 0xbfbffb10, 0xbfbffaf0) =3D 0
fcntl(0, F_SETFD, FD_CLOEXEC)           =3D 0
getsockname(0, {...}, 0xbfbffb6c)       =3D 0
setsockopt(0, 0x6 /* SOL_?? */, TCP_NODELAY, 0xbfbffb30, 4) =3D 0
read(0, "GET /mytest.php HTTP/1.1\r\nAccept"..., 4096) =3D 202
syscall_416(0x1e, 0xbfbfda70, 0xbfbfda50) =3D 0
gettimeofday({791289914, 1091177770}, NULL) =3D 0
stat("/site/html/mytest.php", {st_mode=3DS_IFREG|0644, st_size=3D74, =
...}) =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
umask(077)                              =3D 022
umask(022)                              =3D 077
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
setitimer(ITIMER_PROF, {it_interval=3D{0, 2047}, it_value=3D{0, 0}}, =
NULL) =3D 0
syscall_416(0x1b, 0xbfbff800, 0xbfbff7e0) =3D 0
sigprocmask(SIG_UNBLOCK, [], NULL)      =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
__getcwd("", 4095)                      =3D 0
chdir("")                               =3D 0
lstat("", {st_mode=3D0415, st_size=3D1292785156096, ...}) =3D 0
lstat("=D1=9C", {st_mode=3D0, st_size=3D408021893229, ...}) =3D 0
lstat("c", {st_mode=3D0234, st_size=3D1653562409295, ...}) =3D 0
setitimer(ITIMER_PROF, {it_interval=3D{113, 107}, it_value=3D{232, 0}}, =
NULL) =3D 0
syscall_416(0x1b, 0xbfbfe3a0, 0xbfbfe380) =3D 0
sigprocmask(SIG_UNBLOCK, [], NULL)      =3D 0
__getcwd("", 1024)                      =3D 0
lstat("", {st_mode=3D0151060, st_size=3D15960098996242, ...}) =3D 0
lstat("", {st_mode=3D0, st_size=3D2946347565072, ...}) =3D 0
lstat("", {st_mode=3D073620, st_size=3D17364553302034, ...}) =3D 0
open("/site/html/mytest.php", O_RDONLY) =3D 1
fstat(1, {st_mode=3D023, st_size=3D8070450533662672128, ...}) =3D 0
fstat(1, {st_mode=3D0162755, st_size=3D6875142181715337580, ...}) =3D 0
lseek(1, 0, SEEK_CUR)                   =3D 0
lseek(1, 0, SEEK_SET)                   =3D 0
read(1, "<?php\n\tmail(\"tie@einet.bg\", \"My "..., 8192) =3D 74
read(1, "", 8192)                       =3D 0
close(1)                                =3D 0
pipe([1, 3])                            =3D 1
vfork(strace: open("/proc/...", ...): No such file or directory
)                                 =3D 45534
--- SIGCHLD (Child exited) ---
fcntl(3, F_GETFL)                       =3D 0x2 (flags O_RDWR)
close(1)                                =3D 0
fstat(3, {st_mode=3DS_IFCHR|S_ISUID|0154, st_rdev=3Dmakedev(98, =
577175598), ...}) =3D 0
write(3, "To: tie@einet.bg\nSubject: My Sub"..., 59) =3D -1 EPIPE =
(Broken pipe)
--- SIGPIPE (Broken pipe) ---
close(3)                                =3D 0
wait4(45534, [WIFSIGNALED(s) && WTERMSIG(s) =3D=3D 106], 0, NULL) =3D =
45534
chdir("

Line 1
Line 2
Line 3
Line 3\");
        ?>
") =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
sigprocmask(SIG_BLOCK, NULL, [])        =3D 0
setitimer(ITIMER_PROF, {it_interval=3D{0, 2047}, it_value=3D{0, 0}}, =
NULL) =3D 0
umask(022)                              =3D 022
select(1, [], NULL, NULL, {0, 674295616}) =3D 0 (Timeout)
write(0, "HTTP/1.1 200 OK\r\nDate: Tue, 16 D"..., 210) =3D 210
 (sorry for the lenghty output)

This is a trace from one of the apache processes (the one which handles =
the GET request for the former page). We see that everything is fine =
UNTIL it comes time to fork() and invoke the php interpreter. I don't =
understand what happens when that time comes - strace cannot follow the =
vfork for some reasons. Of course I have tried with other parameters =
also -F -v -s 100 , but haven't obtained more information about that.=20
I have mounted /proc in the jail, but the same problem occurs. I have =
also tried to run strace from within the jail - same error.

I would really appreciate any hint about what might be missing. Without =
strace I'm kind of blind :)

P.S.: One thing I almost forgot. I can execute jls from within the jail =
and see some information about the other jailed hosts. Probably =
shouldn't be like that?

TIA,
Emil Filipov



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00e501c3c3fc$1fa99c10$6e00a8c0>