Bug 13796
Summary: | "rdate -s host" can fail but still exit(0) | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | charles |
Component: | rdate | Assignee: | Crutcher Dunnavant <crutcher> |
Status: | CLOSED RAWHIDE | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 6.2 | CC: | charles |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
URL: | http://www.larim.polymtl.ca/~chuck/rdate-retval.patch | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2000-07-26 23:35:58 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
charles
2000-07-12 14:26:27 UTC
I can't duplicate this. Can you send more info, and the patch? Try something like rdate no_such_host. down_host.; echo $? and it will exit with 0, which is not very helpful in scripts. This is with rdate-1.0-1.i386.rpm. --- rdate.c.orig-1.0 Fri Feb 4 14:07:08 2000 +++ rdate.c Wed Jul 12 03:48:52 2000 @@ -107,7 +107,9 @@ static void usage(int iserr) { - fprintf(stderr, "Usage: %s [-s] [-p] <host> ...\n", program_invocation_short_name); + fprintf(iserr ? stderr : stdout, + "Usage: %s [-s] [-p] <host> ...\n", + program_invocation_short_name); exit(iserr?1:0); } @@ -117,7 +119,7 @@ int print_mode = 0, set_mode = 0; char **hosts = NULL; int nhosts = 0; - int retval = 0; + int retval = 1; for(i = 1; i < argc; i++) { @@ -148,6 +150,9 @@ } } + if(!nhosts) + usage(1); + if(!set_mode && !print_mode) print_mode = 1; @@ -160,18 +165,32 @@ printf("[%s]\t%s", hosts[i], ctime(&timeval) /* ctime includes a trailing \n */); /* Do specified action(s) */ - if(set_mode && stime(&timeval) < 0) + if(set_mode) { - fprintf(stderr, "%s: could not set system time: %s\n", program_invocation_short_name, strerror(errno)); - retval = 1; - break; + if(stime(&timeval) == 0) + set_mode = 0; + else + { + fprintf(stderr, + "%s: could not set system time using host \"%s\": %s\n", + program_invocation_short_name, + hosts[i], + strerror(errno)); + } } - set_mode = 0; + + retval = 0; } } - if(!nhosts) - usage(1); - + if (set_mode) + { + if (nhosts > 1) + fprintf(stderr, + "%s: could not set system time at all\n", + program_invocation_short_name); + retval = 1; + } + return retval; } The patch given is nasty, so I just did it myself. rdate now keeps track of successful calls to the internal rdate function. Maybe it could work better, but It does work, and I am marking it closed. The new version is rdate-1.0-4.src.rpm |