summaryrefslogtreecommitdiffstats
path: root/src/update-utmp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* meson: move declarations of modules-load, nspawn, update-done, and update-utmpYu Watanabe2023-08-011-0/+10
|
* time-util: introduce usleep_safe()Yu Watanabe2023-06-221-1/+1
| | | | | | | | We use usec_t for storing time value, which is 64bit. However, usleep() takes useconds_t that is (typically?) 32bit. Also, usleep() may only support the range [0, 1000000]. This introduce usleep_safe() which takes usec_t.
* update-utmp: reconnect after sleep when PID1 is reexecutingYu Watanabe2023-05-241-23/+48
| | | | Fixes #27167.
* update-utmp: update log messageYu Watanabe2023-05-241-3/+2
|
* update-utmp: downgrade log level of ignored failureYu Watanabe2023-05-241-2/+2
|
* update-utmp: swap q <-> rYu Watanabe2023-05-241-22/+22
| | | | | | We usually use 'r' for general purpose. No functional change, just refactoring.
* update-utmp: modernize get_startup_monotonic_time()Yu Watanabe2023-05-241-12/+15
| | | | | | This also downgrade error level, as the failure will be ignored. No functional change, just refactoring.
* update-utmp: rebreak commentsYu Watanabe2023-05-241-18/+11
|
* update-utmp: use verbsYu Watanabe2023-05-241-22/+17
| | | | No functional change, just refactoring.
* tree-wide: convert more system1.Manager calls to BusLocatorDavid Tardon2023-05-241-8/+2
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* set boot time from monotonic time (#19444)caoxia2008cxx2021-04-291-5/+12
| | | utmp: calculate boot timestamp from monotonic timestamp instead of realtime timestamp
* Add comma in structured initialization in a few placesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | It just looks nicer…
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-01-311-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: use return value of log_xxx_errno()Yu Watanabe2020-11-191-8/+4
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: correct cases where return log_{error,warning} is used without valueZbigniew Jędrzejewski-Szmek2020-09-081-2/+4
| | | | | | | | In various cases, we would say 'return log_warning()' or 'return log_error()'. Those functions return 0 if no error is passed in. For log_warning or log_error this doesn't make sense, and we generally want to propagate the error. In the few cases where the error should be ignored, I think it's better to split it in two, and call 'return 0' on a separate line.
* initctl,update-utmp: define iterator variable in loopZbigniew Jędrzejewski-Szmek2020-07-021-2/+1
|
* update-utmp,initctl: drop ppid checkZbigniew Jędrzejewski-Szmek2020-07-021-3/+0
| | | | | Such checks make debugging harder but serve no useful purpose otherwise. We got rid of all the checks for root, let's kill those too.
* Remove unneded {}sZbigniew Jędrzejewski-Szmek2020-04-131-4/+2
| | | | | | $ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c Inspired by ea7cbf5bdd68d7861ebf1570c439e8bbabd83f6c.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-031-1/+0
|
* update-utmp: remove dead conditionalZbigniew Jędrzejewski-Szmek2019-10-211-12/+9
| | | | | | | Coverity was complaining that runlevel>0 is guaranteed at this point. CID #1404262. While at it, shorten the code a bit.
* update-utmp: define main() through macroZbigniew Jędrzejewski-Szmek2019-09-161-33/+22
| | | | | | Update logging a bit: drop logging of the pid, nowadays pid1 and journald do a very good job of logging that. Always log about failure to open audit fd, but at DEBUG_LEVEL if not important.
* update-utmp: fix assertion failure if rescue.target, multi-user.target and ↵Tommi Rantala2019-08-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | graphical.target are all inactive If rescue.target, multi-user.target and graphical.target are all inactive, get_current_runlevel() is not able to determine current runlevel, and returns with zero. This zero runlevel value results to assertion failure in utmp_put_runlevel(). # systemctl stop rescue.target multi-user.target graphical.target # systemctl start systemd-update-utmp-runlevel.service systemd[1]: Stopped target Graphical Interface. systemd[1]: Stopped target Multi-User System. systemd[1]: Starting Update UTMP about System Runlevel Changes... systemd-update-utmp[67]: Assertion 'runlevel > 0' failed at src/shared/utmp-wtmp.c:275, function utmp_put_runlevel(). Aborting. systemd[1]: systemd-update-utmp-runlevel.service: Main process exited, code=dumped, status=6/ABRT systemd[1]: systemd-update-utmp-runlevel.service: Failed with result 'core-dump'. systemd[1]: Failed to start Update UTMP about System Runlevel Changes. Let's just print a warning in this case and skip the utmp update, to avoid systemd-update-utmp-runlevel.service failures.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+2
| | | | | 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.
* update-utmp: use _cleanup_ attribute to finalize processYu Watanabe2018-11-221-11/+14
|
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | 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.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | 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.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* Merge pull request #6974 from keszybz/clean-up-definesLennart Poettering2017-10-041-8/+8
|\ | | | | Clean up define definitions
| * build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* | tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-3/+3
|/
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-2/+3
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* update-utmp: let's use STR_IN_SET() where it is prettyLennart Poettering2016-10-201-1/+2
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+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-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+6
|
* update-utmp: flush and close the bus used for connections after useLennart Poettering2015-09-291-1/+1
|
* update-utmp: minor modernizationsLennart Poettering2015-09-291-11/+6
|
* 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.
* tree-wide: drop {} from one-line if blocksLennart Poettering2015-09-091-3/+1
| | | | Patch via coccinelle.
* tree-wide: make use of log_error_errno() return valueLennart Poettering2015-09-091-6/+6
| | | | | | | | | | | | | | | | | | | | Turns this: r = -errno; log_error_errno(errno, "foo"); into this: r = log_error_errno(errno, "foo"); and this: r = log_error_errno(errno, "foo"); return r; into this: return log_error_errno(errno, "foo");
* Bug #944: Deletion of unnecessary checks before a few calls of systemd functionsMarkus Elfring2015-08-171-3/+1
| | | | | | | | | | | | | | | The following functions return immediately if a null pointer was passed. * calendar_spec_free * link_address_free * manager_free * sd_bus_unref * sd_journal_close * udev_monitor_unref * udev_unref It is therefore not needed that a function caller repeats a corresponding check. This issue was fixed by using the software Coccinelle 1.0.1.
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-2/+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.