From c42be9fd38556a1cc2e16c8d763a592beb863806 Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Tue, 17 Jan 2006 21:22:00 +0000 Subject: r12986: Use d_fprintf(stderr, ...) for any error message in net. All 'usage' messages are still printed to stdout. Fix some compiler warnings for system() calls where we didn't used the return code. Add appropriate error messages and return with the error code we got from system() or NT_STATUS_UNSUCCESSFUL. (This used to be commit f650e3bdafc4c6bcd7eb4bcf8b6b885b979919eb) --- source3/utils/net_time.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/utils/net_time.c') diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 691adcea00..1a7116d447 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -99,6 +99,7 @@ static int net_time_set(int argc, const char **argv) { time_t t = nettime(NULL); char *cmd; + int result; if (t == 0) return -1; @@ -106,10 +107,13 @@ static int net_time_set(int argc, const char **argv) roll your own. I'm putting this in as it works on a large number of systems and the user has a choice in whether its used or not */ asprintf(&cmd, "/bin/date %s", systime(t)); - system(cmd); + result = system(cmd); + if (result) + d_fprintf(stderr, "%s failed. Error was (%s)\n", + cmd, strerror(errno)); free(cmd); - return 0; + return result; } /* display the time on a remote box in a format ready for /bin/date */ @@ -161,7 +165,7 @@ int net_time(int argc, const char **argv) if (!opt_host && !opt_have_ip && !find_master_ip(opt_target_workgroup, &opt_dest_ip)) { - d_printf("Could not locate a time server. Try "\ + d_fprintf(stderr, "Could not locate a time server. Try "\ "specifying a target host.\n"); net_time_usage(argc,argv); return -1; -- cgit