On a Solaris 10 host there is an inetd service configured to start a bash script when it it gets an incoming TCP connection to a pre-configured port/service. Is there a way to find the IP address of the remote client in the invoked bash script?
If I was using the GNU version of inetd I would use the --environment command line flag. But I am using the default Solaris version of inetd/inetadm, which does not seem to support this flag. Is there a Solaris equivalent of this setting?
I also assume that getpeername(2) invoked on the fd of 0 (stdin) or 1 (stdout) would have returned the desired information but I am running a bash script and I don’t seem to find a way to invoke an equivalent of getpeername(2) from bash.
Is my only option to invoke a C-wrapper that would do getpeername(2), store it in an environment variable (or a command-line argument), and invoke the main bash script?
Thank you!
You can get them by parsing
pfilesoutput, something like:Edit:
Here is a lighter way in reply to Nemo’s right comment about the number of processes launched: