From 93339d735062858e896795fc1544ae9782043269 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Jul 2014 12:29:37 -0700 Subject: [PATCH 1/2] s3: xml-docs. Ensure users of 'net time' know the remote server must be specified with -S. Bug 10728 - 'net time system' segfaults https://bugzilla.samba.org/show_bug.cgi?id=10728 Signed-off-by: Jeremy Allison --- docs-xml/manpages/net.8.xml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml index 8524d1f..d497e66 100644 --- a/docs-xml/manpages/net.8.xml +++ b/docs-xml/manpages/net.8.xml @@ -404,7 +404,8 @@ YOU HAVE BEEN WARNED. TIME Without any options, the NET TIME command -displays the time on the remote server. +displays the time on the remote server. The remote server must be +specified with the -S option. @@ -412,21 +413,27 @@ displays the time on the remote server. TIME SYSTEM -Displays the time on the remote server in a format ready for /bin/date. +Displays the time on the remote server in a format ready for /bin/date. +The remote server must be specified with the -S option. + TIME SET Tries to set the date and time of the local server to that on -the remote server using /bin/date. +the remote server using /bin/date. +The remote server must be specified with the -S option. + TIME ZONE -Displays the timezone in hours from GMT on the remote computer. +Displays the timezone in hours from GMT on the remote server. +The remote server must be specified with the -S option. + -- 2.0.0.526.g5318336 From b85fdf0d06c5169f5d11bde32701d64321a6ef62 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Jul 2014 14:12:31 -0700 Subject: [PATCH 2/2] s3: net time - fix usage and core dump. Bug 10728 - 'net time system' segfaults https://bugzilla.samba.org/show_bug.cgi?id=10728 Signed-off-by: Jeremy Allison --- source3/utils/net_time.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 847b4fe..56ce8f7 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -84,10 +84,10 @@ static const char *systime(time_t t) int net_time_usage(struct net_context *c, int argc, const char **argv) { d_printf(_( -"net time\n\tdisplays time on a server\n\n" -"net time system\n\tdisplays time on a server in a format ready for /bin/date\n\n" -"net time set\n\truns /bin/date with the time from the server\n\n" -"net time zone\n\tdisplays the timezone in hours from GMT on the remote computer\n\n" +"net time\n\tdisplays time on a server (-S server)\n\n" +"net time system\n\tdisplays time on a server (-S server) in a format ready for /bin/date\n\n" +"net time set\n\truns /bin/date with the time from the server (-S server)\n\n" +"net time zone\n\tdisplays the timezone in hours from GMT on the remote server (-S server)\n\n" "\n")); net_common_flags_usage(c, argc, argv); return -1; @@ -99,6 +99,16 @@ static int net_time_set(struct net_context *c, int argc, const char **argv) struct timeval tv; int result; + if (c->display_usage || c->opt_host == NULL) { + d_printf( "%s\n" + "net time set\n" + " %s\n", + _("Usage:"), + _("Set local time to that of remote time " + "server (-S server) ")); + return 0; + } + tv.tv_sec = nettime(c, NULL); tv.tv_usec=0; @@ -118,13 +128,13 @@ static int net_time_system(struct net_context *c, int argc, const char **argv) { time_t t; - if (c->display_usage) { + if (c->display_usage || c->opt_host == NULL) { d_printf( "%s\n" "net time system\n" " %s\n", _("Usage:"), - _("Output remote time server time in a format " - "ready for /bin/date")); + _("Output remote time server (-S server) " + "time in a format ready for /bin/date")); return 0; } @@ -144,13 +154,13 @@ static int net_time_zone(struct net_context *c, int argc, const char **argv) char zsign; time_t t; - if (c->display_usage) { + if (c->display_usage || c->opt_host == NULL) { d_printf( "%s\n" "net time zone\n" " %s\n", _("Usage:"), - _("Display the remote time server's offset to " - "UTC")); + _("Display the remote time server's (-S server) " + "offset to UTC")); return 0; } -- 2.0.0.526.g5318336