aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/tzsetup
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2017-08-07 21:38:10 +0000
committerMarius Strobl <marius@FreeBSD.org>2017-08-07 21:38:10 +0000
commiteabfbad0502478038748fa8211c875e953b2619d (patch)
tree3f325b58407f5ebd894aafe5ddbd23847936401a /usr.sbin/tzsetup
parent662e98634721cf119a23dbc2f7f04d31cbc3c9f4 (diff)
downloadsrc-eabfbad0502478038748fa8211c875e953b2619d.tar.gz
src-eabfbad0502478038748fa8211c875e953b2619d.zip
Revert the parts of r322097 related to /etc/wall_cmos_clock handling as
the previous behavior actually is required for setting up configurations in which the RTC is using UTC but the timezone is not. Still, besides uniform error handling, that file should get the same treatment in the non-interactive variants supported by tzsetup(8).
Notes
Notes: svn path=/head/; revision=322203
Diffstat (limited to 'usr.sbin/tzsetup')
-rw-r--r--usr.sbin/tzsetup/tzsetup.c58
1 files changed, 14 insertions, 44 deletions
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index e51aaef57f39..3e422ade25ff 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -866,47 +866,9 @@ install_zoneinfo_file(const char *zoneinfo_file)
static int
install_zoneinfo(const char *zoneinfo)
{
- int fd, rv;
+ int rv;
FILE *f;
char path_zoneinfo_file[MAXPATHLEN];
- char prompt[SILLY_BUFFER_SIZE], title[64];
-
- if (reallydoit) {
- if (strcmp(zoneinfo, "UTC") == 0) {
- if (unlink(path_wall_cmos_clock) < 0 &&
- errno != ENOENT) {
- snprintf(title, sizeof(title), "Error");
- snprintf(prompt, sizeof(prompt),
- "Could not delete %s: %s",
- path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
- if (usedialog)
- dialog_msgbox(title, prompt, 8, 72, 1);
- else
-#endif
- fprintf(stderr, "%s\n", prompt);
-
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
- } else {
- fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT |
- O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- snprintf(title, sizeof(title), "Error");
- snprintf(prompt, sizeof(prompt),
- "Could not create %s: %s",
- path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
- if (usedialog)
- dialog_msgbox(title, prompt, 8, 72, 1);
- else
-#endif
- fprintf(stderr, "%s\n", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
- close(fd);
- }
- }
if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
"%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
@@ -938,6 +900,7 @@ main(int argc, char **argv)
{
#ifdef HAVE_DIALOG
char title[64], prompt[128];
+ int fd;
#endif
int c, rv, skiputc;
char vm_guest[16] = "";
@@ -992,7 +955,6 @@ main(int argc, char **argv)
_PATH_WALL_CMOS_CLOCK);
}
-
/* Override the user-supplied umask. */
(void)umask(S_IWGRP | S_IWOTH);
@@ -1059,11 +1021,19 @@ main(int argc, char **argv)
yesno = dialog_yesno(title, prompt, 7, 73);
dlg_restore_vars(&save_vars);
if (!yesno) {
+ if (reallydoit)
+ unlink(path_wall_cmos_clock);
+ } else {
if (reallydoit) {
- rv = install_zoneinfo("UTC");
- dlg_clear();
- end_dialog();
- exit(rv & ~DITEM_LEAVE_MENU);
+ fd = open(path_wall_cmos_clock,
+ O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IRGRP | S_IROTH);
+ if (fd < 0) {
+ end_dialog();
+ err(1, "create %s",
+ path_wall_cmos_clock);
+ }
+ close(fd);
}
}
dlg_clear();