[EMAIL PROTECTED] (Marco d'Itri) writes:
> --GvXjxJ+pjyke8COw
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
>
> On Sep 10, jaalto <[EMAIL PROTECTED]> wrote:
>
>> As of 2008-09-10 the /etc/services does not define all standard ports
>> as defined by IANA.
> You must have missed the detailed explanation about this at the top of
> the file.
Done?
Yes I read this:
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.
"Only added by request" sounds like everyone should report problems
individually as they may notice it. Having automated way to keep the
file updated would be more welcomed.
The IANA is the port assignment authority, so these would be expected to
be found from standard system.
I'm attaching script to automate keeping the posrt numbers updated
easily.
Jari
#!/bin/bash
# iana-ports.sh -- Download IANA and compare entries to /etc/services
#
# Copyright (C) 2008 Jari Aalto <[EMAIL PROTECTED]>
#
# License
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with program. If not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Visit <http://www.gnu.org/copyleft/gpl.html>
#
SERVICES=/etc/services
# Positions according to Debian $SERVICES layout
# 123456789 123456
# 123456789 123456
# 123456789 123456
# www 80/tcp http # WorldWideWeb HTTP
SERVICES_FMT="%-16s%-16s%16s# %s\n"
FILE=iana-port-numbers.txt
URL=http://www.iana.org/assignments/port-numbers
shopt -s extglob
Help ()
{
echo "\
Synopsis:
iana-ports.sh [-h] [IANA-FILE-NAME-TO-SAVE]
Description:
Download IANA port number definitions, sore them to filename
given in command line (default: $FILE) and compare those to
$SERVICES. Display entries that are missing from $SERVICES"
exit ${1:-0}
}
Download ()
{
local dest=$1
rm -f $dest
wget -q -O $dest $URL
}
Parse ()
{
local file=$1
awk '/^[a-z-]+[ \t]+[0-9]+\/[a-z]+ / { print }' $file
}
Combine ()
{
iana=$1
services=$SERVICES
while read serv port rest
do
# Skip 21/sctp 9/dccp
[[ "$port" == */+(tcp|udp) ]] || continue
if ! grep -qF "$port" $services
then
printf "$SERVICES_FMT" "$serv" "$port" "" "$rest"
fi
done < $iana
}
Main ()
{
[[ "$*" == *+(-h|--help) ]] && Help
local file=${1:-$FILE}
local iana=$file.iana
Download $file
Parse $file > $iana
Combine $iana
}
Main "$@"
# End of file