summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-12 09:37:17 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-12 09:37:17 +0000
commit60b53b3f6f96c90533264f9dcbfc0edb61f41b7e (patch)
tree8b3c7e3bf472b87f047efab80436bcf8dd42bfcb /source3
parent65cfe6a492b236f49edd591a7e728cbeeed3c344 (diff)
downloadsamba-60b53b3f6f96c90533264f9dcbfc0edb61f41b7e.tar.gz
samba-60b53b3f6f96c90533264f9dcbfc0edb61f41b7e.tar.bz2
samba-60b53b3f6f96c90533264f9dcbfc0edb61f41b7e.zip
added "net time zone" command to show the timezone on a computer
(This used to be commit 4e2691b1c13a7db4770effa6eddeb19adb47f8ae)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_time.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index f99eb9054d..20d51e2a41 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -25,7 +25,7 @@
/*
return the time on a server. This does not require any authentication
*/
-static time_t cli_servertime(const char *host, struct in_addr *ip)
+static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
{
struct nmb_name calling, called;
time_t ret = 0;
@@ -57,6 +57,7 @@ static time_t cli_servertime(const char *host, struct in_addr *ip)
}
ret = cli->servertime;
+ if (zone) *zone = cli->serverzone;
done:
if (cli) cli_shutdown(cli);
@@ -64,12 +65,12 @@ done:
}
/* find the servers time on the opt_host host */
-static time_t nettime(void)
+static time_t nettime(int *zone)
{
extern BOOL opt_have_ip;
extern struct in_addr opt_dest_ip;
extern char *opt_host;
- return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL);
+ return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone);
}
/* return a time as a string ready to be passed to date -u */
@@ -92,6 +93,7 @@ int net_time_usage(int argc, const char **argv)
"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 -u 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"\
"\n");
general_rap_usage(argc, argv);
return -1;
@@ -100,7 +102,7 @@ int net_time_usage(int argc, const char **argv)
/* try to set the system clock using /bin/date */
static int net_time_set(int argc, const char **argv)
{
- time_t t = nettime();
+ time_t t = nettime(NULL);
char *cmd;
if (t == 0) return -1;
@@ -118,7 +120,7 @@ static int net_time_set(int argc, const char **argv)
/* display the time on a remote box in a format ready for /bin/date */
static int net_time_system(int argc, const char **argv)
{
- time_t t = nettime();
+ time_t t = nettime(NULL);
if (t == 0) return -1;
@@ -127,6 +129,27 @@ static int net_time_system(int argc, const char **argv)
return 0;
}
+/* display the time on a remote box in a format ready for /bin/date */
+static int net_time_zone(int argc, const char **argv)
+{
+ int zone = 0;
+ time_t t;
+
+ t = nettime(&zone);
+
+ if (t == 0) return -1;
+
+ zone /= 60;
+
+ if (zone % 60 == 0) {
+ printf("%+d\n", -zone / 60);
+ } else {
+ printf("%+.1f\n", ((double)-zone) / 60);
+ }
+
+ return 0;
+}
+
/* display or set the time on a host */
int net_time(int argc, const char **argv)
{
@@ -137,6 +160,7 @@ int net_time(int argc, const char **argv)
struct functable func[] = {
{"SYSTEM", net_time_system},
{"SET", net_time_set},
+ {"ZONE", net_time_zone},
{NULL, NULL}
};
@@ -150,7 +174,7 @@ int net_time(int argc, const char **argv)
}
/* default - print the time */
- t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL);
+ t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL);
if (t == 0) return -1;
d_printf("%s", ctime(&t));