summaryrefslogtreecommitdiff
path: root/src/timedate
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_IDZbigniew Jędrzejewski-Szmek2017-02-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Embedding sd_id128_t's in constant strings was rather cumbersome. We had SD_ID128_CONST_STR which returned a const char[], but it had two problems: - it wasn't possible to statically concatanate this array with a normal string - gcc wasn't really able to optimize this, and generated code to perform the "conversion" at runtime. Because of this, even our own code in coredumpctl wasn't using SD_ID128_CONST_STR. Add a new macro to generate a constant string: SD_ID128_MAKE_STR. It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition of the numbers, but in practice it is more convenient to use, and allows gcc to generate smarter code: $ size .libs/systemd{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/systemd.old 1260268 149564 4808 1414640 1595f0 .libs/systemd 246805 13852 209 260866 3fb02 .libs/systemd-logind.old 240973 13852 209 255034 3e43a .libs/systemd-logind 146839 4984 34 151857 25131 .libs/systemd-journald.old 146391 4984 34 151409 24f71 .libs/systemd-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/systemd.old|grep MESSAGE_ID MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x $ strings .libs/systemd|grep MESSAGE_ID MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27 MESSAGE_ID=b07a249cd024414a82dd00cd181378ff MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7 MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f MESSAGE_ID=d34d037fff1847e6ae669a370e694725 MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5 MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7 MESSAGE_ID=39f53479d3a045ac8e11786248231fbf MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d MESSAGE_ID=7b05ebc668384222baa8881179cfda54 MESSAGE_ID=9d1aaa27d60140bd96365438aad20286
* tree-wide: make bus_map_all_properties return a proper sd_bus_errorLennart Poettering2017-02-091-1/+4
| | | | | | | | And then show it, to make things a bit friendlier to the user if we fail acquiring some props. In fact, this fixes a number of actual bugs, where we used an error structure for output that we actually never got an error in.
* Add enable_disable() helperZbigniew Jędrzejewski-Szmek2016-07-311-1/+1
| | | | | In this patch "enabled" and "disabled" is used exclusively, but "enable" and "disable" forms are need for the following patch.
* sd-bus: make sure bus_map_all_properties() handle booleans rightLennart Poettering2016-06-211-4/+4
| | | | | | | | | | sd-bus generally exposes bools as "int" instead of "bool" in the public API. This is relevant when unmarshaling booleans, as the relevant functions expect an int* pointer and no bool* pointer. Since sizeof(bool) is not necessarily the same as sizeof(int) this is problematic and might result in memory corruption. Let's fix this, and make sure bus_map_all_properties() handles booleans as ints, as the rest of sd-bus, and make all users of it expect the right thing.
* systemctl: make sure we terminate the bus connection first, and then close ↵Lennart Poettering2016-06-161-1/+2
| | | | | | | | | | | | | | | the pager (#3550) If "systemctl -H" is used, let's make sure we first terminate the bus connection, and only then close the pager. If done in this order ssh will get an EOF on stdin (as we speak D-Bus through ssh's stdin/stdout), and then terminate. This makes sure the standard error we were invoked on is released by ssh, and only that makes sure we don't deadlock on the pager which waits for all clients closing its input pipe. (Similar fixes for the various other xyzctl tools that support both pagers and -H) Fixes: #3543
* tree-wide: use ansi_highlight() instead of ANSI_HIGHLIGHT where appropriateLennart Poettering2016-05-301-7/+7
| | | | Let's make sure SYSTEMD_COLORS is honour by more tools
* selinux: always try to load the full selinux dbZbigniew Jędrzejewski-Szmek2016-03-011-1/+1
| | | | | https://github.com/systemd/systemd/pull/2508#issuecomment-190901170 Maybe fixes https://bugzilla.redhat.com/show_bug.cgi?id=1308771.
* timedated: trivial stylistic fixMartin Pitt2016-02-291-2/+2
| | | | Don't use {} for single-line "then" blocks.
* Merge pull request #2749 from martinpitt/adjtimeZbigniew Jędrzejewski-Szmek2016-02-281-16/+30
|\
| * timedated: be more tolerant in parsing /etc/adjtimeMartin Pitt2016-02-261-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | Similarly to the previous commit, make context_write_data_local_rtc() understand /etc/adjtime files with just one or two lines, with or without a final newline. Normalize the file to the current definition in hwclock(8), in the spirit of "be liberal what you accept and strict what you produce": Add line terminators, and set the second line to "0" if missing. Fixes: #2638
| * clock-util: make clock_is_localtime() testable and add initial testsMartin Pitt2016-02-261-1/+1
|/ | | | | | | | | Add path argument to clock_is_localtime() and default to "/etc/adjtime" if it's NULL. This makes the function testable. Add test-clock: initial test cases for some scenarios, using a temporary file. This also checks the behaviour with a NULL (i. e. the system's /etc/adjtime) file.
* tree-wide: merge pager_open_if_enabled() to the pager_open()Alexander Kuleshov2016-02-261-9/+1
| | | | | | | | | Many subsystems define own pager_open_if_enabled() function which checks '--no-pager' command line argument and open pager depends on its value. All implementations of pager_open_if_enabled() are the same. Let's merger this function with pager_open() from the shared/pager.c and remove pager_open_if_enabled() from all subsytems to prevent code duplication.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-102-4/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-272-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering2015-10-271-0/+1
|
* util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering2015-10-271-10/+11
|
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* bus-util: rename bus_open_transport() to bus_connect_transport()Lennart Poettering2015-09-291-1/+1
| | | | | | | | | | | | | | In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus, while sd_bus_default_xyz() family tries to reuse the thread's default bus. bus_open_transport() sometimes internally uses the former, sometimes the latter family, but suggests it only calls the former via its name. Hence, let's avoid this confusion, and generically rename the call to bus_connect_transport(). Similar for all related calls. And while we are at it, also change cgls + cgtop to do direct systemd connections where possible, since all they do is talk to systemd itself.
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-9/+7
| | | | | | This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
* cgtop: underline table headerLennart Poettering2015-09-221-2/+2
| | | | | | Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
* bus-util: support details in CheckAuthorization callsMichael Chapman2015-09-061-0/+4
| | | | | | Extra details for an action can be supplied when calling polkit's CheckAuthorization method. Details are a list of key/value string pairs. Custom policy can use these details when making authorization decisions.
* time-util: add new get_timezone() call to get local timezoneLennart Poettering2015-08-261-25/+8
| | | | | Let's move the timedated-specific code to time-util.h and make it generic.
* timedatectl: when no timezone is set consider UTC the defaultLennart Poettering2015-08-201-1/+1
| | | | | This fixes #993, and ensures that the libc does not consider any old timezone information into account, that was set earlier.
* timedatectl: assert timezone is not null in setenv() call.Dimitri John Ledkov2015-08-191-1/+1
| | | | | | | | | | | | | setenv is declared as: extern int setenv (const char *__name, const char *__value, int __replace) __THROW __nonnull ((2)); And i->timezone can be NULL, if for example /etc/localtime is missing. Previously that worked, but now result in a libc dumping core, as seen with gcc 2.22, due to: https://sourceware.org/ml/glibc-cvs/2015-q2/msg00075.html
* sd-bus: introduce new sd_bus_flush_close_unref() callLennart Poettering2015-07-032-3/+3
| | | | | | | | | | | | | | | | sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush() (which writes all unwritten messages out) + sd_bus_close() (which terminates the connection, releasing all unread messages) + sd_bus_unref() (which frees the connection). The combination of this call is used pretty frequently in systemd tools right before exiting, and should also be relevant for most external clients, and is hence useful to cover in a call of its own. Previously the combination of the three calls was already done in the _cleanup_bus_close_unref_ macro, but this was only available internally. Also see #327
* timedatectl: trim non-local RTC warning to 80 chars wideVedran Miletić2015-07-021-5/+6
|
* tree-wide: fix memory leaks in users of bus_map_all_properties()David Herrmann2015-06-141-7/+10
| | | | | | | | | | If you use bus_map_all_properties(), you must be aware that it might touch output variables even though it may fail. This is, because we parse many different bus-properties and cannot tell how to clean them up, in case we fail deep down in the parser. Fix all callers of bus_map_all_properties() to correctly cleanup any context structures at all times.
* timedate: fix memory leak in timedatedCristian Rodríguez2015-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ /usr/lib/systemd/systemd-timedated (wait until auto-exit) ================================================================= ==396==ERROR: LeakSanitizer: detected memory leaks Direct leak of 928 byte(s) in 1 object(s) allocated from: #0 0x7f782f788db1 in __interceptor_calloc (/usr/lib64/libasan.so.2+0x96db1) #1 0x562a83ae60cf in bus_message_from_header src/libsystemd/sd-bus/bus-message.c:480 #2 0x562a83ae6f5a in bus_message_from_malloc src/libsystemd/sd-bus/bus-message.c:576 #3 0x562a83ad3cad in bus_socket_make_message src/libsystemd/sd-bus/bus-socket.c:915 #4 0x562a83ad4cfc in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:1051 #5 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647 #6 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038 #7 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94 #8 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192 #9 0x562a83aae1af in main src/timedate/timedated.c:730 #10 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4) Indirect leak of 77 byte(s) in 1 object(s) allocated from: #0 0x7f782f788f6a in realloc (/usr/lib64/libasan.so.2+0x96f6a) #1 0x562a83ad418a in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:963 #2 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647 #3 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038 #4 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94 #5 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192 #6 0x562a83aae1af in main src/timedate/timedated.c:730 #7 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4) Indirect leak of 2 byte(s) in 1 object(s) allocated from: #0 0x7f782f75493f in strdup (/usr/lib64/libasan.so.2+0x6293f) #1 0x562a83b0229b in bus_message_parse_fields src/libsystemd/sd-bus/bus-message.c:5382 #2 0x562a83ae7290 in bus_message_from_malloc src/libsystemd/sd-bus/bus-message.c:601 #3 0x562a83ad3cad in bus_socket_make_message src/libsystemd/sd-bus/bus-socket.c:915 #4 0x562a83ad4cfc in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:1051 #5 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647 #6 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038 #7 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94 #8 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192 #9 0x562a83aae1af in main src/timedate/timedated.c:730 #10 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4) SUMMARY: AddressSanitizer: 1007 byte(s) leaked in 3 allocation(s). This is due to missing _cleanup_bus_message_unref_ in context_read_ntp()
* timedated: remove unnecessary gotoZbigniew Jędrzejewski-Szmek2015-05-061-3/+0
| | | | Not needed since 99f861310d3f05f4.
* sd-bus: drop bus parameter from message callback prototypeLennart Poettering2015-04-291-12/+12
| | | | | | This should simplify the prototype a bit. The bus parameter is redundant in most cases, and in the few where it matters it can be derived from the message via sd_bus_message_get_bus().
* tree-wide: get rid of more strerror() callsLennart Poettering2015-04-211-3/+3
|
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* man: avoid confusion regarding "time synchronization state"Lennart Poettering2015-04-081-1/+1
| | | | | Also, update example in the timedatectl man page to match the actual timedatectl output.
* timedatectl: trim --help output to 80 charsRonny Chevalier2015-04-081-1/+1
|
* timedatectl: avoid specifically referring to NTPLennart Poettering2015-04-071-2/+2
| | | | | | | | systemd-timesyncd not only does NTP, but also manages clock monotonicity using a flags file. In future, it might learn PTP support. Hence don't expose its enablement state as "NTP" but use the more generic term "network time synchronization". After all, for similar reasons systemd-timesyncd is not called systemd-ntpd.
* timedatectl: many fixesLennart Poettering2015-04-021-14/+23
| | | | | | | | | | | - print runtime warnings with log_warning() - save and restore $TZ properly - Get rid of exit() pseudo error handling - Using time() is OK when connecting to a local container or when showing data about local host, but certainly not for remote hosts.
* timedatectl: remove unused variablesThomas Hindoe Paaboel Andersen2015-03-241-1/+0
|
* timedate: remove daylight saving time handling and tzfile parserKay Sievers2015-03-241-56/+0
| | | | | | | | | | | | We planned to support (the conceptually broken) daylight saving time/local time features in the kernel, SCSI, networking, FAT filesystem, but it turned out to be a race we cannot win and do not want to get involved. Systemd should not fiddle with daylight saving time or parse timezone information itself. Leave everything to glibc or tools like date(1) and do not make any promises or raise expectations that systemd should handle anything like this.
* timedatectl: fix when queried system has differn't timezoneShawn Landden2015-03-241-2/+9
| | | | | | Also allow getting time from time(2) when BUS_TRANSPORT_MACHINE. v2: check for error
* timedated: fix enable/disable reversalZbigniew Jędrzejewski-Szmek2015-03-211-38/+21
| | | | | | | | | Bug introduced in 984f1b1d1b. The state was flipped later, but the enable/disable routine made use of the state to decide what to do. context_enable_ntp() and context_start_ntp() now get the desired state directly, so the Context parameter can be removed.
* timedated: flip internal status after executing operationZbigniew Jędrzejewski-Szmek2015-03-211-2/+2
| | | | | | | | | timedated would set the internal status before calling out to systemd to do the actual change. When the operation was refused because of a SELinux denial, the state kept in timedated would get out of sync, and the second call from timedatectl would appear to succeed. https://bugzilla.redhat.com/show_bug.cgi?id=1014315
* Use space after a silencing (void)Zbigniew Jędrzejewski-Szmek2015-03-131-1/+1
| | | | | We were using a space more often than not, and this way is codified in CODING_STYLE.
* tree-wide: there is no ENOTSUP on linuxDavid Herrmann2015-03-131-1/+1
| | | | Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
* adjust for time spent in timedated even without dbus timestampShawn Landden2015-03-071-2/+6
| | | | | | | | it is trivial to fall back to our own timestamp v2: use now() v3: remove useless if () v4: add comment
* timedated: when performing "SetTime" compensate for program lagShawn Landden2015-02-261-0/+10
| | | | (David: fix up compile-failure and simplify code a bit)
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-232-6/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* logind: open up most bus calls for unpriviliged processes, using PolicyKitLennart Poettering2015-02-181-4/+32
| | | | | | Also, allow clients to alter their own objects without any further priviliges. i.e. this allows clients to kill and lock their own sessions without involving PK.
* time-util: let's make xstrftime() useful for everybody, even if we only have ↵Lennart Poettering2015-02-021-2/+0
| | | | a single user so far.
* Add a snprinf wrapper which checks that the buffer was big enoughZbigniew Jędrzejewski-Szmek2015-02-011-39/+28
| | | | | | | | | | If we scale our buffer to be wide enough for the format string, we should expect that the calculation was correct. char_array_0() invocations are removed, since snprintf nul-terminates the output in any case. A similar wrapper is used for strftime calls, but only in timedatectl.c.