Thanks a lot!
Does exactly what I need.
Cheers, Marcel
Jeremy C. Reed <[EMAIL PROTECTED]> 18 Sep 2001, at 9:55:
> On Tue, 18 Sep 2001, Marcel Hicking wrote:
>
> > I have a script invoked via inetd.
> > How can I let the script know of the IP of the client
> > connecting (remote IP)? I need to do some additional
> > security checks not possible with hosts.access|deny
> >
> > Any hints?
>
> getpeername(2) is the C library function to get the remote
> IP. This works for me:
>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> #include <stdio.h>
>
> int main (int argc, char *argv[])
>
> {
>
> struct sockaddr_in name;
> int namelen = sizeof(name);
> char *temp_domain;
>
> if (getpeername((int) 1,
> (struct sockaddr *) & name, (socklen_t *) & namelen)
> == 0) {
> if ((temp_domain = (char *) inet_ntoa(name.sin_addr)))
> printf ("%s", temp_domain);
> }
> }
>
> Then compile it with "gcc -o getpeername getpeername.c".
> Then use the getpeername executable in your script.
>
> Jeremy C. Reed
> http://www.reedmedia.net/
> http://bsd.reedmedia.net/ -- BSD news and resources
> http://www.isp-faq.com/ -- find answers to your
> questions
>
>
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact
> [EMAIL PROTECTED]
>
--
__
.´ `.
: :' ! Enjoy
`. `´ Debian/GNU Linux
`-
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]