Hello community, here is the log from the commit of package net-tools for openSUSE:Factory checked in at 2018-10-02 19:39:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/net-tools (Old) and /work/SRC/openSUSE:Factory/.net-tools.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "net-tools" Tue Oct 2 19:39:08 2018 rev:54 rq:633753 version:2.0+git20180626.aebd88e Changes: -------- --- /work/SRC/openSUSE:Factory/net-tools/net-tools.changes 2018-04-02 22:47:10.330327985 +0200 +++ /work/SRC/openSUSE:Factory/.net-tools.new/net-tools.changes 2018-10-02 19:39:15.170402810 +0200 @@ -1,0 +2,9 @@ +Thu Aug 30 09:56:06 UTC 2018 - tchva...@suse.com + +- Update to version 2.0+git20180626.aebd88e: + * standardize --help/usage handling + * always write --version output to stdout +- Rebase patch: + * 0005-Add-support-for-interface-rename-in-nameif.patch + +------------------------------------------------------------------- Old: ---- net-tools-2.0+git20170221.479bb4a.tar.xz New: ---- net-tools-2.0+git20180626.aebd88e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ net-tools.spec ++++++ --- /var/tmp/diff_new_pack.Wl22pC/_old 2018-10-02 19:39:15.822401842 +0200 +++ /var/tmp/diff_new_pack.Wl22pC/_new 2018-10-02 19:39:15.822401842 +0200 @@ -17,12 +17,12 @@ Name: net-tools -Version: 2.0+git20170221.479bb4a +Version: 2.0+git20180626.aebd88e Release: 0 Summary: Important Programs for Networking License: GPL-2.0-or-later Group: Productivity/Networking/Other -Url: https://sourceforge.net/projects/net-tools/ +URL: https://sourceforge.net/projects/net-tools/ # Repacked by the service file from git Source: %{name}-%{version}.tar.xz # PATCH-FEATURE-SUSE: set configure values to our liking as we do not need @@ -49,7 +49,6 @@ ifconfig, rarp, route) are obsoleted by the tools from iproute2 package (ip, ss) and have been moved to net-tools-deprecated. - %package deprecated Summary: Deprecated Networking Utilities Group: Productivity/Networking/Other @@ -78,7 +77,7 @@ %make_install BINDIR=%{_bindir} SBINDIR=%{_sbindir} # remove rarp as it is not usefull with our kernel -rm -fv %{buildroot}/usr/*bin/rarp +rm -fv %{buildroot}%{_prefix}/*bin/rarp rm -fv %{buildroot}/%{_mandir}/man*/rarp.* rm -fv %{buildroot}/%{_mandir}/*/man*/rarp.* # Fix manpage locations @@ -101,7 +100,6 @@ %find_lang %{name} --all-name %files -%defattr(-,root,root) %license COPYING %doc README ABOUT-NLS %{_sbindir}/ether-wake @@ -112,21 +110,20 @@ /sbin/plipconfig %{_sbindir}/slattach /sbin/slattach -%{_mandir}/de/man5/ethers.5%{ext_man} -%{_mandir}/de/man8/plipconfig.8%{ext_man} -%{_mandir}/de/man8/slattach.8%{ext_man} -%{_mandir}/fr/man5/ethers.5%{ext_man} -%{_mandir}/fr/man8/plipconfig.8%{ext_man} -%{_mandir}/fr/man8/slattach.8%{ext_man} -%{_mandir}/man5/ethers.5%{ext_man} -%{_mandir}/man8/ether-wake.8%{ext_man} -%{_mandir}/man8/nameif.8%{ext_man} -%{_mandir}/man8/plipconfig.8%{ext_man} -%{_mandir}/man8/slattach.8%{ext_man} +%{_mandir}/de/man5/ethers.5%{?ext_man} +%{_mandir}/de/man8/plipconfig.8%{?ext_man} +%{_mandir}/de/man8/slattach.8%{?ext_man} +%{_mandir}/fr/man5/ethers.5%{?ext_man} +%{_mandir}/fr/man8/plipconfig.8%{?ext_man} +%{_mandir}/fr/man8/slattach.8%{?ext_man} +%{_mandir}/man5/ethers.5%{?ext_man} +%{_mandir}/man8/ether-wake.8%{?ext_man} +%{_mandir}/man8/nameif.8%{?ext_man} +%{_mandir}/man8/plipconfig.8%{?ext_man} +%{_mandir}/man8/slattach.8%{?ext_man} %files deprecated -%defattr(-,root,root) -%doc COPYING +%license COPYING %{_bindir}/netstat /bin/netstat %{_sbindir}/arp @@ -139,26 +136,25 @@ /sbin/iptunnel %{_bindir}/route /bin/route -%{_mandir}/de/man8/arp.8%{ext_man} -%{_mandir}/de/man8/ifconfig.8%{ext_man} -%{_mandir}/de/man8/netstat.8%{ext_man} -%{_mandir}/de/man8/route.8%{ext_man} -%{_mandir}/fr/man8/arp.8%{ext_man} -%{_mandir}/fr/man8/ifconfig.8%{ext_man} -%{_mandir}/fr/man8/netstat.8%{ext_man} -%{_mandir}/fr/man8/route.8%{ext_man} -%{_mandir}/man8/arp.8%{ext_man} -%{_mandir}/man8/ifconfig.8%{ext_man} -%{_mandir}/man8/netstat.8%{ext_man} -%{_mandir}/man8/route.8%{ext_man} -%{_mandir}/man8/ipmaddr.8%{ext_man} -%{_mandir}/man8/iptunnel.8%{ext_man} -%{_mandir}/pt_BR/man8/arp.8%{ext_man} -%{_mandir}/pt_BR/man8/ifconfig.8%{ext_man} -%{_mandir}/pt_BR/man8/netstat.8%{ext_man} -%{_mandir}/pt_BR/man8/route.8%{ext_man} +%{_mandir}/de/man8/arp.8%{?ext_man} +%{_mandir}/de/man8/ifconfig.8%{?ext_man} +%{_mandir}/de/man8/netstat.8%{?ext_man} +%{_mandir}/de/man8/route.8%{?ext_man} +%{_mandir}/fr/man8/arp.8%{?ext_man} +%{_mandir}/fr/man8/ifconfig.8%{?ext_man} +%{_mandir}/fr/man8/netstat.8%{?ext_man} +%{_mandir}/fr/man8/route.8%{?ext_man} +%{_mandir}/man8/arp.8%{?ext_man} +%{_mandir}/man8/ifconfig.8%{?ext_man} +%{_mandir}/man8/netstat.8%{?ext_man} +%{_mandir}/man8/route.8%{?ext_man} +%{_mandir}/man8/ipmaddr.8%{?ext_man} +%{_mandir}/man8/iptunnel.8%{?ext_man} +%{_mandir}/pt_BR/man8/arp.8%{?ext_man} +%{_mandir}/pt_BR/man8/ifconfig.8%{?ext_man} +%{_mandir}/pt_BR/man8/netstat.8%{?ext_man} +%{_mandir}/pt_BR/man8/route.8%{?ext_man} %files lang -f %{name}.lang -%defattr(-,root,root) %changelog ++++++ 0005-Add-support-for-interface-rename-in-nameif.patch ++++++ --- /var/tmp/diff_new_pack.Wl22pC/_old 2018-10-02 19:39:15.838401819 +0200 +++ /var/tmp/diff_new_pack.Wl22pC/_new 2018-10-02 19:39:15.842401812 +0200 @@ -8,11 +8,11 @@ nameif.c | 61 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 70 insertions(+), 34 deletions(-) -diff --git a/man/en_US/nameif.8 b/man/en_US/nameif.8 -index 195304d..ccea694 100644 ---- a/man/en_US/nameif.8 -+++ b/man/en_US/nameif.8 -@@ -4,26 +4,37 @@ nameif \- name network interfaces based on MAC addresses +Index: net-tools-2.0+git20180626.aebd88e/man/en_US/nameif.8 +=================================================================== +--- net-tools-2.0+git20180626.aebd88e.orig/man/en_US/nameif.8 ++++ net-tools-2.0+git20180626.aebd88e/man/en_US/nameif.8 +@@ -4,26 +4,37 @@ nameif \- name network interfaces based .SH SYNOPSIS .B "nameif [\-c configfile] [\-s]" .br @@ -66,10 +66,10 @@ .SH NOTES .I nameif -diff --git a/nameif.c b/nameif.c -index b280e59..bdc1dfa 100644 ---- a/nameif.c -+++ b/nameif.c +Index: net-tools-2.0+git20180626.aebd88e/nameif.c +=================================================================== +--- net-tools-2.0+git20180626.aebd88e.orig/nameif.c ++++ net-tools-2.0+git20180626.aebd88e/nameif.c @@ -28,6 +28,7 @@ const char default_conf[] = "/etc/mactab"; const char *fname = default_conf; @@ -78,7 +78,7 @@ int ctl_sk = -1; void err(char *msg) -@@ -114,7 +115,8 @@ int getmac(char *name, unsigned char *mac) +@@ -114,7 +115,8 @@ int getmac(char *name, unsigned char *ma struct change { struct change *next; int found; @@ -88,7 +88,7 @@ unsigned char mac[6]; }; struct change *clist; -@@ -128,13 +130,28 @@ struct change *lookupmac(unsigned char *mac) +@@ -128,13 +130,28 @@ struct change *lookupmac(unsigned char * return NULL; } @@ -139,27 +139,27 @@ {"syslog", 0, NULL, 's' }, + {"rename", 0, NULL, 'r' }, {"config-file", 1, NULL, 'c' }, - {"help", 0, NULL, '?' }, + {"help", 0, NULL, 'h' }, {NULL}, -@@ -194,7 +212,7 @@ struct option lopt[] = { - - void usage(void) +@@ -195,7 +213,7 @@ struct option lopt[] = { + static void usage(int rc) { -- fprintf(stderr, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n")); -+ fprintf(stderr, _("usage: nameif [-c configurationfile] [-s] [-r] {ifname macaddress|oldifname}\n")); + FILE *fp = rc ? stderr : stdout; +- fprintf(fp, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n")); ++ fprintf(fp, _("usage: nameif [-c configurationfile] [-s] [-r] {ifname macaddress}\n")); exit(E_USAGE); } -@@ -209,7 +227,7 @@ int main(int ac, char **av) +@@ -210,7 +228,7 @@ int main(int ac, char **av) int ret = 0; for (;;) { -- int c = getopt_long(ac,av,"c:s",lopt,NULL); -+ int c = getopt_long(ac,av,"c:sr",lopt,NULL); +- int c = getopt_long(ac,av,"c:sh",lopt,NULL); ++ int c = getopt_long(ac,av,"c:srh",lopt,NULL); if (c == -1) break; switch (c) { default: -@@ -221,6 +239,9 @@ int main(int ac, char **av) +@@ -223,6 +241,9 @@ int main(int ac, char **av) case 's': use_syslog = 1; break; @@ -169,8 +169,8 @@ } } -@@ -235,7 +256,7 @@ int main(int ac, char **av) - usage(); +@@ -237,7 +258,7 @@ int main(int ac, char **av) + usage(E_OPTERR); if (strlen(av[optind])+1>IFNAMSIZ) complain(_("interface name `%s' too long"), av[optind]); - safe_strncpy(ch->ifname, av[optind], sizeof(ch->ifname)); @@ -178,7 +178,7 @@ optind++; sprintf(pos,_("argument %d"),optind); addchange(av[optind], ch, pos); -@@ -266,18 +287,22 @@ int main(int ac, char **av) +@@ -268,18 +289,22 @@ int main(int ac, char **av) if (n > IFNAMSIZ-1) complain(_("interface name `%s' too long"), p); @@ -207,7 +207,7 @@ } } fclose(ifh); -@@ -286,7 +311,7 @@ int main(int ac, char **av) +@@ -288,7 +313,7 @@ int main(int ac, char **av) struct change *ch = clist; clist = clist->next; if (!ch->found){ @@ -216,6 +216,3 @@ ret = 1; } free(ch); --- -2.13.1 - ++++++ net-tools-2.0+git20170221.479bb4a.tar.xz -> net-tools-2.0+git20180626.aebd88e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/arp.c new/net-tools-2.0+git20180626.aebd88e/arp.c --- old/net-tools-2.0+git20170221.479bb4a/arp.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/arp.c 2018-06-26 09:30:13.000000000 +0200 @@ -93,7 +93,7 @@ int sockfd = 0; /* active socket descriptor */ int hw_set = 0; /* flag if hw-type was set (-H) */ char device[16] = ""; /* current device */ -static void usage(void); +static void usage(int); /* Delete an entry from the ARP cache. */ static int arp_del(char **args) @@ -168,14 +168,14 @@ } if (!strcmp(*args, "dev")) { if (*++args == NULL) - usage(); + usage(E_OPTERR); safe_strncpy(device, *args, sizeof(device)); args++; continue; } if (!strcmp(*args, "netmask")) { if (*++args == NULL) - usage(); + usage(E_OPTERR); if (strcmp(*args, "255.255.255.255") != 0) { safe_strncpy(host, *args, (sizeof host)); if (ap->input(0, host, &ss) < 0) { @@ -189,7 +189,7 @@ args++; continue; } - usage(); + usage(E_OPTERR); } // if neighter priv nor pub is given, work on both @@ -345,14 +345,14 @@ } if (!strcmp(*args, "dev")) { if (*++args == NULL) - usage(); + usage(E_OPTERR); safe_strncpy(device, *args, sizeof(device)); args++; continue; } if (!strcmp(*args, "netmask")) { if (*++args == NULL) - usage(); + usage(E_OPTERR); if (strcmp(*args, "255.255.255.255") != 0) { safe_strncpy(host, *args, (sizeof host)); if (ap->input(0, host, &ss) < 0) { @@ -366,7 +366,7 @@ args++; continue; } - usage(); + usage(E_OPTERR); } /* Fill in the remainder of the request. */ @@ -623,33 +623,34 @@ static void version(void) { - fprintf(stderr, "%s\n%s\n", Release, Features); + printf("%s\n%s\n", Release, Features); exit(E_VERSION); } -static void usage(void) +static void usage(int rc) { - fprintf(stderr, _("Usage:\n arp [-vn] [<HW>] [-i <if>] [-a] [<hostname>] <-Display ARP cache\n")); - fprintf(stderr, _(" arp [-v] [-i <if>] -d <host> [pub] <-Delete ARP entry\n")); - fprintf(stderr, _(" arp [-vnD] [<HW>] [-i <if>] -f [<filename>] <-Add entry from file\n")); - fprintf(stderr, _(" arp [-v] [<HW>] [-i <if>] -s <host> <hwaddr> [temp] <-Add entry\n")); - fprintf(stderr, _(" arp [-v] [<HW>] [-i <if>] -Ds <host> <if> [netmask <nm>] pub <-''-\n\n")); - - fprintf(stderr, _(" -a display (all) hosts in alternative (BSD) style\n")); - fprintf(stderr, _(" -e display (all) hosts in default (Linux) style\n")); - fprintf(stderr, _(" -s, --set set a new ARP entry\n")); - fprintf(stderr, _(" -d, --delete delete a specified entry\n")); - fprintf(stderr, _(" -v, --verbose be verbose\n")); - fprintf(stderr, _(" -n, --numeric don't resolve names\n")); - fprintf(stderr, _(" -i, --device specify network interface (e.g. eth0)\n")); - fprintf(stderr, _(" -D, --use-device read <hwaddr> from given device\n")); - fprintf(stderr, _(" -A, -p, --protocol specify protocol family\n")); - fprintf(stderr, _(" -f, --file read new entries from file or from /etc/ethers\n\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage:\n arp [-vn] [<HW>] [-i <if>] [-a] [<hostname>] <-Display ARP cache\n")); + fprintf(fp, _(" arp [-v] [-i <if>] -d <host> [pub] <-Delete ARP entry\n")); + fprintf(fp, _(" arp [-vnD] [<HW>] [-i <if>] -f [<filename>] <-Add entry from file\n")); + fprintf(fp, _(" arp [-v] [<HW>] [-i <if>] -s <host> <hwaddr> [temp] <-Add entry\n")); + fprintf(fp, _(" arp [-v] [<HW>] [-i <if>] -Ds <host> <if> [netmask <nm>] pub <-''-\n\n")); + + fprintf(fp, _(" -a display (all) hosts in alternative (BSD) style\n")); + fprintf(fp, _(" -e display (all) hosts in default (Linux) style\n")); + fprintf(fp, _(" -s, --set set a new ARP entry\n")); + fprintf(fp, _(" -d, --delete delete a specified entry\n")); + fprintf(fp, _(" -v, --verbose be verbose\n")); + fprintf(fp, _(" -n, --numeric don't resolve names\n")); + fprintf(fp, _(" -i, --device specify network interface (e.g. eth0)\n")); + fprintf(fp, _(" -D, --use-device read <hwaddr> from given device\n")); + fprintf(fp, _(" -A, -p, --protocol specify protocol family\n")); + fprintf(fp, _(" -f, --file read new entries from file or from /etc/ethers\n\n")); - fprintf(stderr, _(" <HW>=Use '-H <hw>' to specify hardware address type. Default: %s\n"), DFLT_HW); - fprintf(stderr, _(" List of possible hardware types (which support ARP):\n")); + fprintf(fp, _(" <HW>=Use '-H <hw>' to specify hardware address type. Default: %s\n"), DFLT_HW); + fprintf(fp, _(" List of possible hardware types (which support ARP):\n")); print_hwlist(1); /* 1 = ARPable */ - exit(E_USAGE); + exit(rc); } int main(int argc, char **argv) @@ -751,10 +752,11 @@ case 'V': version(); - case '?': case 'h': + usage(E_USAGE); + case '?': default: - usage(); + usage(E_OPTERR); } if (ap->af != AF_INET) { @@ -803,7 +805,7 @@ break; default: - usage(); + usage(E_OPTERR); } exit(what); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/hostname.c new/net-tools-2.0+git20180626.aebd88e/hostname.c --- old/net-tools-2.0+git20170221.479bb4a/hostname.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/hostname.c 2018-06-26 09:30:13.000000000 +0200 @@ -63,7 +63,6 @@ static void sethname(char *); static void setdname(char *); static void showhname(char *, int); -static void usage(void); static void version(void); static void setfilename(char *, int); @@ -254,39 +253,40 @@ static void version(void) { - fprintf(stderr, "%s\n", Release); + printf("%s\n", Release); exit(E_VERSION); } -static void usage(void) +static void usage(int rc) { - fprintf(stderr, _("Usage: hostname [-v] {hostname|-F file} set hostname (from file)\n")); - fprintf(stderr, _(" domainname [-v] {nisdomain|-F file} set NIS domainname (from file)\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: hostname [-v] {hostname|-F file} set hostname (from file)\n")); + fprintf(fp, _(" domainname [-v] {nisdomain|-F file} set NIS domainname (from file)\n")); #if HAVE_AFDECnet - fprintf(stderr, _(" nodename [-v] {nodename|-F file} set DECnet node name (from file)\n")); + fprintf(fp, _(" nodename [-v] {nodename|-F file} set DECnet node name (from file)\n")); #endif - fprintf(stderr, _(" hostname [-v] [-d|-f|-s|-a|-i|-y|-n] display formatted name\n")); - fprintf(stderr, _(" hostname [-v] display hostname\n\n")); - fprintf(stderr, _(" hostname -V|--version|-h|--help print info and exit\n\n")); - fprintf(stderr, _(" dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y\n\n")); - fprintf(stderr, _(" -s, --short short host name\n")); - fprintf(stderr, _(" -a, --alias alias names\n")); - fprintf(stderr, _(" -i, --ip-address addresses for the hostname\n")); - fprintf(stderr, _(" -f, --fqdn, --long long host name (FQDN)\n")); - fprintf(stderr, _(" -d, --domain DNS domain name\n")); - fprintf(stderr, _(" -y, --yp, --nis NIS/YP domainname\n")); + fprintf(fp, _(" hostname [-v] [-d|-f|-s|-a|-i|-y|-n] display formatted name\n")); + fprintf(fp, _(" hostname [-v] display hostname\n\n")); + fprintf(fp, _(" hostname -V|--version|-h|--help print info and exit\n\n")); + fprintf(fp, _(" dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y\n\n")); + fprintf(fp, _(" -s, --short short host name\n")); + fprintf(fp, _(" -a, --alias alias names\n")); + fprintf(fp, _(" -i, --ip-address addresses for the hostname\n")); + fprintf(fp, _(" -f, --fqdn, --long long host name (FQDN)\n")); + fprintf(fp, _(" -d, --domain DNS domain name\n")); + fprintf(fp, _(" -y, --yp, --nis NIS/YP domainname\n")); #if HAVE_AFDECnet - fprintf(stderr, _(" -n, --node DECnet node name\n")); + fprintf(fp, _(" -n, --node DECnet node name\n")); #endif /* HAVE_AFDECnet */ - fprintf(stderr, _(" -F, --file read hostname or NIS domainname from given file\n\n")); - fprintf(stderr, _( + fprintf(fp, _(" -F, --file read hostname or NIS domainname from given file\n\n")); + fprintf(fp, _( " This command can read or set the hostname or the NIS domainname. You can\n" " also read the DNS domain or the FQDN (fully qualified domain name).\n" " Unless you are using bind or NIS for host lookups you can change the\n" " FQDN (Fully Qualified Domain Name) and the DNS domain name (which is\n" " part of the FQDN) in the /etc/hosts file.\n")); - exit(E_USAGE); + exit(rc); } @@ -366,10 +366,12 @@ case 'V': version(); break; // not reached - case '?': case 'h': + usage(E_USAGE); + break; // not reached + case '?': default: - usage(); + usage(E_OPTERR); break; // not reached }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/ifconfig.c new/net-tools-2.0+git20180626.aebd88e/ifconfig.c --- old/net-tools-2.0+git20170221.479bb4a/ifconfig.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/ifconfig.c 2018-06-26 09:30:13.000000000 +0200 @@ -198,42 +198,43 @@ return (ifr.ifr_flags & flags); } -static void usage(void) +static void usage(int rc) { - fprintf(stderr, _("Usage:\n ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage:\n ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]\n")); #if HAVE_AFINET - fprintf(stderr, _(" [add <address>[/<prefixlen>]]\n")); - fprintf(stderr, _(" [del <address>[/<prefixlen>]]\n")); - fprintf(stderr, _(" [[-]broadcast [<address>]] [[-]pointopoint [<address>]]\n")); - fprintf(stderr, _(" [netmask <address>] [dstaddr <address>] [tunnel <address>]\n")); + fprintf(fp, _(" [add <address>[/<prefixlen>]]\n")); + fprintf(fp, _(" [del <address>[/<prefixlen>]]\n")); + fprintf(fp, _(" [[-]broadcast [<address>]] [[-]pointopoint [<address>]]\n")); + fprintf(fp, _(" [netmask <address>] [dstaddr <address>] [tunnel <address>]\n")); #endif #ifdef SIOCSKEEPALIVE - fprintf(stderr, _(" [outfill <NN>] [keepalive <NN>]\n")); + fprintf(fp, _(" [outfill <NN>] [keepalive <NN>]\n")); #endif - fprintf(stderr, _(" [hw <HW> <address>] [mtu <NN>]\n")); - fprintf(stderr, _(" [[-]trailers] [[-]arp] [[-]allmulti]\n")); - fprintf(stderr, _(" [multicast] [[-]promisc]\n")); - fprintf(stderr, _(" [mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]\n")); + fprintf(fp, _(" [hw <HW> <address>] [mtu <NN>]\n")); + fprintf(fp, _(" [[-]trailers] [[-]arp] [[-]allmulti]\n")); + fprintf(fp, _(" [multicast] [[-]promisc]\n")); + fprintf(fp, _(" [mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]\n")); #ifdef HAVE_TXQUEUELEN - fprintf(stderr, _(" [txqueuelen <NN>]\n")); + fprintf(fp, _(" [txqueuelen <NN>]\n")); #endif #ifdef HAVE_DYNAMIC - fprintf(stderr, _(" [[-]dynamic]\n")); + fprintf(fp, _(" [[-]dynamic]\n")); #endif - fprintf(stderr, _(" [up|down] ...\n\n")); + fprintf(fp, _(" [up|down] ...\n\n")); - fprintf(stderr, _(" <HW>=Hardware Type.\n")); - fprintf(stderr, _(" List of possible hardware types:\n")); + fprintf(fp, _(" <HW>=Hardware Type.\n")); + fprintf(fp, _(" List of possible hardware types:\n")); print_hwlist(0); /* 1 = ARPable */ - fprintf(stderr, _(" <AF>=Address family. Default: %s\n"), DFLT_AF); - fprintf(stderr, _(" List of possible address families:\n")); + fprintf(fp, _(" <AF>=Address family. Default: %s\n"), DFLT_AF); + fprintf(fp, _(" List of possible address families:\n")); print_aflist(0); /* 1 = routeable */ - exit(E_USAGE); + exit(rc); } static void version(void) { - fprintf(stderr, "%s\n", Release); + printf("%s\n", Release); exit(E_VERSION); } @@ -299,7 +300,7 @@ else if (!strcmp(*argv, "-?") || !strcmp(*argv, "-h") || !strcmp(*argv, "-help") || !strcmp(*argv, "--help")) - usage(); + usage(E_USAGE); else { fprintf(stderr, _("ifconfig: option `%s' not recognised.\n"), @@ -359,7 +360,7 @@ #ifdef IFF_PORTSEL if (!strcmp(*spp, "media") || !strcmp(*spp, "port")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if (!strcasecmp(*spp, "auto")) { goterr |= set_flag(ifr.ifr_name, IFF_AUTOMEDIA); } else { @@ -471,7 +472,7 @@ if (!strcmp(*spp, "mtu")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); ifr.ifr_mtu = atoi(*spp); if (ioctl(skfd, SIOCSIFMTU, &ifr) < 0) { fprintf(stderr, "SIOCSIFMTU: %s\n", strerror(errno)); @@ -483,7 +484,7 @@ #ifdef SIOCSKEEPALIVE if (!strcmp(*spp, "keepalive")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp); if (ioctl(skfd, SIOCSKEEPALIVE, &ifr) < 0) { fprintf(stderr, "SIOCSKEEPALIVE: %s\n", strerror(errno)); @@ -497,7 +498,7 @@ #ifdef SIOCSOUTFILL if (!strcmp(*spp, "outfill")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp); if (ioctl(skfd, SIOCSOUTFILL, &ifr) < 0) { fprintf(stderr, "SIOCSOUTFILL: %s\n", strerror(errno)); @@ -540,7 +541,7 @@ } if (!strcmp(*spp, "dstaddr")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); safe_strncpy(host, *spp, (sizeof host)); if (ap->input(0, host, &_sa) < 0) { if (ap->herror) @@ -562,7 +563,7 @@ } if (!strcmp(*spp, "netmask")) { if (*++spp == NULL || didnetmask) - usage(); + usage(E_OPTERR); safe_strncpy(host, *spp, (sizeof host)); if (ap->input(0, host, &_sa) < 0) { if (ap->herror) @@ -581,7 +582,7 @@ #ifdef HAVE_TXQUEUELEN if (!strcmp(*spp, "txqueuelen")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); ifr.ifr_qlen = strtoul(*spp, NULL, 0); if (ioctl(skfd, SIOCSIFTXQLEN, &ifr) < 0) { fprintf(stderr, "SIOCSIFTXQLEN: %s\n", strerror(errno)); @@ -594,7 +595,7 @@ if (!strcmp(*spp, "mem_start")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) { fprintf(stderr, "mem_start: SIOCGIFMAP: %s\n", strerror(errno)); spp++; @@ -611,7 +612,7 @@ } if (!strcmp(*spp, "io_addr")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) { fprintf(stderr, "io_addr: SIOCGIFMAP: %s\n", strerror(errno)); spp++; @@ -628,7 +629,7 @@ } if (!strcmp(*spp, "irq")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) { fprintf(stderr, "irq: SIOCGIFMAP: %s\n", strerror(errno)); goterr = 1; @@ -677,9 +678,9 @@ if (!strcmp(*spp, "hw")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if ((hw = get_hwtype(*spp)) == NULL) - usage(); + usage(E_OPTERR); if (hw->input == NULL) { fprintf(stderr, _("hw address type `%s' has no handler to set address. failed.\n"), *spp); spp+=2; @@ -687,7 +688,7 @@ continue; } if (*++spp == NULL) - usage(); + usage(E_OPTERR); safe_strncpy(host, *spp, (sizeof host)); if (hw->input(host, &_sa) < 0) { fprintf(stderr, _("%s: invalid %s address.\n"), host, hw->name); @@ -711,14 +712,14 @@ #if HAVE_AFINET || HAVE_AFINET6 if (!strcmp(*spp, "add")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); #if HAVE_AFINET6 if (strchr(*spp, ':')) { /* INET6 */ if ((cp = strchr(*spp, '/'))) { prefix_len = atol(cp + 1); if ((prefix_len < 0) || (prefix_len > 128)) - usage(); + usage(E_OPTERR); *cp = 0; } else { prefix_len = 128; @@ -801,7 +802,7 @@ #if HAVE_AFINET || HAVE_AFINET6 if (!strcmp(*spp, "del")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); #ifdef SIOCDIFADDR #if HAVE_AFINET6 @@ -809,7 +810,7 @@ if ((cp = strchr(*spp, '/'))) { prefix_len = atol(cp + 1); if ((prefix_len < 0) || (prefix_len > 128)) - usage(); + usage(E_OPTERR); *cp = 0; } else { prefix_len = 128; @@ -896,11 +897,11 @@ #if HAVE_AFINET6 if (!strcmp(*spp, "tunnel")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); if ((cp = strchr(*spp, '/'))) { prefix_len = atol(cp + 1); if ((prefix_len < 0) || (prefix_len > 128)) - usage(); + usage(E_OPTERR); *cp = 0; } else { prefix_len = 128; @@ -948,11 +949,11 @@ if (ap->getmask) { switch (ap->getmask(host, &_samask, NULL)) { case -1: - usage(); + usage(E_OPTERR); break; case 1: if (didnetmask) - usage(); + usage(E_OPTERR); // remeber to set the netmask from samask later neednetmask = 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/include/util-ank.h new/net-tools-2.0+git20180626.aebd88e/include/util-ank.h --- old/net-tools-2.0+git20170221.479bb4a/include/util-ank.h 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/include/util-ank.h 2018-06-26 09:30:13.000000000 +0200 @@ -23,7 +23,7 @@ #define NEXT_ARG() \ argv++; \ if (--argc <= 0) \ - usage(); + usage(E_OPTERR); typedef struct { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/ipmaddr.c new/net-tools-2.0+git20180626.aebd88e/ipmaddr.c --- old/net-tools-2.0+git20170221.479bb4a/ipmaddr.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/ipmaddr.c 2018-06-26 09:30:13.000000000 +0200 @@ -49,14 +49,14 @@ exit(E_VERSION); } -static void usage(void) __attribute__((noreturn)); - -static void usage(void) +__attribute__((noreturn)) +static void usage(int rc) { - fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n")); - fprintf(stderr, _(" ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n")); - fprintf(stderr, _(" ipmaddr -V | -version\n")); - exit(E_USAGE); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n")); + fprintf(fp, _(" ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n")); + fprintf(fp, _(" ipmaddr -V | -version\n")); + exit(rc); } static void print_lla(FILE *fp, int len, unsigned char *addr) @@ -290,7 +290,7 @@ NEXT_ARG(); l = strlen(*argv); if (l <= 0 || l >= sizeof(filter_dev)) - usage(); + usage(E_OPTERR); strncpy(filter_dev, *argv, sizeof (filter_dev)); } else if (strcmp(*argv, "all") == 0) { filter_family = AF_UNSPEC; @@ -303,7 +303,7 @@ } else { l = strlen(*argv); if (l <= 0 || l >= sizeof(filter_dev)) - usage(); + usage(E_OPTERR); strncpy(filter_dev, *argv, sizeof (filter_dev)); } argv++; argc--; @@ -335,18 +335,18 @@ if (strcmp(*argv, "dev") == 0) { NEXT_ARG(); if (ifr.ifr_name[0]) - usage(); + usage(E_OPTERR); strncpy(ifr.ifr_name, *argv, IFNAMSIZ); } else { if (ifr.ifr_hwaddr.sa_data[0]) - usage(); + usage(E_OPTERR); if (parse_lla(*argv, ifr.ifr_hwaddr.sa_data) < 0) - usage(); + usage(E_OPTERR); } argc--; argv++; } if (ifr.ifr_name[0] == 0) - usage(); + usage(E_OPTERR); fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { @@ -374,7 +374,7 @@ if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 || matches(*argv, "lst") == 0) return multiaddr_list(argc-1, argv+1); - usage(); + usage(E_OPTERR); } int preferred_family = AF_UNSPEC; @@ -404,13 +404,13 @@ argc--; argv++; if (argc <= 1) - usage(); + usage(E_OPTERR); if (strcmp(argv[1], "inet") == 0) preferred_family = AF_INET; else if (strcmp(argv[1], "inet6") == 0) preferred_family = AF_INET6; else - usage(); + usage(E_OPTERR); } else if (matches(argv[1], "-stats") == 0 || matches(argv[1], "-statistics") == 0) { ++show_stats; @@ -418,8 +418,10 @@ ++resolve_hosts; } else if ((matches(argv[1], "-V") == 0) || matches(argv[1], "--version") == 0) { version(); + } else if ((matches(argv[1], "-h") == 0) || matches(argv[1], "--help") == 0) { + usage(E_USAGE); } else - usage(); + usage(E_OPTERR); argc--; argv++; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/iptunnel.c new/net-tools-2.0+git20180626.aebd88e/iptunnel.c --- old/net-tools-2.0+git20170221.479bb4a/iptunnel.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/iptunnel.c 2018-06-26 09:30:13.000000000 +0200 @@ -75,21 +75,21 @@ exit(E_VERSION); } -static void usage(void) __attribute__((noreturn)); - -static void usage(void) +__attribute__((noreturn)) +static void usage(int rc) { - fprintf(stderr, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n")); - fprintf(stderr, _(" [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n")); - fprintf(stderr, _(" [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n")); - fprintf(stderr, _(" [ ttl TTL ] [ tos TOS ] [ nopmtudisc ] [ dev PHYS_DEV ]\n")); - fprintf(stderr, _(" iptunnel -V | --version\n\n")); - fprintf(stderr, _("Where: NAME := STRING\n")); - fprintf(stderr, _(" ADDR := { IP_ADDRESS | any }\n")); - fprintf(stderr, _(" TOS := { NUMBER | inherit }\n")); - fprintf(stderr, _(" TTL := { 1..255 | inherit }\n")); - fprintf(stderr, _(" KEY := { DOTTED_QUAD | NUMBER }\n")); - exit(E_USAGE); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n")); + fprintf(fp, _(" [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n")); + fprintf(fp, _(" [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n")); + fprintf(fp, _(" [ ttl TTL ] [ tos TOS ] [ nopmtudisc ] [ dev PHYS_DEV ]\n")); + fprintf(fp, _(" iptunnel -V | --version\n\n")); + fprintf(fp, _("Where: NAME := STRING\n")); + fprintf(fp, _(" ADDR := { IP_ADDRESS | any }\n")); + fprintf(fp, _(" TOS := { NUMBER | inherit }\n")); + fprintf(fp, _(" TTL := { 1..255 | inherit }\n")); + fprintf(fp, _(" KEY := { DOTTED_QUAD | NUMBER }\n")); + exit(rc); } static int do_ioctl_get_ifindex(char *dev) @@ -216,18 +216,18 @@ NEXT_ARG(); if (strcmp(*argv, "ipip") == 0) { if (p->iph.protocol) - usage(); + usage(E_OPTERR); p->iph.protocol = IPPROTO_IPIP; } else if (strcmp(*argv, "gre") == 0) { if (p->iph.protocol) - usage(); + usage(E_OPTERR); p->iph.protocol = IPPROTO_GRE; } else if (strcmp(*argv, "sit") == 0) { if (p->iph.protocol) - usage(); + usage(E_OPTERR); p->iph.protocol = IPPROTO_IPV6; } else - usage(); + usage(E_OPTERR); } else if (strcmp(*argv, "key") == 0) { unsigned uval; NEXT_ARG(); @@ -237,7 +237,7 @@ p->i_key = p->o_key = get_addr32(*argv); else { if (scan_number(*argv, &uval)<0) - usage(); + usage(E_OPTERR); p->i_key = p->o_key = htonl(uval); } } else if (strcmp(*argv, "ikey") == 0) { @@ -248,7 +248,7 @@ p->o_key = get_addr32(*argv); else { if (scan_number(*argv, &uval)<0) - usage(); + usage(E_OPTERR); p->i_key = htonl(uval); } } else if (strcmp(*argv, "okey") == 0) { @@ -259,7 +259,7 @@ p->o_key = get_addr32(*argv); else { if (scan_number(*argv, &uval)<0) - usage(); + usage(E_OPTERR); p->o_key = htonl(uval); } } else if (strcmp(*argv, "seq") == 0) { @@ -294,9 +294,9 @@ NEXT_ARG(); if (strcmp(*argv, "inherit") != 0) { if (scan_number(*argv, &uval)<0) - usage(); + usage(E_OPTERR); if (uval > 255) - usage(); + usage(E_OPTERR); p->iph.ttl = uval; } } else if (strcmp(*argv, "tos") == 0) { @@ -304,15 +304,15 @@ NEXT_ARG(); if (strcmp(*argv, "inherit") != 0) { if (scan_number(*argv, &uval)<0) - usage(); + usage(E_OPTERR); if (uval > 255) - usage(); + usage(E_OPTERR); p->iph.tos = uval; } else p->iph.tos = 1; } else { if (p->name[0]) - usage(); + usage(E_OPTERR); safe_strncpy(p->name, *argv, IFNAMSIZ); } argc--; argv++; @@ -573,7 +573,7 @@ } else return do_show(0, NULL); - usage(); + usage(E_OPTERR); } @@ -604,13 +604,13 @@ argc--; argv++; if (argc <= 1) - usage(); + usage(E_OPTERR); if (strcmp(argv[1], "inet") == 0) preferred_family = AF_INET; else if (strcmp(argv[1], "inet6") == 0) preferred_family = AF_INET6; else - usage(); + usage(E_OPTERR); } else if (matches(argv[1], "-stats") == 0 || matches(argv[1], "-statistics") == 0) { ++show_stats; @@ -618,8 +618,10 @@ ++resolve_hosts; } else if ((matches(argv[1], "-V") == 0) || (matches(argv[1], "--version") == 0)) { version(); + } else if ((matches(argv[1], "-h") == 0) || (matches(argv[1], "--help") == 0)) { + usage(E_USAGE); } else - usage(); + usage(E_OPTERR); argc--; argv++; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/lib/inet6_sr.c new/net-tools-2.0+git20180626.aebd88e/lib/inet6_sr.c --- old/net-tools-2.0+git20170221.479bb4a/lib/inet6_sr.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/lib/inet6_sr.c 2018-06-26 09:30:13.000000000 +0200 @@ -44,9 +44,10 @@ static int usage(const int rc) { - fprintf(stderr, _("Usage: inet6_route [-vF] del Target\n")); - fprintf(stderr, _(" inet6_route [-vF] add Target [gw Gw] [metric M] [[dev] If]\n")); - fprintf(stderr, _(" inet6_route [-FC] flush NOT supported\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: inet6_route [-vF] del Target\n")); + fprintf(fp, _(" inet6_route [-vF] add Target [gw Gw] [metric M] [[dev] If]\n")); + fprintf(fp, _(" inet6_route [-FC] flush NOT supported\n")); return (rc); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/lib/inet_sr.c new/net-tools-2.0+git20180626.aebd88e/lib/inet_sr.c --- old/net-tools-2.0+git20170221.479bb4a/lib/inet_sr.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/lib/inet_sr.c 2018-06-26 09:30:13.000000000 +0200 @@ -50,12 +50,13 @@ static int usage(const int rc) { - fprintf(stderr, _("Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]\n")); - fprintf(stderr, _(" inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]\n")); - fprintf(stderr, _(" [netmask N] [mss Mss] [window W] [irtt I]\n")); - fprintf(stderr, _(" [mod] [dyn] [reinstate] [[dev] If]\n")); - fprintf(stderr, _(" inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject\n")); - fprintf(stderr, _(" inet_route [-FC] flush NOT supported\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]\n")); + fprintf(fp, _(" inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]\n")); + fprintf(fp, _(" [netmask N] [mss Mss] [window W] [irtt I]\n")); + fprintf(fp, _(" [mod] [dyn] [reinstate] [[dev] If]\n")); + fprintf(fp, _(" inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject\n")); + fprintf(fp, _(" inet_route [-FC] flush NOT supported\n")); return (rc); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/lib/x25_sr.c new/net-tools-2.0+git20180626.aebd88e/lib/x25_sr.c --- old/net-tools-2.0+git20170221.479bb4a/lib/x25_sr.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/lib/x25_sr.c 2018-06-26 09:30:13.000000000 +0200 @@ -47,8 +47,9 @@ static int usage(const int rc) { - fprintf(stderr,"Usage: x25_route [-v] del Target[/mask] [dev] If\n"); - fprintf(stderr," x25_route [-v] add Target[/mask] [dev] If\n"); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, "Usage: x25_route [-v] del Target[/mask] [dev] If\n"); + fprintf(fp, " x25_route [-v] add Target[/mask] [dev] If\n"); return(rc); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/mii-tool.c new/net-tools-2.0+git20180626.aebd88e/mii-tool.c --- old/net-tools-2.0+git20170221.479bb4a/mii-tool.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/mii-tool.c 2018-06-26 09:30:13.000000000 +0200 @@ -469,7 +469,7 @@ static void version(void) { - fprintf(stderr, "%s\n%s\n", Release, Signature); + printf("%s\n%s\n", Release, Signature); exit(E_VERSION); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/nameif.c new/net-tools-2.0+git20180626.aebd88e/nameif.c --- old/net-tools-2.0+git20170221.479bb4a/nameif.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/nameif.c 2018-06-26 09:30:13.000000000 +0200 @@ -188,13 +188,14 @@ struct option lopt[] = { {"syslog", 0, NULL, 's' }, {"config-file", 1, NULL, 'c' }, - {"help", 0, NULL, '?' }, + {"help", 0, NULL, 'h' }, {NULL}, }; -void usage(void) +static void usage(int rc) { - fprintf(stderr, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n")); exit(E_USAGE); } @@ -209,12 +210,13 @@ int ret = 0; for (;;) { - int c = getopt_long(ac,av,"c:s",lopt,NULL); + int c = getopt_long(ac,av,"c:sh",lopt,NULL); if (c == -1) break; switch (c) { default: - case '?': - usage(); + usage(E_OPTERR); + case 'h': + usage(E_USAGE); case 'c': fname = optarg; break; @@ -232,7 +234,7 @@ char pos[30]; if ((ac-optind) & 1) - usage(); + usage(E_OPTERR); if (strlen(av[optind])+1>IFNAMSIZ) complain(_("interface name `%s' too long"), av[optind]); safe_strncpy(ch->ifname, av[optind], sizeof(ch->ifname)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/netstat.c new/net-tools-2.0+git20180626.aebd88e/netstat.c --- old/net-tools-2.0+git20170221.479bb4a/netstat.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/netstat.c 2018-06-26 09:30:13.000000000 +0200 @@ -1962,41 +1962,42 @@ static void usage(int rc) { - fprintf(stderr, _("usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}\n")); - fprintf(stderr, _(" netstat [-vWnNcaeol] [<Socket> ...]\n")); - fprintf(stderr, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}\n")); + fprintf(fp, _(" netstat [-vWnNcaeol] [<Socket> ...]\n")); + fprintf(fp, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n")); - fprintf(stderr, _(" -r, --route display routing table\n")); - fprintf(stderr, _(" -i, --interfaces display interface table\n")); - fprintf(stderr, _(" -g, --groups display multicast group memberships\n")); - fprintf(stderr, _(" -s, --statistics display networking statistics (like SNMP)\n")); + fprintf(fp, _(" -r, --route display routing table\n")); + fprintf(fp, _(" -i, --interfaces display interface table\n")); + fprintf(fp, _(" -g, --groups display multicast group memberships\n")); + fprintf(fp, _(" -s, --statistics display networking statistics (like SNMP)\n")); #if HAVE_FW_MASQUERADE - fprintf(stderr, _(" -M, --masquerade display masqueraded connections\n\n")); + fprintf(fp, _(" -M, --masquerade display masqueraded connections\n\n")); #endif - fprintf(stderr, _(" -v, --verbose be verbose\n")); - fprintf(stderr, _(" -W, --wide don't truncate IP addresses\n")); - fprintf(stderr, _(" -n, --numeric don't resolve names\n")); - fprintf(stderr, _(" --numeric-hosts don't resolve host names\n")); - fprintf(stderr, _(" --numeric-ports don't resolve port names\n")); - fprintf(stderr, _(" --numeric-users don't resolve user names\n")); - fprintf(stderr, _(" -N, --symbolic resolve hardware names\n")); - fprintf(stderr, _(" -e, --extend display other/more information\n")); - fprintf(stderr, _(" -p, --programs display PID/Program name for sockets\n")); - fprintf(stderr, _(" -o, --timers display timers\n")); - fprintf(stderr, _(" -c, --continuous continuous listing\n\n")); - fprintf(stderr, _(" -l, --listening display listening server sockets\n")); - fprintf(stderr, _(" -a, --all display all sockets (default: connected)\n")); - fprintf(stderr, _(" -F, --fib display Forwarding Information Base (default)\n")); - fprintf(stderr, _(" -C, --cache display routing cache instead of FIB\n")); + fprintf(fp, _(" -v, --verbose be verbose\n")); + fprintf(fp, _(" -W, --wide don't truncate IP addresses\n")); + fprintf(fp, _(" -n, --numeric don't resolve names\n")); + fprintf(fp, _(" --numeric-hosts don't resolve host names\n")); + fprintf(fp, _(" --numeric-ports don't resolve port names\n")); + fprintf(fp, _(" --numeric-users don't resolve user names\n")); + fprintf(fp, _(" -N, --symbolic resolve hardware names\n")); + fprintf(fp, _(" -e, --extend display other/more information\n")); + fprintf(fp, _(" -p, --programs display PID/Program name for sockets\n")); + fprintf(fp, _(" -o, --timers display timers\n")); + fprintf(fp, _(" -c, --continuous continuous listing\n\n")); + fprintf(fp, _(" -l, --listening display listening server sockets\n")); + fprintf(fp, _(" -a, --all display all sockets (default: connected)\n")); + fprintf(fp, _(" -F, --fib display Forwarding Information Base (default)\n")); + fprintf(fp, _(" -C, --cache display routing cache instead of FIB\n")); #if HAVE_SELINUX - fprintf(stderr, _(" -Z, --context display SELinux security context for sockets\n")); + fprintf(fp, _(" -Z, --context display SELinux security context for sockets\n")); #endif - fprintf(stderr, _("\n <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}\n")); - fprintf(stderr, _(" {-x|--unix} --ax25 --ipx --netrom\n")); - fprintf(stderr, _(" <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF); - fprintf(stderr, _(" List of possible address families (which support routing):\n")); + fprintf(fp, _("\n <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}\n")); + fprintf(fp, _(" {-x|--unix} --ax25 --ipx --netrom\n")); + fprintf(fp, _(" <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF); + fprintf(fp, _(" List of possible address families (which support routing):\n")); print_aflist(1); /* 1 = routeable */ exit(rc); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/plipconfig.c new/net-tools-2.0+git20180626.aebd88e/plipconfig.c --- old/net-tools-2.0+git20170221.479bb4a/plipconfig.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/plipconfig.c 2018-06-26 09:30:13.000000000 +0200 @@ -57,12 +57,13 @@ exit(E_VERSION); } -void usage(void) +static void usage(int rc) { - fprintf(stderr, _("Usage: plipconfig interface [nibble NN] [trigger NN]\n")); - fprintf(stderr, _(" plipconfig -V | --version\n")); - fprintf(stderr, _(" plipconfig -h | --help\n")); - exit(E_USAGE); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: plipconfig interface [nibble NN] [trigger NN]\n")); + fprintf(fp, _(" plipconfig -V | --version\n")); + fprintf(fp, _(" plipconfig -h | --help\n")); + exit(rc); } void print_plip(void) @@ -91,14 +92,16 @@ while (argv[0] && *argv[0] == '-') { if (!strcmp(*argv, "-V") || !strcmp(*argv, "--version")) version(); + else if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) + usage(E_USAGE); else - usage(); + usage(E_OPTERR); argv++; argc--; } if (argc == 0) - usage(); + usage(E_OPTERR); spp = argv; safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ); @@ -117,19 +120,19 @@ while (*spp != (char *) NULL) { if (!strcmp(*spp, "nibble")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); plip->nibble = atoi(*spp); spp++; continue; } if (!strcmp(*spp, "trigger")) { if (*++spp == NULL) - usage(); + usage(E_OPTERR); plip->trigger = atoi(*spp); spp++; continue; } - usage(); + usage(E_OPTERR); } plip->pcmd = PLIP_SET_TIMEOUT; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/rarp.c new/net-tools-2.0+git20180626.aebd88e/rarp.c --- old/net-tools-2.0+git20170221.479bb4a/rarp.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/rarp.c 2018-06-26 09:30:13.000000000 +0200 @@ -173,18 +173,19 @@ return 0; } -static void usage(void) +static void usage(int rc) { - fprintf(stderr, _("Usage: rarp -a list entries in cache.\n")); - fprintf(stderr, _(" rarp -d <hostname> delete entry from cache.\n")); - fprintf(stderr, _(" rarp [<HW>] -s <hostname> <hwaddr> add entry to cache.\n")); - fprintf(stderr, _(" rarp -f add entries from /etc/ethers.\n")); - fprintf(stderr, _(" rarp -V display program version.\n\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: rarp -a list entries in cache.\n")); + fprintf(fp, _(" rarp -d <hostname> delete entry from cache.\n")); + fprintf(fp, _(" rarp [<HW>] -s <hostname> <hwaddr> add entry to cache.\n")); + fprintf(fp, _(" rarp -f add entries from /etc/ethers.\n")); + fprintf(fp, _(" rarp -V display program version.\n\n")); - fprintf(stderr, _(" <HW>=Use '-H <hw>' to specify hardware address type. Default: %s\n"), DFLT_HW); - fprintf(stderr, _(" List of possible hardware types (which support ARP):\n")); + fprintf(fp, _(" <HW>=Use '-H <hw>' to specify hardware address type. Default: %s\n"), DFLT_HW); + fprintf(fp, _(" List of possible hardware types (which support ARP):\n")); print_hwlist(1); /* 1 = ARPable */ - exit(E_USAGE); + exit(rc); } #define MODE_DISPLAY 1 @@ -225,9 +226,9 @@ case EOF: break; case 'h': - usage(); + usage(E_USAGE); case 'V': - fprintf(stderr, "%s\n", Release); + printf("%s\n", Release); exit(E_VERSION); break; case 'v': @@ -238,7 +239,7 @@ case 'd': if (mode) { fprintf(stderr, _("%s: illegal option mix.\n"), argv[0]); - usage(); + usage(E_OPTERR); } else { mode = (c == 'a' ? MODE_DISPLAY : (c == 'd' ? MODE_DELETE : MODE_SET)); } @@ -251,19 +252,19 @@ if (optarg) { hardware = get_hwtype(optarg); } else { - usage(); + usage(E_OPTERR); } break; case 1: if (nargs == 2) { - usage(); + usage(E_OPTERR); exit(1); } else { args[nargs++] = optarg; } break; default: - usage(); + usage(E_OPTERR); } } while (c != EOF); @@ -273,11 +274,11 @@ } switch (mode) { case 0: - usage(); + usage(E_OPTERR); case MODE_DISPLAY: if (nargs != (mode - 1)) { - usage(); + usage(E_OPTERR); } result = display_cache(); break; @@ -285,7 +286,7 @@ case MODE_DELETE: case MODE_SET: if (nargs != (mode - 1)) { - usage(); + usage(E_OPTERR); } if ((hp = gethostbyname(args[0])) == NULL) { fprintf(stderr, _("rarp: %s: unknown host\n"), args[0]); @@ -301,7 +302,7 @@ case MODE_ETHERS: if (nargs != 0 && nargs != 1) - usage(); + usage(E_OPTERR); if (fd = socket(PF_INET, SOCK_DGRAM, 0), fd < 0) { perror("socket"); exit(1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/route.c new/net-tools-2.0+git20180626.aebd88e/route.c --- old/net-tools-2.0+git20170221.479bb4a/route.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/route.c 2018-06-26 09:30:13.000000000 +0200 @@ -78,20 +78,21 @@ static void usage(int rc) { - fprintf(stderr, _("Usage: route [-nNvee] [-FC] [<AF>] List kernel routing tables\n")); - fprintf(stderr, _(" route [-v] [-FC] {add|del|flush} ... Modify routing table for AF.\n\n")); + FILE *fp = rc ? stderr : stdout; + fprintf(fp, _("Usage: route [-nNvee] [-FC] [<AF>] List kernel routing tables\n")); + fprintf(fp, _(" route [-v] [-FC] {add|del|flush} ... Modify routing table for AF.\n\n")); + + fprintf(fp, _(" route {-h|--help} [<AF>] Detailed usage syntax for specified AF.\n")); + fprintf(fp, _(" route {-V|--version} Display version/author and exit.\n\n")); + + fprintf(fp, _(" -v, --verbose be verbose\n")); + fprintf(fp, _(" -n, --numeric don't resolve names\n")); + fprintf(fp, _(" -e, --extend display other/more information\n")); + fprintf(fp, _(" -F, --fib display Forwarding Information Base (default)\n")); + fprintf(fp, _(" -C, --cache display routing cache instead of FIB\n\n")); - fprintf(stderr, _(" route {-h|--help} [<AF>] Detailed usage syntax for specified AF.\n")); - fprintf(stderr, _(" route {-V|--version} Display version/author and exit.\n\n")); - - fprintf(stderr, _(" -v, --verbose be verbose\n")); - fprintf(stderr, _(" -n, --numeric don't resolve names\n")); - fprintf(stderr, _(" -e, --extend display other/more information\n")); - fprintf(stderr, _(" -F, --fib display Forwarding Information Base (default)\n")); - fprintf(stderr, _(" -C, --cache display routing cache instead of FIB\n\n")); - - fprintf(stderr, _(" <AF>=Use -4, -6, '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF); - fprintf(stderr, _(" List of possible address families (which support routing):\n")); + fprintf(fp, _(" <AF>=Use -4, -6, '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF); + fprintf(fp, _(" List of possible address families (which support routing):\n")); print_aflist(1); /* 1 = routeable */ exit(rc); } @@ -99,7 +100,7 @@ static void version(void) { - fprintf(stderr, "%s\n%s\n", Release, Features); + printf("%s\n%s\n", Release, Features); exit(E_VERSION); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/net-tools-2.0+git20170221.479bb4a/slattach.c new/net-tools-2.0+git20180626.aebd88e/slattach.c --- old/net-tools-2.0+git20170221.479bb4a/slattach.c 2017-02-21 19:24:32.000000000 +0100 +++ new/net-tools-2.0+git20180626.aebd88e/slattach.c 2018-06-26 09:30:13.000000000 +0200 @@ -574,8 +574,9 @@ static void -usage(void) +usage(int rc) { + FILE *fp = rc ? stderr : stdout; char *usage_msg = "Usage: slattach [-ehlLmnqv] " #ifdef SIOCSKEEPALIVE "[-k keepalive] " @@ -586,8 +587,8 @@ "[-c cmd] [-s speed] [-p protocol] tty | -\n" " slattach -V | --version\n"; - fputs(usage_msg, stderr); - exit(E_USAGE); + fputs(usage_msg, fp); + exit(rc); } @@ -684,7 +685,7 @@ /*NOTREACHED*/ default: - usage(); + usage(E_OPTERR); /*NOTREACHED*/ } @@ -700,7 +701,7 @@ opt_m++; /* Is a terminal given? */ - if (optind != (argc - 1)) usage(); + if (optind != (argc - 1)) usage(E_OPTERR); safe_strncpy(path_buf, argv[optind], sizeof(path_buf)); if (!strcmp(path_buf, "-")) { opt_e = 1;