Bug 15797 - rdate shouldn't require /etc/services
rdate shouldn't require /etc/services
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: rdate (Show other bugs)
7.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-08-09 08:31 EDT by Rick Niles
Modified: 2015-03-04 20:08 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-08-09 10:40:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rick Niles 2000-08-09 08:31:56 EDT
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)

Note You need to log in before you can comment on or make changes to this bug.