Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: inetd in perl Message-ID: <8652@jpl-devvax.JPL.NASA.GOV> Date: 9 Jul 90 22:52:51 GMT References: <1990Jul7.030248.11160@fxgrp.fx.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 51 In article <1990Jul7.030248.11160@fxgrp.fx.com> grady@postgres.berkeley.edu writes: : Because I don't think I'll be spending much time hacking on this in the : near future, I figured I'd post this now. This is a version of inetd : written in perl. It parses BSD/SunOS-style inetd.conf files. It is : intended to allow individual (non-root type) users to run their own : servers -- a feature sorely lacking in standard versions. Other : than allowing you to specify your own configuration file, it supports : numbered services as well as names. It handles tcp (stream) and udp : (dgram), wait and nowait sockets. No RPC or internal services. The : two main problems are that it doesn't set the uid (trivial to add, but : I don't have the time or the need), and it can't set argv[0] (since : perl doesn't seem to let you do that). The closest I've come is to : replace argv[0] in the command with the specified server. This may or : may not be adequate. From the manual: If you don't really want to execute the first argu- ment, but want to lie to the program you are execut- ing about its own name, you can specify the program you actually want to run by assigning that to a variable and putting the name of the variable in front of the LIST without a comma. (This always forces interpretation of the LIST as a multi-valued list, even if there is only a single scalar in the list.) Example: $shell = '/bin/csh'; exec $shell '-sh'; # pretend it's a login shell So, in your case, instead of exec split(' ', $command{$service}); you want to say ($realname,@args) = split(' ', $command{$service}); exec $realname @args; and of course add the extra field back into your inetd.conf. The reason for this weird usage is that it's actually just piggy-backed onto the syntax that lets you say print $filehandle LIST; It's a little odd but it helps keep the size of the yacc file within reason. Well, closer to being within reason, anyway. Larry