Commit Graph

265 Commits

Author SHA1 Message Date
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
Yu Watanabe 754f026935 timedate: set sd_event_add_signal() 2018-07-20 14:59:23 +09:00
Yu Watanabe e0f691e1fd tree-wide: use localtime_r() instead of localtime()
Follow-up for e46acb7950.
2018-06-26 14:26:39 +09:00
Lennart Poettering e46acb7950 timedate: use gmtime_r() and localtime_r()
gmtime() and localtime() operate on a static buffer. let's avoid this,
as we never know whether some library might use these calls in some
backrgound thread.

Discovered by lgtm:

https://lgtm.com/projects/g/systemd/systemd/
2018-06-25 19:20:34 +02:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Yu Watanabe ead0adb161 timedatectl: add 'show' command to display machine-readable output
Closes #9249.
2018-06-14 10:19:08 +02:00
Zbigniew Jędrzejewski-Szmek 5d904a6aaa tree-wide: drop !! casts to booleans
They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-13 10:52:40 +02:00
Zbigniew Jędrzejewski-Szmek a1230ff972 basic/log: add the log_struct terminator to macro
This way all callers do not need to specify it.
Exhaustively tested by running test-log under valgrind ;)
2018-06-04 13:46:03 +02:00
Lennart Poettering 2a7ff45f09 timedated: add some debug logging when a number of kernel calls fail 2018-05-29 16:33:06 +02:00
Lennart Poettering 8a50b96f81 timedated: show the short timezone name when changing timezones in logs 2018-05-29 16:31:18 +02:00
Lennart Poettering 0612ac38a7
Merge pull request #8985 from yuwata/bus-macro-3
tree-wide: use BUS_DEFINE_PROPERTY_GET* macros
2018-05-18 20:25:52 +02:00
Lennart Poettering b391a5f5d5
Merge pull request #9002 from yuwata/fix-timedate
Fixes timedated and cleanups hostnamed
2018-05-17 10:38:37 -07:00
Yu Watanabe e610ac3d50 timedatectl: do not wrap polkit policy message
If messages are wrapped, then only the last line is shown in the
dialog, at least polkit gui for Xfce. It may be a bug of polkit or
Xfce. But it is not necessary to wrap the message in the policy
file. So, let's fix them.
2018-05-18 00:03:15 +09:00
Yu Watanabe 6cc379b573 timedate: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:07:02 +09:00
Yu Watanabe 539a68e0fb timedate: do not copy input string before bus_verify_polkit_async()
This fixes the commit 2c3def6214 which
breaks `timedatectl set-timezone` called by non-privileged user.
2018-05-15 22:53:42 +09:00
Mike Gilbert 089fb8653f basic: add log_level argument to timezone_is_valid 2018-05-12 15:20:13 -04:00
Yu Watanabe 2c3def6214 timedate: use free_and_strdup() 2018-05-10 00:59:47 +09:00
Yu Watanabe 6129ec852e timedatectl: add timesync-status and show-timesync commands
Closes #1589.
2018-05-03 18:07:43 +09:00
Tobias Jungel 201b26a344 remove unused variables (#8768)
clang 5.0 complains with -Wunused-variable
2018-04-20 13:31:17 +02:00
Yu Watanabe f567f086d2 timedatectl: update output format of status command 2018-04-17 14:12:49 +09:00
Yu Watanabe 5d280742b6 timedated: support multiple NTP services
Support for alternative NTP services was dropped by b72ddf0f4f.
This makes timedated re-support alternative NTP services.

Closes #8402. Also, fixes #1329.
2018-04-17 14:09:13 +09:00
Yu Watanabe e9e5ea880a timedate: use sd_bus_error_set() if nothing is substituted 2018-04-17 14:05:27 +09:00
Yu Watanabe 07411fd3bd timedate: move error mapping to bus-common-errors.[ch] 2018-04-17 14:03:25 +09:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Yu Watanabe a7e4861c74 bus-util: add flags for bus_map_all_properties() (#8546)
This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL.
If BUS_MAP_STRDUP is set, then each "s" message is duplicated.
If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is
written to a bool pointer.

Follow-up for #8488.
See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.
2018-03-28 13:37:27 +02:00
Yu Watanabe f37f8a61c0 bus-util: make bus_map_all_properties() not copy string 2018-03-20 00:42:48 +09:00
Yu Watanabe ee5324aa04 tree-wide: voidify pager_open()
Even if pager_open() fails, in general, we should continue the operations.
All erroneous cases in pager_open() show log message in the function.
So, it is not necessary to check the returned value.
2018-03-19 21:04:02 +09:00
Yu Watanabe be90a88654 timedatectl: use dispatch_verb() 2018-03-19 21:04:02 +09:00
Zbigniew Jędrzejewski-Szmek 9b3cff199d meson: drop unnecessary "transformation" of policy files
Those files don't contain any @variables@, so the configuration step was just
copying them to build/. Let's avoid that, and fix their suffixes while at it.
2018-02-16 13:01:12 +01:00
Gunnar Hjalmarsson 264d8dcc16 Gettextize policy files
* Don't merge translations into the files
* Add gettext-domain="systemd" to description and message

Closes #8162, replaces #8118.
2018-02-16 13:00:52 +01:00
Zbigniew Jędrzejewski-Szmek 87ac8d998f tree-wide: use "cannot" instead of "can not"
This is the usual spelling, and a bit shorter.
2018-02-08 10:34:52 +01:00
Franck Bui 0a84daa5aa Comment the fact that some tools need to termintate their bus connect first 2018-01-12 16:20:36 +01:00