Bug 15797 - rdate shouldn't require /etc/services
Summary: rdate shouldn't require /etc/services
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rdate   
(Show other bugs)
Version: 7.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-08-09 12:31 UTC by Rick Niles
Modified: 2015-03-05 01:08 UTC (History)
2 users (show)

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: ---


Attachments (Terms of Use)

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)


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