From nobody@FreeBSD.org  Thu Jan 12 06:07:27 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C4CCC106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jan 2012 06:07:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id AF8788FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jan 2012 06:07:27 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0C67RB9016297
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jan 2012 06:07:27 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q0C67R4w016293;
	Thu, 12 Jan 2012 06:07:27 GMT
	(envelope-from nobody)
Message-Id: <201201120607.q0C67R4w016293@red.freebsd.org>
Date: Thu, 12 Jan 2012 06:07:27 GMT
From: Devin Teske <dteske@vicor.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] tzsetup(8): Fix VERBOSE to work with new UTC menu option
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>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:    dteske
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 12 06:10:11 UTC 2012
>Closed-Date:    Mon Mar 04 11:14:33 UTC 2013
>Last-Modified:  Mon Mar 04 11:14:33 UTC 2013
>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@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:
State-Changed-From-To: open->patched 
State-Changed-By: emaste 
State-Changed-When: Wed Jan 18 04:37:38 UTC 2012 
State-Changed-Why:  
Committed as r230299. 


Responsible-Changed-From-To: freebsd-bugs->emaste 
Responsible-Changed-By: emaste 
Responsible-Changed-When: Wed Jan 18 04:37:38 UTC 2012 
Responsible-Changed-Why:  
Grab for MFC 

http://www.freebsd.org/cgi/query-pr.cgi?pr=164042 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/164042: commit references a PR
Date: Wed, 18 Jan 2012 04:37:44 +0000 (UTC)

 Author: emaste
 Date: Wed Jan 18 04:37:35 2012
 New Revision: 230299
 URL: http://svn.freebsd.org/changeset/base/230299
 
 Log:
   Fix #ifdef VERBOSE for UTC case
   
   Update verbose output to match what actually happens when selecting
   the UTC option, and when the -n option is used.
   
   Patch updated slightly for new libdialog.
   
   PR:		bin/164042
   Submitted by:	Devin Teske <dteske vicor com>
   MFC after:	2 weeks
 
 Modified:
   head/usr.sbin/tzsetup/tzsetup.c
 
 Modified: head/usr.sbin/tzsetup/tzsetup.c
 ==============================================================================
 --- head/usr.sbin/tzsetup/tzsetup.c	Wed Jan 18 04:37:17 2012	(r230298)
 +++ head/usr.sbin/tzsetup/tzsetup.c	Wed Jan 18 04:37:35 2012	(r230299)
 @@ -659,16 +659,19 @@ install_zoneinfo_file(const char *zonein
  		copymode = 1;
  
  #ifdef VERBOSE
 -	if (copymode)
 +	snprintf(title, sizeof(title), "Info");
 +	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);
 +		dialog_msgbox(title, prompt, 8, 72, 1);
  	else
  		fprintf(stderr, "%s\n", prompt);
  #endif
 @@ -699,6 +702,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);
  		}
  
 @@ -797,23 +804,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);
  }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: emaste->dteske 
Responsible-Changed-By: emaste 
Responsible-Changed-When: Mon Apr 9 13:20:55 UTC 2012 
Responsible-Changed-Why:  
Submitter is becoming a committer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=164042 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/164042: commit references a PR
Date: Sun,  3 Mar 2013 19:20:43 +0000 (UTC)

 Author: dteske
 Date: Sun Mar  3 19:20:30 2013
 New Revision: 247727
 URL: http://svnweb.freebsd.org/changeset/base/247727
 
 Log:
   MFC r230299:
   
   Fix #ifdef VERBOSE for UTC case
   
   Update verbose output to match what actually happens when selecting
   the UTC option, and when the -n option is used.
   
   Patch updated slightly for new libdialog.
   
   PR:		bin/164042
   Submitted by:	dteske
 
 Modified:
   stable/9/usr.sbin/tzsetup/tzsetup.c
 
 Modified: stable/9/usr.sbin/tzsetup/tzsetup.c
 ==============================================================================
 --- stable/9/usr.sbin/tzsetup/tzsetup.c	Sun Mar  3 19:12:07 2013	(r247726)
 +++ stable/9/usr.sbin/tzsetup/tzsetup.c	Sun Mar  3 19:20:30 2013	(r247727)
 @@ -33,7 +33,7 @@
   */
  
  #include <sys/cdefs.h>
 -__FBSDID("$FreeBSD$"); 
 +__FBSDID("$FreeBSD$");
  
  #include <err.h>
  #include <errno.h>
 @@ -659,16 +659,19 @@ install_zoneinfo_file(const char *zonein
  		copymode = 1;
  
  #ifdef VERBOSE
 -	if (copymode)
 +	snprintf(title, sizeof(title), "Info");
 +	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);
 +		dialog_msgbox(title, prompt, 8, 72, 1);
  	else
  		fprintf(stderr, "%s\n", prompt);
  #endif
 @@ -699,6 +702,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);
  		}
  
 @@ -797,23 +804,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);
  }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/164042: commit references a PR
Date: Mon,  4 Mar 2013 01:32:32 +0000 (UTC)

 Author: dteske
 Date: Mon Mar  4 01:32:24 2013
 New Revision: 247747
 URL: http://svnweb.freebsd.org/changeset/base/247747
 
 Log:
   MFC r230299:
   
   Fix #ifdef VERBOSE for UTC case
   
   Update verbose output to match what actually happens when selecting
   the UTC option, and when the -n option is used.
   
   Patch updated slightly for new libdialog.
   
   PR:		bin/164042
   Submitted by:	dteske
 
 Modified:
   stable/8/usr.sbin/tzsetup/tzsetup.c
 
 Modified: stable/8/usr.sbin/tzsetup/tzsetup.c
 ==============================================================================
 --- stable/8/usr.sbin/tzsetup/tzsetup.c	Mon Mar  4 01:22:07 2013	(r247746)
 +++ stable/8/usr.sbin/tzsetup/tzsetup.c	Mon Mar  4 01:32:24 2013	(r247747)
 @@ -544,16 +544,19 @@ install_zoneinfo_file(const char *zonein
  		copymode = 1;
  
  #ifdef VERBOSE
 -	if (copymode)
 +	snprintf(title, sizeof(title), "Info");
 +	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);
 +		dialog_mesgbox(title, prompt, 8, 72);
  	else
  		fprintf(stderr, "%s\n", prompt);
  #endif
 @@ -584,6 +587,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);
  		}
  
 @@ -682,23 +689,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_mesgbox(title, prompt, 8, 72);
 -	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_mesgbox(title, prompt, 8, 72);
 +		else
 +			fprintf(stderr, "%s\n", prompt);
  #endif
 +	} /* reallydoit */
  
  	return (DITEM_LEAVE_MENU);
  }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: dteske 
State-Changed-When: Mon Mar 4 11:12:52 UTC 2013 
State-Changed-Why:  
MFC'd to stable/9 and stable/8 with r247727 

http://www.freebsd.org/cgi/query-pr.cgi?pr=164042 
>Unformatted:
