Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174661273
D52247.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D52247.id.diff
View Options
diff --git a/usr.sbin/tzsetup/tzsetup.8 b/usr.sbin/tzsetup/tzsetup.8
--- a/usr.sbin/tzsetup/tzsetup.8
+++ b/usr.sbin/tzsetup/tzsetup.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 14, 2024
+.Dd August 29, 2025
.Dt TZSETUP 8
.Os
.Sh NAME
@@ -30,7 +30,7 @@
.Nd set local timezone
.Sh SYNOPSIS
.Nm
-.Op Fl nrs
+.Op Fl Nnrs
.Op Fl C Ar chroot_directory
.Op Ar zoneinfo_file | zoneinfo_name
.Sh DESCRIPTION
@@ -51,6 +51,9 @@
.It Fl C Ar chroot_directory
Open all files and directories relative to
.Ar chroot_directory .
+.It Fl N
+Do not create
+.Pa /etc/localtime .
.It Fl n
Do not create or symlink files.
.It Fl r
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -37,21 +37,21 @@
* no unintended changes and commit updated file.
*/
-#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/fcntl.h>
+#include <sys/queue.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+
#include <err.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-
#ifdef HAVE_BSDDIALOG
#include <bsddialog.h>
#include <locale.h>
@@ -82,8 +82,9 @@
path_zoneinfo[MAXPATHLEN], path_localtime[MAXPATHLEN],
path_db[MAXPATHLEN], path_wall_cmos_clock[MAXPATHLEN];
-static int reallydoit = 1;
-static int reinstall = 0;
+static bool dryrun = false;
+static bool noinstall = false;
+static bool reinstall = false;
static char *chrootenv = NULL;
static void usage(void);
@@ -746,13 +747,16 @@
{
char prompt[SILLY_BUFFER_SIZE];
+ if (noinstall)
+ return (DITEM_LEAVE_MENU);
+
#ifdef VERBOSE
snprintf(prompt, sizeof(prompt), "Creating symbolic link %s to %s",
path_localtime, zoneinfo_file);
message_zoneinfo_file("Info", prompt);
#endif
- if (reallydoit) {
+ if (!dryrun) {
if (access(zoneinfo_file, R_OK) != 0) {
snprintf(prompt, sizeof(prompt),
"Cannot access %s: %s", zoneinfo_file,
@@ -794,13 +798,14 @@
FILE *f;
char path_zoneinfo_file[MAXPATHLEN];
+ /* Install the symlink */
if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
- "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
+ "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo);
rv = install_zoneinfo_file(path_zoneinfo_file);
/* Save knowledge for later */
- if (reallydoit && (rv & DITEM_FAILURE) == 0) {
+ if (!dryrun && (rv & DITEM_FAILURE) == 0) {
if ((f = fopen(path_db, "w")) != NULL) {
fprintf(f, "%s\n", zoneinfo);
fclose(f);
@@ -814,7 +819,7 @@
usage(void)
{
- fprintf(stderr, "usage: tzsetup [-nrs] [-C chroot_directory]"
+ fprintf(stderr, "usage: tzsetup [-Nnrs] [-C chroot_directory]"
" [zoneinfo_file | zoneinfo_name]\n");
exit(1);
}
@@ -843,7 +848,7 @@
strcmp(vm_guest, "none") != 0)
skiputc = 1;
- while ((c = getopt(argc, argv, "C:d:nrs")) != -1) {
+ while ((c = getopt(argc, argv, "C:d:Nnrs")) != -1) {
switch (c) {
case 'C':
chrootenv = optarg;
@@ -851,11 +856,14 @@
case 'd':
dztpath = optarg;
break;
+ case 'N':
+ noinstall = true;
+ break;
case 'n':
- reallydoit = 0;
+ dryrun = true;
break;
case 'r':
- reinstall = 1;
+ reinstall = true;
#ifdef HAVE_BSDDIALOG
usedialog = 0;
#endif
@@ -894,7 +902,7 @@
/* Override the user-supplied umask. */
(void)umask(S_IWGRP | S_IWOTH);
- if (reinstall == 1) {
+ if (reinstall) {
FILE *f;
char zoneinfo[MAXPATHLEN];
@@ -959,10 +967,10 @@
conf.title = "Select local or UTC (Coordinated Universal Time) clock";
if (bsddialog_yesno(&conf, prompt, 7, 73) == BSDDIALOG_YES) {
- if (reallydoit)
+ if (!dryrun)
unlink(path_wall_cmos_clock);
} else {
- if (reallydoit) {
+ if (!dryrun) {
fd = open(path_wall_cmos_clock,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IRGRP | S_IROTH);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 6, 1:05 AM (22 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40221922
Default Alt Text
D52247.id.diff (4 KB)
Attached To
Mode
D52247: tzsetup: Add an option to not create the symlink
Attached
Detach File
Event Timeline
Log In to Comment