aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/tzsetup
diff options
context:
space:
mode:
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();