One can see here that the broken pipe comes from trying to pipe a mail to a subprocess. Tracing that one too reveals:
dup2(4, 0) = 0
close(4) = 0
close(5) = 0
close(3) = 0
setgid(1021) = 0
setreuid(1021, 1021) = 0
execve("/usr/sbin/sendmail", ["/usr/sbin/sendmail", "-t"], [/* 4 vars */]) = -1 ENOENT (No such file or directory)
exit_group(127) = ?
I.e. /usr/sbin/sendmail doesn't exist. (The error that sudo tried to mail was that my user didn't exist in /etc/sudoers.)
Note that this has nothing to do with the chroot environment as I suspected, but rather that sudo doesn't gracefully handle the case when /usr/sbin/sendmail doesn't exist. I was able to reproduce the same problem outside the chroot.
strace'ing the problem revealed the reason for the cryptic error:
# strace -u mast sudo ls stack=0, flags=CLONE_ CHILD_CLEARTID| CLONE_CHILD_ SETTID| SIGCHLD, child_tidptr= 0x2b34bf991b80) = 15504 S_IFIFO| 0600, st_size=0, ...}) = 0 PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, -1, 0) = 0x2b34bf029000 etc/localtime" , {st_mode= S_IFREG| 0644, st_size=1892, ...}) = 0 etc/localtime" , {st_mode= S_IFREG| 0644, st_size=1892, ...}) = 0 etc/localtime" , {st_mode= S_IFREG| 0644, st_size=1892, ...}) = 0
/.../
pipe([4, 5]) = 0
clone(child_
close(4) = 0
fcntl(5, F_GETFL) = 0x1 (flags O_WRONLY)
fstat(5, {st_mode=
mmap(NULL, 4096, PROT_READ|
lseek(5, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
stat("/
stat("/
stat("/
write(5, "To: root\nFrom: mast\nSubject: ***"..., 176) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
+++ killed by SIGPIPE +++
One can see here that the broken pipe comes from trying to pipe a mail to a subprocess. Tracing that one too reveals:
dup2(4, 0) = 0 "/usr/sbin/ sendmail" , ["/usr/ sbin/sendmail" , "-t"], [/* 4 vars */]) = -1 ENOENT (No such file or directory)
close(4) = 0
close(5) = 0
close(3) = 0
setgid(1021) = 0
setreuid(1021, 1021) = 0
execve(
exit_group(127) = ?
I.e. /usr/sbin/sendmail doesn't exist. (The error that sudo tried to mail was that my user didn't exist in /etc/sudoers.)
Note that this has nothing to do with the chroot environment as I suspected, but rather that sudo doesn't gracefully handle the case when /usr/sbin/sendmail doesn't exist. I was able to reproduce the same problem outside the chroot.