bin/164042: [PATCH] tzsetup(8): Fix VERBOSE to work with new UTC
menu option
Devin Teske
dteske at vicor.com
Thu Jan 12 06:10:11 UTC 2012
>Number: 164042
>Category: bin
>Synopsis: [PATCH] tzsetup(8): Fix VERBOSE to work with new UTC menu option
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Jan 12 06:10:11 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Devin Teske
>Release: FreeBSD 9.0-RELEASE amd64
>Organization:
FIS Global, Inc.
>Environment:
FreeBSD scribe.vicor.com 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2010
root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
When compiling with VERBOSE, the verbosity doesn't make sense when selecting the new "UTC" top-level menu-item (which removes the /etc/localtime and /var/db/zoneinfo files).
While we're here, also make the verbose messages adhere to "-n".
>How-To-Repeat:
Compile with VERBOSE defined (-DVERBOSE). Select the "UTC" top-level item. Observe the message:
Copying to /etc/localtime
or, if you have a symlink in place at /etc/localtime before executing tzsetup(8), instead observe:
Creating symbolic link /etc/localtime to (UTC)
The problem with both of these messages is that what actually happens is that /etc/localtime is deleted. No symbolic link is ever created (despite the message) and no file is ever copied, rather unlink(2) is called and the result is that /etc/localtime no longer exists.
This patch causes the verbose messages to instead be:
Removing /etc/localtime
Which is a more accurate description of what occurred after selecting the "UTC" menu item that was added in SVN r220172.
>Fix:
See attached patch.txt
Patch attached with submission follows:
--- usr.sbin/tzsetup/tzsetup.c.orig Fri Dec 2 11:19:10 2011
+++ usr.sbin/tzsetup/tzsetup.c Wed Jan 11 19:47:51 2012
@@ -652,14 +652,16 @@ install_zoneinfo_file(const char *zonein
copymode = 1;
#ifdef VERBOSE
- if (copymode)
+ if (zoneinfo_file == NULL)
+ snprintf(prompt, sizeof(prompt),
+ "Removing %s", path_localtime);
+ else if (copymode)
snprintf(prompt, sizeof(prompt),
"Copying %s to %s", zoneinfo_file, path_localtime);
else
snprintf(prompt, sizeof(prompt),
"Creating symbolic link %s to %s",
- path_localtime,
- zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file);
+ path_localtime, zoneinfo_file);
if (usedialog)
dialog_notify(prompt);
else
@@ -692,6 +694,10 @@ install_zoneinfo_file(const char *zonein
return (DITEM_FAILURE | DITEM_RECREATE);
}
+#ifdef VERBOSE
+ snprintf(prompt, sizeof(prompt),
+ "Removed %s", path_localtime);
+#endif
return (DITEM_LEAVE_MENU);
}
@@ -769,23 +775,23 @@ install_zoneinfo_file(const char *zonein
return (DITEM_FAILURE | DITEM_RECREATE);
}
}
- }
#ifdef VERBOSE
- snprintf(title, sizeof(title), "Done");
- if (copymode)
- snprintf(prompt, sizeof(prompt),
- "Copied timezone file from %s to %s", zoneinfo_file,
- path_localtime);
- else
- snprintf(prompt, sizeof(prompt),
- "Created symbolic link from %s to %s", zoneinfo_file,
- path_localtime);
- if (usedialog)
- dialog_msgbox(title, prompt, 8, 72, 1);
- else
- fprintf(stderr, "%s\n", prompt);
+ snprintf(title, sizeof(title), "Done");
+ if (copymode)
+ snprintf(prompt, sizeof(prompt),
+ "Copied timezone file from %s to %s",
+ zoneinfo_file, path_localtime);
+ else
+ snprintf(prompt, sizeof(prompt),
+ "Created symbolic link from %s to %s",
+ zoneinfo_file, path_localtime);
+ if (usedialog)
+ dialog_msgbox(title, prompt, 8, 72, 1);
+ else
+ fprintf(stderr, "%s\n", prompt);
#endif
+ } /* reallydoit */
return (DITEM_LEAVE_MENU);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list