client server socket interaction (inetd)

Martin Gregorie martin at address-in-sig.invalid
Fri Feb 18 17:49:36 CET 2011


On Fri, 18 Feb 2011 07:23:35 -0800, Tim wrote:

> Thanks for helping me to understand. I don't know if you're familiar
> with LaTeX, but that's part of what daemon.py calls via subprocess, and
> that is the underlying process I wanted the user to be able to interact
> with.
>
I've used nroff but never LaTeX - however, my understanding is that its 
essentially a batch process.
  
> When LaTeX encounters a problem it stops processing, asks the user what
> to do (like abort/retry, kind-of), and does whatever the user says. The
> daemon.py script handles that okay from the command line, but if I'm
> understanding you this will be much harder if not impossible to
> accomplish from a client communicating over a socket.
>
Are you sure it wouldn't be better to end the run, returning suitable 
error messages to the user, who would correct the input file(s) and rerun 
LaTex?
 
> I thought that maybe I needed to fork the socket (somehow) so it could
> listen after the message is sent, but it looks like it will be more
> complex.
> 
The easier way my be to give the user a login to a captive shell that's 
restricted to running LateX, an editor and little else apart from a 
results viewer. Bash and most decent editors can be restricted so the 
user can't start a second, less restricted shell, and the range of 
programs it can execute can be restricted by adjusting with $PATH. 

You may also be able to find a menu program that can impose many of those 
restrictions by replacing the login's shell by the menu program. I do 
this as a matter of course: my menu program may get released one of these 
days but it's not currently on a fit state to publish.

If you want to continue down the server path you should investigate popen. 
It is part of the os module. You could design the server so a suitable 
request runs LaTeX via popen, captures the stdout and stderr output, if 
any, and returns that and the LaTeX termination status code to the client 
as a response message.

  
-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |



More information about the Python-list mailing list