[rwho] allow longer hostnames (bug #212076)

Jan Horak hhorak at fedoraproject.org
Wed Dec 7 14:38:31 UTC 2011


commit 3d096530ea045413cd8fb0eaaeb23cef10b5307a
Author: Honza HorĂ¡k <hhorak at redhat.com>
Date:   Wed Dec 7 15:23:37 2011 +0100

    allow longer hostnames (bug #212076)

 netkit-rwho-0.17-hostnamelen.patch |   64 ++++++++++++++++++++++++++++++++++++
 rwho.spec                          |    5 ++-
 2 files changed, 68 insertions(+), 1 deletions(-)
---
diff --git a/netkit-rwho-0.17-hostnamelen.patch b/netkit-rwho-0.17-hostnamelen.patch
new file mode 100644
index 0000000..8710a1e
--- /dev/null
+++ b/netkit-rwho-0.17-hostnamelen.patch
@@ -0,0 +1,64 @@
+Only in netkit-rwho-0.17mzk/: MCONFIG
+Only in netkit-rwho-0.17mzk/ruptime: a.out
+diff -urp netkit-rwho-0.17/ruptime/ruptime.c netkit-rwho-0.17mzk/ruptime/ruptime.c
+--- netkit-rwho-0.17/ruptime/ruptime.c	2007-08-10 13:29:10.000000000 +0200
++++ netkit-rwho-0.17mzk/ruptime/ruptime.c	2007-08-10 13:46:08.000000000 +0200
+@@ -66,6 +66,7 @@ struct hs {
+ 
+ #define	ISDOWN(h)	(now - (h)->hs_recvtime > 11 * 60)
+ #define	WHDRSIZE	((int)(sizeof (awhod) - sizeof (awhod.wd_we)))
++#define HOSTNAMELEN 12
+ 
+ static size_t nhosts, hspace = 20;
+ static struct hs *hs;
+@@ -93,10 +94,11 @@ main(int argc, char **argv)
+ 	unsigned i;
+ 	struct whod buf;
+ 	int (*cmp)(const void *, const void *) = hscmp;
++	int hostnamelen = HOSTNAMELEN;
+ 	time_t correction;
+ 
+ 	aflg = 0;
+-	while ((ch = getopt(argc, argv, "alrut")) != -1)
++	while ((ch = getopt(argc, argv, "alrutn:")) != -1)
+ 		switch((char)ch) {
+ 		case 'a':
+ 			aflg = 1;
+@@ -113,6 +115,13 @@ main(int argc, char **argv)
+ 		case 'u':
+ 			cmp = ucmp;
+ 			break;
++		case 'n':
++			hostnamelen = atoi(optarg+1);
++			if(hostnamelen < 0){
++				fprintf(stderr,"Error, hostname length can't be negative number!\n");
++				exit(1);
++			}
++			break;
+ 		default: 
+ 			(void)fprintf(stderr, "usage: ruptime [-alrut]\n");
+ 			exit(1);
+@@ -182,15 +191,20 @@ main(int argc, char **argv)
+ 	}
+ 	(void)time(&now);
+ 	qsort(hs, nhosts, sizeof(hs[0]), cmp);
++	char output_format[512];
++	char *down_pattern = "%%-%i.%is%%s\n";
++	char *up_pattern = "%%-%i.%is%%s,  %%4d user%%s  load %%*.2f, %%*.2f, %%*.2f\n";
+ 	for (i = 0; i < nhosts; i++) {
+ 		hsp = &hs[i];
+ 		if (ISDOWN(hsp)) {
+-			(void)printf("%-12.12s%s\n", hsp->hs_hostname,
++			sprintf(output_format, down_pattern, hostnamelen,hostnamelen);
++			(void)printf(output_format, hsp->hs_hostname,
+ 			    interval(now - hsp->hs_recvtime, "down"));
+ 			continue;
+ 		}
++		sprintf(output_format, up_pattern, hostnamelen,hostnamelen);
+ 		(void)printf(
+-		    "%-12.12s%s,  %4d user%s  load %*.2f, %*.2f, %*.2f\n",
++		    output_format,
+ 		    hsp->hs_hostname,
+ 		    interval((time_t)hsp->hs_sendtime -
+ 			(time_t)hsp->hs_boottime, "  up"),
+Only in netkit-rwho-0.17mzk/ruptime: ruptime.c~
diff --git a/rwho.spec b/rwho.spec
index 0f08227..5b6b226 100644
--- a/rwho.spec
+++ b/rwho.spec
@@ -1,7 +1,7 @@
 Summary: Displays who is logged in to local network machines
 Name: rwho
 Version: 0.17
-Release: 36%{?dist}
+Release: 37%{?dist}
 License: BSD
 Group: System Environment/Daemons
 Source: ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/netkit-rwho-%{version}.tar.gz
@@ -17,6 +17,7 @@ Patch7: netkit-rwho-0.17-time.patch
 Patch8: netkit-rwho-0.17-gcc4.patch
 Patch9: netkit-rwho-0.17-waitchild.patch
 Patch10: netkit-rwho-0.17-neighbours.patch
+Patch11: netkit-rwho-0.17-hostnamelen.patch
 Requires(post): systemd-units
 Requires(preun): systemd-units
 Requires(postun): systemd-units
@@ -45,6 +46,7 @@ are logged in to your local network.
 %patch8 -p1 -b .gcc4
 %patch9 -p1 -b .waitchild
 %patch10 -p1 -b .neighbours
+%patch11 -p1 -b .hostnamelen
 
 %build
 sh configure --with-c-compiler=gcc
@@ -127,6 +129,7 @@ fi
 * Wed Dec 07 2011 Honza Horak <hhorak at redhat.com> - 0.17-37
 - systemd unit file mod fix
   removed non-essential Requires: /sbin/chkconfig /etc/init.d
+- allow longer hostnames (bug #212076)
 
 * Wed Aug 01 2011 Honza Horak <hhorak at redhat.com> - 0.17-36
 - added systemd native unit file


More information about the scm-commits mailing list