diff options
author | attilio <attilio@FreeBSD.org> | 2009-07-04 11:11:21 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2009-07-04 11:11:21 +0000 |
commit | d483a0f67c6361d1cdabe323bb62563bf5354af8 (patch) | |
tree | db4f467503013769cb9bd190529b4a7abae23d13 /usr.sbin/tzsetup | |
parent | af8ce5a98815085a29b45a941b5af56345470b10 (diff) | |
download | FreeBSD-src-d483a0f67c6361d1cdabe323bb62563bf5354af8.zip FreeBSD-src-d483a0f67c6361d1cdabe323bb62563bf5354af8.tar.gz |
Add a new options (-s) that, when specified, skips the question about
adjusting the clock to UTC.
That avoids to write on /etc/wall_cmos_clock which is useful in some
cases (example: host user in a jail).
Sponsored by: Sandvine Incorporated
Initially submitted by: Matt Koivisto <mkoivisto at sandvine dot com>
Approved by: re (kib)
Diffstat (limited to 'usr.sbin/tzsetup')
-rw-r--r-- | usr.sbin/tzsetup/tzsetup.8 | 7 | ||||
-rw-r--r-- | usr.sbin/tzsetup/tzsetup.c | 50 |
2 files changed, 33 insertions, 24 deletions
diff --git a/usr.sbin/tzsetup/tzsetup.8 b/usr.sbin/tzsetup/tzsetup.8 index 562744c..fd355b6 100644 --- a/usr.sbin/tzsetup/tzsetup.8 +++ b/usr.sbin/tzsetup/tzsetup.8 @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd January 24, 1996 +.Dd July 4, 2009 .Dt TZSETUP 8 .Os .Sh NAME @@ -31,7 +31,7 @@ .Nd set local timezone .Sh SYNOPSIS .Nm -.Op Fl n +.Op Fl ns .Op Ar default .Sh DESCRIPTION The @@ -51,6 +51,9 @@ The following option is available: .Bl -tag -offset indent -width Fl .It Fl n Do not create or copy files. +.It Fl s +Skip the initial question about adjusting the clock if not set to +.Tn UTC . .El .Pp It is possible to short-circuit the menu system by specifying a diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index c02bac1..66a34c4 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -652,7 +652,7 @@ static void usage(void) { - fprintf(stderr, "usage: tzsetup [-n]\n"); + fprintf(stderr, "usage: tzsetup [-ns]\n"); exit(1); } @@ -666,14 +666,17 @@ int main(int argc, char **argv) { char title[64], prompt[128]; - int c, fd; + int c, fd, skiputc; - while ((c = getopt(argc, argv, "n")) != -1) { + skiputc = 0; + while ((c = getopt(argc, argv, "ns")) != -1) { switch(c) { case 'n': reallydoit = 0; break; - + case 's': + skiputc = 1; + break; default: usage(); } @@ -690,27 +693,30 @@ main(int argc, char **argv) sort_countries(); make_menus(); - snprintf(title, sizeof(title), - "Select local or UTC (Greenwich Mean Time) clock"); - snprintf(prompt, sizeof(prompt), - "Is this machine's CMOS clock set to UTC? " - "If it is set to local time,\n" - "or you don't know, please choose NO here!"); init_dialog(); - if (!DIALOG_UTC(title, prompt, 7, 72)) { - if (reallydoit) - unlink(_PATH_WALL_CMOS_CLOCK); - } else { - if (reallydoit) { - fd = open(_PATH_WALL_CMOS_CLOCK, - O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IRGRP | S_IROTH); - if (fd < 0) - err(1, "create %s", _PATH_WALL_CMOS_CLOCK); - close(fd); + if (skiputc == 0) { + snprintf(title, sizeof(title), + "Select local or UTC (Greenwich Mean Time) clock"); + snprintf(prompt, sizeof(prompt), + "Is this machine's CMOS clock set to UTC? " + "If it is set to local time,\n" + "or you don't know, please choose NO here!"); + if (!DIALOG_UTC(title, prompt, 7, 72)) { + if (reallydoit) + unlink(_PATH_WALL_CMOS_CLOCK); + } else { + if (reallydoit) { + fd = open(_PATH_WALL_CMOS_CLOCK, + O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IRGRP | S_IROTH); + if (fd < 0) + err(1, "create %s", + _PATH_WALL_CMOS_CLOCK); + close(fd); + } } + dialog_clear_norefresh(); } - dialog_clear_norefresh(); if (optind == argc - 1) { snprintf(title, sizeof(title), "Default timezone provided"); snprintf(prompt, sizeof(prompt), |