Commit Graph

76 Commits

Author SHA1 Message Date
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Yuri Pankov
bb255cee93 tzsetup: fix "misleading indentation" warning with -DVERBOSE 2023-07-26 12:33:42 +02:00
Yuri Pankov
08ed87514f tzsetup: appease checkstyle9 2023-04-27 20:29:55 +02:00
Yuri Pankov
cfd0217aa9 tzsetup: adopt zone1970.tab changes
- assumption that single-zone countries do not have description
  is no longer correct; do not try to optimize this case as it's
  only going to make the code more confusing and we now have menus
  with a single zone selection because of this
- remove the single-country continent short cut, it also only serves
  to confuse users as we now have such a continent
- instead add a single-zone contry short cut (see above), now all
  single-zone countries fall here
- use the #@ continent overrides that zone1970.tab introduces (this is
  visible at least fixing Iceland being currently listed under Africa)
- add Arctic Ocean "continent" coming only from the overrides at the
  moment
- update baseline with the changes

Reviewed by:	bapt, philip
Differential Revision:	https://reviews.freebsd.org/D39606
2023-04-27 19:31:48 +02:00
Yuri Pankov
989a0e1d81 tzsetup: fix bootstrapping for github CI jobs
Move dump_zonetab() under HAVE_BSDDIALOG as the parsing code
it relies on already is.
2023-04-26 14:29:08 +02:00
Yuri Pankov
336c4682b6 tzsetup: add baseline file to control parsed zonetab contents
Introduce undocumented option -d to dump parsed zonetab file contents
and add a "baseline" target along with instructions on updating it.

Reviewed by:	philip
Differential Revision:	https://reviews.freebsd.org/D39634
2023-04-23 10:32:02 +02:00
Alfonso S. Siciliano
94cb21cda6
tzsetup(8): Refactoring to delete dialog(3) code
Little refactoring to complete the conversion to bsddialog(3),
not functional changes:

 * Delete: remaining code for autosizing using BSDDIALOG_AUTOSIZE.
 * Add: constants to delete magical numbers and to avoid unclear
   returned values.
 * Delete: redundant 'conf.button.default_cancel=false', performed by
   bsddialog_initconf().
 * Add: a new function message_zoneinfo_file() to merge features.

Approved by:		bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D34862
2022-04-12 00:38:40 +02:00
Alfonso Siciliano
263660c061 bsddialog: import version 0.1
Import bsddialog 0.1 Utility and Library, fully refatorized, API stable,
manuals completed, easier to maintain and improve.

Update deps for new API:
add mixedgauge consts, delete __DECONST and add bsddialog_geterror()
info to avoid silent errors

* tzsetup
* kbdmap
* distextract

Differential Revision:	https://reviews.freebsd.org/D34066
2022-01-28 09:56:21 +01:00
Alfonso Siciliano
be0236ebd8 tzsetup: Fix unicode support
Differential revision:	https://reviews.freebsd.org/D33532
2021-12-17 09:25:07 +01:00
Alfonso Siciliano
0a7e19b30f tzsetup: adapt for libbsddialog 0.0.1
libbsdialog 0.0.1 provides:
* bsddialog_conf.auto_minwidth:
* menurows is variable with autosize (properly defines max menurows)

Then tzsetup can use BSDDIALOG_AUTOSIZE keeping the dialog behavior:
min 24 cols, max 16 menurows

Differential revision:	https://reviews.freebsd.org/D33397
2021-12-13 09:07:47 +01:00
Emmanuel Vadot
547fc67fec tzsetup: Default to UTC
Restore old behavior.

Fixes:	f872dde34c ("tzsetup: replace libdialog with libbsddialog")

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D33334
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2021-12-08 14:39:00 +01:00
Baptiste Daroussin
f499134dd4 bsddialog: import snapshot 2021-12-05 2021-12-06 11:43:34 +01:00
Baptiste Daroussin
6ea39dd6c7 tzsetup: remove dedundant declaration 2021-11-24 11:12:05 +01:00
Baptiste Daroussin
f872dde34c tzsetup: replace libdialog with libbsddialog
Reviewed by: alfix86_gmail.com (bsddialog author)
Differential Revision: https://reviews.freebsd.org/D33077
2021-11-24 11:03:33 +01:00
Warner Losh
7047dceee3 Remove sparc64 ifdef
Now we default to setting the hardware clock to UTC
everywhere. sparc64 was the old odd-man out before.

Reivewed by: cy@, bcr@
Differential Revision: https://reviews.freebsd.org/D23593
2020-02-10 17:16:41 +00:00
Thomas Munro
513419f404 tzsetup: upgrade to zone1970.tab
zone.tab is deprecated.  Install zone1970.tab alongside it, and use it
for tzsetup(8).  This is also useful for other applications that need
the modern better maintained file.

Reviewed by: philip
Approved by: allanjude (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20646
2019-07-17 06:17:27 +00:00
Xin LI
963aa85d2a In read_zones(), check if the file name actually fit in the buffer
and make sure it would terminate with nul with strlcpy().

Reviewed by:	imp (earlier revision)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16595
2018-08-09 02:47:22 +00:00
Marius Strobl
eabfbad050 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).
2017-08-07 21:38:10 +00:00
Marius Strobl
4b38286169 - Move creation and unlinking of /etc/wall_cmos_clock from the handling
of the initial UTC dialog to install_zoneinfo() so that file gets the
  necessary treatment also when that dialog is skipped via "-s", when
  selecting UTC from the time zone menu or on the command-line instead
  etc.
- Make the initial UTC dialog actually work by giving the relevant files
  the necessary treatment and then exit when choosing "Yes" there instead
  of moving on to the time zone menu regardless.
- Since r301131, /etc/localtime is also installed when selecting UTC in
  interactive configurations (which previously meant only via the time
  zone menu, though). Thus, the code added in r230298 which treats a
  NULL zone file name as UTC and removes /etc/localtime in that case can
  go again.
- Consistently refer to "could not delete" (as chosen by the oldest such
  code in here) when unlink(2) fails instead of a to mixture of "delete"
  and "unlink" in error messages.
2017-08-05 12:59:03 +00:00
Baptiste Daroussin
4fe54d4279 Fix build of tzsetup when WITHOUT_DIALOG is set
Hide dialog specific code behind HAVE_DIALOG. It allows to build a stripped
down version (missing the dialog UI) but perfectly function tzsetup when
world is built WITHOUT_DIALOG

Reorganise a bit the code to limit the number of blocks under HAVE_DIALOG

Reviewed by:	emaste
Sponsored by:	https://reviews.freebsd.org/D8325
2016-10-22 22:35:39 +00:00
Steven Hartland
dc30160e1a Fix tzsetup not installing /etc/localtime for UTC
If tzsetup UTC is run then it successfully configured the system for UTC
including installing /etc/localtime however if the user ran just tzsetup
for interactive configuration and select UTC no /etc/localtime was installed
which resulted in failures for utilities which require said file.

Change set_zone_utc to call install_zoneinfo("UTC") to ensure that
/etc/localtime is created for interactive UTC selection.

Users who have previously run tzsetup in interactive mode and select UTC
can install the missing /etc/localtime by running tzsetup -r.

Also correct static miss-match for set_zone_utc.

MFC after:	2 weeks
Relnotes:	Yes
Sponsored by:	Multiplay
2016-06-01 15:39:11 +00:00
Don Lewis
ee67f7cc77 Avoid buffer overflow or truncation when constructing path_zoneinfo_file.
Reported by:	Coverity
CID:		1011160
MFC after:	1 week
2016-05-26 01:45:04 +00:00
Marcelo Araujo
b916534496 Use NULL instead of 0 for pointers.
fgetln(3) will returns NULL if cannot get a line from a stream.
strsep(3) it will returns NULL if the end of the string was reached.
jemalloc(3) malloc will returns NULL if it cannot allocate memory.
fgetln(3) it will returns NULL if it cannot get a line from a stream.

MFC after:	4 weeks
2016-04-15 04:10:47 +00:00
Xin LI
427c435f64 Revert r289269 for now. After looking at share/zoneinfo/Makefile this could
potentially break non-root installs and we need a better solution, probably
by doing it differently when no UI is involved.
2015-10-27 01:26:50 +00:00
Xin LI
a2668e8128 Use chroot(2) instead of using prefixes for files.
Previously, the code prefixes the chroot path to actual file paths to
simulate the effect.  This, however, will not work for tzset(3) which
expects the current system have a working set of timezone data files,
and that is not always the case.

This changeset simplifies the handling of paths and use an actual
chroot(2) call to implement the effect.

PR:		bin/197313
MFC after:	2 weeks
2015-10-13 22:55:17 +00:00
Eitan Adler
b1abc63706 tzsetup: remove set but unused variable
- leave a comment explaining which variable it used to be

Reported by:	gcc5.1
2015-04-19 08:45:37 +00:00
Devin Teske
7e31e02573 Fix whitespace.
Thanks to:	nwhitehorn
2014-11-11 19:45:14 +00:00
Devin Teske
e91afc1cda Default bsdconfig timezone' and tzsetup' to `-s' in a VM.
Recommended by:	cperciva
Reviewed by:	cperciva
Relnotes:	tzsetup and bsdconfig now assume that the "hardware" clock inside a VM is set to UTC
2014-11-11 19:37:17 +00:00
Devin Teske
d2dc532df5 Fix VERBOSE reporting on results when removing _PATH_LOCALTIME for UTC option.
PR:		bin/164976
Submitted by:	dteske
2013-03-04 11:34:31 +00:00
Garrett Wollman
41b549dc80 It's not an error if unlink(2) fails because the pathname doesn't exist.
Noticed by: kevlo
Pointy hat to: wollman
2012-02-08 05:03:04 +00:00
Ed Maste
3129859c92 Clean up reinstall option and remove duplicate code
- Move the reinstall logic to be before menus are initialised
  (menus are not needed when reinstalling a zonefile).

- Remove unnecessary re-initialization of path_db.

- Update variable name and error message because we now use the
  zone name relative to /usr/share/zoneinfo, not the full path.

pr:		bin/164041
Submitted by:	Devin Teske <dteske vicor com>
MFC after:	1 week
2012-01-25 02:15:40 +00:00
Ed Maste
da4b02cf70 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
2012-01-18 04:37:35 +00:00
Ed Maste
e202760872 Don't write /var/db/zoneinfo when zone is not actually changed.
If the specified zone file does not exist or the -n flag is specified,
do not update /var/db/zoneinfo.

PR:		bin/164039
Submitted by:	Devin Teske <dteske vicor com>
MFC after:	1 week
2012-01-18 04:12:32 +00:00
Garrett Wollman
8c261aeac3 Use a reasonable-sized buffer when formatting error messages about
installing zoneinfo.  While we're in the vicinity, add some missing
error checking to eliminate an unhelpful error message when unlink()
fails.

/me is embarrassed by the quality of his 16-year-old code.
The whole thing is awful and could stand a complete rewrite.

PR:		164038
Submitted by:	Devin Teske (but implemented differently)
2012-01-12 05:50:32 +00:00
Max Khon
fcc050e759 Sync xdialog_menu() implementation with sade. 2011-12-01 09:02:57 +00:00
Max Khon
8396c7de45 calloc +1 DIALOG_LISTITEM to prevent possible wild pointer access
in dlg_default_listitem().
2011-11-24 18:45:23 +00:00
Max Khon
3567b2c445 Port to new libdialog. 2011-11-24 13:24:06 +00:00
Doug Barton
983ac1b7fc If the user is moving from any other time zone to UTC we need
to delete any old /var/db/zoneinfo file that may exist so that
tzsetup -r does the right thing.
2011-11-02 04:21:20 +00:00
Ruslan Ermilov
81046d3cb3 - add missing options and arguments to program's usage()
and sync it with manpage's SYNOPSIS

- generally clean up a manpage's formatting

Reviewed by:	edwin
2011-05-20 17:35:10 +00:00
Edwin Groothuis
75a59404d5 Add a menu entry for UTC in the main menu.
PR:		bin/156019
Submitted by:	Daniel O'Conner
Reviewed by:	Garrett Cooper <gcooper@FreeBSD.org>
MFC after:	1 week
2011-03-30 21:33:23 +00:00
Norikatsu Shigemura
33ac3bc5a2 Fix support for chrooted installs.
Approved by:	imp (mentor)
2010-07-19 16:38:45 +00:00
Ed Maste
781e51d3eb Use literal format strings. Found by clang. 2010-06-14 23:51:35 +00:00
Edwin Groothuis
7ba8f7307a Add comment that this value is unused.
It is obvious that it isn't used, but both clang and Coverity talk about it.

Found with:   Coverity Prevent(tm)
CID:          8066
2010-06-05 12:53:44 +00:00
Edwin Groothuis
3b8d8bd75e When there is a problem with writing, also bail out.
Found with the clang checker.
2010-06-05 12:49:39 +00:00
Edwin Groothuis
b5f58d7778 - Add support for chrooted installs.
- Add examples to the man-page.

MFC after:	1 week
2009-10-21 20:55:04 +00:00
Edwin Groothuis
ada5f18a1b Instead of having to know which timezone was picked last time, you
now can run "tzsetup -r" which will reinstall the last choice. This
data is recorded in /var/db/zoneinfo.

MFC after:	 1 week
2009-10-20 06:54:31 +00:00
Edwin Groothuis
08c7e8c879 When tzsetup is run as non-root and the "CMOS clock question on
UTC" is answered as No, it would abort without properly ending the
dialog session.

MFC after:	 1 week
2009-10-19 21:24:19 +00:00
Attilio Rao
5d279e6530 Add a new options (-s) that, when specified, skips the question about
adjusting the clock to UTC.
That avoids to write on /etc/wall_cmos_clock which is useful in some
cases (example: host user in a jail).

Sponsored by:	Sandvine Incorporated
Initially submitted by:	Matt Koivisto <mkoivisto at sandvine dot com>
Approved by:	re (kib)
2009-07-04 11:11:21 +00:00
Jung-uk Kim
659a596a2c - Replace rcsid with __FBSDID.
- Remove paths.h and embed it in the source.
- Remove stale alpha support.
- Clean up compiler warnings and fix style(9) bugs.
2008-06-03 22:34:52 +00:00
Jung-uk Kim
62467b2549 Fix a crash when Arctic Ocean is selected.
MFC after:	1 week
2008-06-02 23:37:33 +00:00