Calling programs through inetd & services

Calling programs through inetd & services

Post by Michael John Ell » Wed, 16 Mar 1994 05:23:29



Hey there ppl.

I'm sure someone knows this but again, I'm pretty clueless. (how unusual. :-)

Anyway, I'm calling a program through inetd.conf & services etc.

No problems so far.

The thing is that I NEED the program I'm calling to know WHO is calling it.

Functions like getpeername() expect you to open & bind local sockets, so
I guess those are useless.

----------------------------------------

So I guess my question is: How can a program "see" where it is getting
a TCP connection from if it's invoked by telnetd.

-- A small code example would be great.
-- Just a function-name would be just as cool.

Thank you,

        MikeE

 
 
 

Calling programs through inetd & services

Post by Barry Margol » Thu, 17 Mar 1994 07:24:18



Quote:>Anyway, I'm calling a program through inetd.conf & services etc.
>The thing is that I NEED the program I'm calling to know WHO is calling it.
>Functions like getpeername() expect you to open & bind local sockets, so
>I guess those are useless.

Inetd opens the socket for you, and provides it as fd's 0, 1, and 2.  You
can call getpeername() on these.
--
Barry Margolin
System Manager, Thinking Machines Corp.



 
 
 

Calling programs through inetd & services

Post by Michael John Ell » Thu, 17 Mar 1994 08:40:20




>>Anyway, I'm calling a program through inetd.conf & services etc.
>>The thing is that I NEED the program I'm calling to know WHO is calling it.
>>Functions like getpeername() expect you to open & bind local sockets, so
>>I guess those are useless.

>Inetd opens the socket for you, and provides it as fd's 0, 1, and 2.  You
>can call getpeername() on these.

Many thanks to all. This was not as complicated as I thought.

One last thing.... I know what fd 0 is. but what are 1 & 2?

Please post to the net, I'm sure other would be interested.

Thanks again,

        MikeE

 
 
 

Calling programs through inetd & services

Post by Barry Margol » Fri, 18 Mar 1994 13:54:08



Quote:>One last thing.... I know what fd 0 is. but what are 1 & 2?

stdout and stderr

Quote:>Please post to the net, I'm sure other would be interested.

Maybe they should get a book on Unix system programming.

--
Barry Margolin
System Manager, Thinking Machines Corp.


 
 
 

Calling programs through inetd & services

Post by Aaron Jacks » Thu, 24 Mar 1994 02:42:00


Quote:>  One last thing.... I know what fd 0 is. but what are 1 & 2?

0 = STDIN
1 = STDOUT
2 = STDERR

--

 
 
 

1. inetd/services: How to execute a program when you login to a port

OS: Solaris 2.4

I have an executable "demo". When the user telnets into a
particular port I just want this program to execute. i.e.

telnet hostname 123   (assuming 123 is our port number)

I want demo to start executing. This program will interact
with the user (i.e. user is allowed to enter text at
the program prompt). What files do I need to modify and
what needs to be modified in those files? Or do I need
to install my own telnet daemon (which I doubt) ?

Please send a copy of the response by email.

thanks

--
B.G. Mahesh                     | Corp Home Page: http://www.dalmatian.com
System Analyst                  | Pers Home Page: http://www.mahesh.com
The Dalmatian Group Inc.        | On site at http://www.teir.com

2. Tape backups and Disk management

3. execl within a inetd called program.

4. Scsh (a Unix Scheme shell) FAQ

5. Network issue, losing inetd services, ssh, & nfs mounts.

6. MTA on NetBSD

7. Are sendmail & inetd services necessary?

8. How do I change the defaultrouter without restarting ?

9. How to get calling program name in called program

10. inetd.conf & internal programs

11. How to pass envvars from calling shell to called program?

12. program calls rcmd() twice, _second_ call works for root but not normal users

13. Fvwm calling xterm calling another program