summaryrefslogtreecommitdiff
path: root/source3/utils/net_time.c
diff options
context:
space:
mode:
authorLars Müller <lmuelle@samba.org>2006-01-17 21:22:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:06:09 -0500
commitc42be9fd38556a1cc2e16c8d763a592beb863806 (patch)
treee69234055238ca6996dac2c153ad0c3e44f1e134 /source3/utils/net_time.c
parentf7519540090b2f47259f72d81b267b3e7a1a8950 (diff)
downloadsamba-c42be9fd38556a1cc2e16c8d763a592beb863806.tar.gz
samba-c42be9fd38556a1cc2e16c8d763a592beb863806.tar.bz2
samba-c42be9fd38556a1cc2e16c8d763a592beb863806.zip
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)
Diffstat (limited to 'source3/utils/net_time.c')
-rw-r--r--source3/utils/net_time.c10
1 files changed, 7 insertions, 3 deletions
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;