I am running a CVS server in a chroot jail, and everything is working
okay, apart from one thing. We have been using a commitinfo script
for a long time with no problems, and now I wanted to add a loginfo
script as well. This however fails with a broken pipe.
If I run the same script from commitinfo, it works, and if I run the cvs
server normally (not in a jail), it also works. To test the later, I run
cvs on the cvs server itself (after I noticed that it failed running
through ssh): with the module i am testing checked out in the cvs-jail:
$ echo "some change" >> /cvs-jail/TestModule/test.txt
$ cvs -d /cvs-jail/mnt/cvsroot commit -m" " /cvs-jail/TestModule
cvs commit: Examining /cvs-jail/TestModule
Checking in /cvs-jail/TestModule/test.txt;
/cvs-jail/mnt/cvsroot/TestModule/test.txt,v <-- test.txt
new revision: 1.49; previous revision: 1.48
done
$ echo "some change" >> /cvs-jail/TestModule/test.txt
$ chroot /cvs-jail/ cvs -d /mnt/cvsroot commit -m" " TestModule
cvs commit: Examining TestModule
Checking in TestModule/test.txt;
/mnt/cvsroot/TestModule/test.txt,v <-- test.txt
new revision: 1.51; previous revision: 1.50
done
cvs [commit aborted]: received broken pipe signal
I have googled for this error, and I have found several mentions
of it, but no solution.
I can provide you with more information (running cvs with trace
output for example) if that would help.
Kind regards,
Maarten
The commitinfo interface doesn't feature this pipe, which is why
your script works in that context.
--- Forwarded mail from mde...@iua.upf.es
--- End of forwarded message from mde...@iua.upf.es
My loginfo script (well, not really a script, but an application written
in C) does not ignore the standard input: I read the stdin while (fgets(...)).
I also tried cat > /dev/null
And besides, it _does_ work when not using the chroot jail. Everything
really points to some problem running the loginfo in a chroot jail..
Maarten
Most likely, the problem is that some command your script uses doesn't
exist in your chroot jail -- perhaps even the script's interpreter. I'd
suggest running CVS with tracing enabled to see if that tells you
anything, although I don't think it will. If not, add an echo into a
file as the very first thing in the script to see if it's being run at
all. If it is, you can add more echos to see where it dies. You could
also try running the script manually inside the chroot jail.
-Larry Jones
What better way to spend one's freedom than eating chocolate
cereal and watching cartoons! -- Calvin
It's not a script, it's a small executable - written in c.
> suggest running CVS with tracing enabled to see if that tells you
> anything, although I don't think it will.
Tried that. Does not tell me anything helpful...
> If not, add an echo into a
> file as the very first thing in the script to see if it's being run at
> all.
Tried fopen, fprintf, fclose. To no avail...
> If it is, you can add more echos to see where it dies. You could
> also try running the script manually inside the chroot jail.
Tried that. It works.
Has anybody here run loginfo's with a chrooted cvs server succesfully?
And could people with a chrooted cvs server test this behaviour?
Maarten
Sorry if this is a silly question, but have you put a shell in your jail?
http://tiefighter.et.tudelft.nl/~arthur/cvsd/faq.html#cvsscripts
HTH,
Geoff
No, I haven't, but why would I? What I execute from loginfo is a standalone
application, it should not need a shell at all.
Maarten
--
Jim Hyslop
Senior Software Designer
Leitch Technology International Inc. (http://www.leitch.com)
Columnist, C/C++ Users Journal (http://www.cuj.com/experts)
Sorry... I thought the link made it clear enough. When you run cvs with the -t
flag, you see a line like the following when loginfo is processed:
-> run_popen( yourLogProgram )
If you look at the cvs sources, you can see on line 396 of run.c that, as its
name would imply, run_popen() uses the popen() call to invoke your "standalone
application":
return (popen (cmd, mode));
Even though yourLogProgram is "standalone", a quick trip to popen(3) reveals:
DESCRIPTION
The popen() function ``opens'' a process by creating a pipe, forking, and
invoking the shell. Since a pipe is by definition unidirectional, the
type argument may specify only reading or writing, not both; the result-
ing stream is correspondingly read-only or write-only.
Notice that the "invoking the shell" part is not optional. Therefore, to use
popen() in a chroot jail (which is required for loginfo) you require a shell.
HTH,
Geoff
Does your program use any shared libraries? They may no longer be accessible
after the chroot. You may need statically linked programs.
-Allan
-----Original Message-----
From: Maarten de Boer [mailto:mde...@iua.upf.es]
Sent: Friday, November 07, 2003 4:05 AM
To: Geoff Beier
Cc: info...@gnu.org
Subject: Re: Broken pipe with loginfo in a chroot jail
> Sorry if this is a silly question, but have you put a shell in your jail?
> http://tiefighter.et.tudelft.nl/~arthur/cvsd/faq.html#cvsscripts
No, I haven't, but why would I? What I execute from loginfo is a standalone
application, it should not need a shell at all.
Maarten
_______________________________________________
Info-cvs mailing list
Info...@gnu.org
http://mail.gnu.org/mailman/listinfo/info-cvs
It's a means of restricting the operations of an application (on UNIX-like
systems) to a particular area of a disk. Here's a pretty good explanation:
http://www.linux-mag.com/2002-12/chroot_01.html
Regards,
Geoff
Ah. That would explain a lot... Which shell would that be? /bin/sh?
Having a shell in the chroot jail is of course far from ideal.. Is there some
way aroudn this? Could I use some shell that allows nothing?
Maarten
donald
On Fri, Nov 07, 2003 at 09:28:57AM -0500, Jim.Hyslop wrote:
> Geoff Beier [mailto:ge...@caradas.com] wrote:
> > Sorry if this is a silly question, but have you put a shell
> > in your jail?
> OK, here's an even sillier question - what is a "chroot jail"?
>
> --
> Jim Hyslop
> Senior Software Designer
> Leitch Technology International Inc. (http://www.leitch.com)
> Columnist, C/C++ Users Journal (http://www.cuj.com/experts)
>
>
1. Get it working using the ash shell... its tiny, mostly bourne- and
POSIX-compliant, and can easily be statically linked.
2. Once that is working reliably, attempt to customize smrsh, rcsh or a
similar restricted shell for my setup.
HTH,
Geoff
Okay, I found the answer to this question.
If can simply rename the application that I want to run on loginfo to
/bin/sh in the chroot jail. That's it! And I could even use argv[2] to use
different functionality (here is passed what you specify in the loginfo
file). This way I want compromise my chroot jail with a full shell.
Thanks a lot for the help and the answers.
Maarten
But CVS doesn't have any way to know that. The administrative files
contain command lines, so CVS passes them to the shell for parsing and
execution. If you don't have a shell, that isn't going to work.
-Larry Jones
Nobody knows how to pamper like a Mom. -- Calvin