Bug 15797

Summary: rdate shouldn't require /etc/services
Product: [Retired] Red Hat Linux Reporter: Rick Niles <niles>
Component: rdateAssignee: Phil Knirsch <pknirsch>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: niles, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-08-09 14:40:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rick Niles 2000-08-09 12:31:56 UTC
rdate shouldn't require /etc/services.  There should be a fall back
default.
It would make life a lot easier for minimal installations (e.g. Beowulf
slave nodes).

Please consider adding this patch:

--- rdate-1.0/rdate.c.~1~	Fri Feb  4 14:07:08 2000
+++ rdate-1.0/rdate.c	Wed Jun  7 14:36:48 2000
@@ -34,6 +34,7 @@
 
 /* difference between Unix time and net time */
 #define BASE1970	2208988800L
+#define DEFAULT_PORT     37
 
 static int
 rdate(const char *hostname, time_t *retval)
@@ -64,12 +65,10 @@
       memcpy(&saddr.sin_addr, hent->h_addr_list[0], hent->h_length);
     }
 
-  if(!(sent = getservbyname("time", "tcp")))
-    {
-      fprintf(stderr, "%s: time/tcp: service not found\n",
program_invocation_short_name);
-      return -1;
-    }
-  saddr.sin_port = sent->s_port;
+  if((sent = getservbyname("time", "tcp")))
+    saddr.sin_port = sent->s_port;      
+  else
+    saddr.sin_port = htons(DEFAULT_PORT);
 
   fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   if(fd < 0)