bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] [PATCH] Allow port numbers in inetd.conf


From: Tollef Fog Heen
Subject: Re: [bug-inetutils] [PATCH] Allow port numbers in inetd.conf
Date: Sun, 25 Apr 2004 01:10:23 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

* Jeroen Dekkers 

| At Sat, 24 Apr 2004 14:11:25 +0200,
| Robert Millan wrote:
| > I'm attaching a patch, made by Tollef Fog Heen <address@hidden>, for
| > allowing port numbers in inetd.conf.
| > 
| > 2004-04-24  Tollef Fog Heen  <address@hidden>
| > 
| >     * inetd/inetd.c: Allow use of port numbers.
| <SNIP>
| > +      port = strtol(sep->se_service, NULL, 10);
| > +      if (port > 0)
| > +       {
| > +         sp = malloc(sizeof(struct servent));
| > +         if (!sp)
| > +           {
| > +             syslog (LOG_ERR, strerror (errno));
| > +             continue;
| > +           }
| > +         asprintf(&(sp->s_name), "%d", port);
| > +         sp->s_aliases = NULL;
| > +         sp->s_port = htons(port);
| > +         sp->s_proto = strdup(sep->se_proto);
| > +        }
| 
| Why don't you use getservbyport()?

Because it only returns meaningful answers for ports which are
registered in /etc/services:

: address@hidden ~ > perl -e '($name,$aliases,$port,$proto) = 
getservbyport(1234,"tcp"); print "$port\n"'

: address@hidden ~ > perl -e '($name,$aliases,$port,$proto) = 
getservbyport(80,"tcp"); print "$port\n"'                                       
                
80

(Yes, I know that is perl, but I'm lazy and it should do the same as
the C library call. :)

-- 
Tollef Fog Heen                                                        ,''`.
UNIX is user friendly, it's just picky about who its friends are      : :' :
                                                                      `. `' 
                                                                        `-  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]