Commit Graph

301 Commits

Author SHA1 Message Date
Vito Caputo 43fe4f7613 timedate: switch to BusLocator-oriented helpers
Mechanical substitution reducing some verbosity
2020-05-07 08:46:44 -07:00
Zbigniew Jędrzejewski-Szmek c4b7d95c46 timedated: convert to the new scheme and add --bus-introspect 2020-05-05 22:34:37 +02:00
Zbigniew Jędrzejewski-Szmek d4cc0edfce importd,logind: add --bus-introspect= option 2020-05-05 22:34:17 +02:00
Zbigniew Jędrzejewski-Szmek fc021a5bbf logind,importd,hostnamed,localed,timedated,machined,resolved: add option parsing stubs
--help and --version are implemented in the usual style.
help() prints full path, since the program is not expected to
be in $PATH.
2020-05-03 10:55:51 +02:00
Lennart Poettering ac9f55ed40 tree-wide: implement new log control API dbus interface in all our daemons 2020-04-21 17:08:16 +02:00
Zbigniew Jędrzejewski-Szmek 599c99ee3b timedated: add dbus parameter names 2020-04-12 19:48:01 +02:00
Lennart Poettering 269e4d2d6b shared: split out polkit stuff from bus-util.c → bus-polkit.c
It's enough, complex stuff to warrant its own source file.

No other changes, just splitting out.
2020-01-22 12:34:10 +01:00
Lennart Poettering 04d8507f68
Merge pull request #14381 from keszybz/ifindex-cleanup
Resolve alternative names
2020-01-13 17:57:59 +01:00
Zbigniew Jędrzejewski-Szmek 9030b50a7b timedatectl: drop ifindex output parameter too 2020-01-11 12:07:28 +01:00
Zbigniew Jędrzejewski-Szmek 597da51bae tree-wide: make parse_ifindex simply return the index
We don't need a seperate output parameter that is of type int.  glibc() says
that the type is "unsigned", but the kernel thinks it's "int".  And the
"alternative names" interface also uses ints. So let's standarize on ints,
since it's clearly not realisitic to have interface numbers in the upper half
of unsigned int range.
2020-01-11 12:06:08 +01:00
Yu Watanabe bd17fa8cd8 tree-wide: use table_log_add_error() 2020-01-10 18:28:30 +09:00
Yu Watanabe cf57766d79 timedatectl: use format-table.[ch] 2020-01-09 15:40:50 +01:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Lennart Poettering a650e19820
Merge pull request #14010 from poettering/localtime-symlink
tweaks to /etc/localtime management
2019-11-13 16:38:41 +01:00
Lennart Poettering 437f48a471 tree-wide: fix how we set $TZ
According to tzset(3) we need to prefix timezone names with ":". Let's
do so hence, to avoid any ambiguities and follow documented behaviour.
2019-11-13 12:30:22 +01:00
Lennart Poettering 5322db0651 timedated: it might be that tzinfo files are just not installed 2019-11-13 10:39:14 +01:00
Lennart Poettering 9193af0f05 timedated: handle UTC specially, when generating /etc/localtime 2019-11-13 10:39:14 +01:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Zbigniew Jędrzejewski-Szmek ce2529b4a2 Highlight the synopsis and summary in --help
This doesn't cover all the binaries, but I don't know how to script
this, and I run out of steam ;)
2019-10-08 18:21:27 +02:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Zbigniew Jędrzejewski-Szmek 0957790b5f timedated: always enable&start the service with highest priority
This removes a special case that was implemented before: if some service
was already enabled, we'd treat it as having higher priority.

From https://bugzilla.redhat.com/show_bug.cgi?id=1735584#c4:
> Setting ntp off and on should give the same result as just setting it
> on. There should be no stickiness (hidden state). It should behave like
> running an ansible role.
>
> The other service might have been enabled because no other was installed at
> the time. If I install a new NTP service with a higher priority, setting ntp
> on should enable and start the new service, and disable all other. Also, if
> for some reason multiple services are enabled, after setting ntp on there
> should be only one enabled to avoid systemd selecting between them randomly
> on the next boot.
2019-08-06 15:04:03 +02:00
Zbigniew Jędrzejewski-Szmek ad7fb9434c timedated: log about unit enablement actions and enhance logs in general
The general idea is that for things which can occur repeatedly, like SetNTP
being called with the same argument, we only log at debug level. For things
which change state, like when we realize that a unit that wasn't enabled
before needs to be enabled, we log at info level.

Also, don't return success if there are no units loaded.
2019-08-05 21:27:00 +02:00
Zbigniew Jędrzejewski-Szmek d9cb4bba20 timedated: minor code simplifications 2019-08-04 11:06:33 +02:00
Zbigniew Jędrzejewski-Szmek afaae43bb1 timedated: add back support for ntp-units.d/
We removed support for foreign services (and ntp-units.d/) in b72ddf0f4.
Support for foreign services was added back in 5d280742, but through an
environment variable.

The problem with the env var approach is that it only works as a mechanism
to select one item, and doesn't work nicely as a mechinism to create a list
of items through drop-ins (because the env var can be easily overridden, but not
extended). Having a list of "ntp providers" is important to be able to reliably disable
all of them when that is requested.

Another problem is that nobody ever bothered to care about our new "standard".
ntp-units.d/ is a nice simple format that works and is already supported by
chrony and ntpd and timedatex. If we were to introduce and ask people to follow
a new standard, there should be some good reason for this. The idea with env
vars has lower functionality, requires systemd-specific syntax. We should just
re-adopt the format that we originally introduced and that seems to work for
everyone, and more on to more interesting problems.
2019-07-22 15:21:20 +02:00
Yu Watanabe 159a855b34 timedatectl: add 'ntp-servers' and 'revert' commands to modify link NTP servers 2019-07-17 06:59:12 +09:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Zbigniew Jędrzejewski-Szmek 1a04395959 Enable log colors for most of tools in /usr/bin
When emitting the calendarspec warning we want to see some color.
Follow-up for 04220fda5c.

Exceptions:
- systemctl, because it has a lot hand-crafted coloring
- tmpfiles, sysusers, stdio-bridge, etc, because they are also used in
  services and I'm not sure if this wouldn't mess up something.
2019-05-08 09:50:21 +02:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Lennart Poettering 0a9707187b util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
2019-03-13 12:16:43 +01:00
Yu Watanabe 49942d6b1e timedate: fix emitted value when ntp client is enabled/disabled (#11951)
This fixes a regression originall caused by cf3872bd2 and
triggered by b4356b5720.

Fixes #11944
2019-03-10 20:44:21 +01:00
Yu Watanabe 102b021460 bus-util: drop unnecessary re-formatting 2019-03-04 23:35:46 +09:00
Yu Watanabe b4356b5720 timedate: refuse to set time when previous request is not finished
If `timedatectl set-time` is invoked right after `timedatectl set-ntp true`,
then, the NTP service may not be started yet.

Fixes #11420.
2019-01-15 15:15:26 +09:00
Yu Watanabe 84a87726ee timedate: treat 'activating' or 'inactivating' NTP client status as 'active'
When `timedatectl set-time` is called, NTP client may be in
'activating' or something. For safety, let's treat such states as
'active'.

This also changes all unit file status except for 'masked' or 'disabled'
are treated as 'enabled'.
2019-01-15 14:44:32 +09:00
tibbling 2cf0b2fe2d timedated: Add dbus method to retrieve list of time zones (#11114)
Move function call get_timezones from timedatectl to timedated and
create a dbus method to list timezones.
2018-12-12 20:49:04 +01:00
Yu Watanabe 36dd5ffd5d util: drop missing.h from util.h 2018-12-04 10:00:34 +01:00
Lennart Poettering e4de72876e util-lib: split out all temporary file related calls into tmpfiles-util.c
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.

No code changes, just some rearranging of source files.
2018-12-02 13:22:29 +01:00
Yu Watanabe 1f47bc3349 timedate: define main through macro 2018-11-23 06:22:30 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Zbigniew Jędrzejewski-Szmek 50378e5d97 timedatectl: define main through macro
pager_close() is called from DEFINE_MAIN_FUNCTION().
2018-11-20 16:48:21 +01:00
Lennart Poettering 6bf3c61c57 log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.
2018-11-20 11:18:22 +01:00
Lennart Poettering 042cad5737
Merge pull request #10753 from keszybz/pager-no-interrupt
Add mode in journalctl where ^C is handled by the pager
2018-11-14 20:09:39 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Lennart Poettering 4b670f8688 hostnamed,localed,timedate: properly propagate errors from sd_event_add_signal()
main() can't doesn't expect negative error codes as return.
2018-11-12 17:51:34 +01:00
Yu Watanabe eda193578e bus-util: make --property= optionally take value 2018-09-12 12:11:25 +09:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Yu Watanabe cf3872bd28 timedate: emit property changed signal after all jobs are completed
Follow-up for 3af0a96c0f (#9684).
2018-08-08 14:32:28 +02:00
Yu Watanabe 4ae25393f3 tree-wide: shorten error logging a bit
Continuation of 4027f96aa0.
2018-08-07 10:14:33 +09:00
Yu Watanabe 3af0a96c0f timedate: defer the property changed signal until job of starting/stopping NTP service is finished
Before this, the property changed signal is emitted immediately after
StartUnit/StopUnit method is called. So, the running state of the NTP
client service may not updated.
This makes the timing of emitting property changed signal is deferred
until job of starting/stopping NTP client service is completed.

Fixes #9672.
2018-07-26 12:13:35 +09:00
Yu Watanabe 2770af85ac timedate: increment reference count of sd_bus_message
The commit 5d280742b6 introduces a
barrier to suppress calling context_update_ntp_status() multiple times.
However, it just stores the address of sd_bus_message object. So,
when an address is reused on the subsequent message, then the status
of NTP clients are not updated.

This makes the stored message object is referenced by the context
object. So, the subsequent message is on cirtainly different address.
2018-07-26 12:13:35 +09:00