summaryrefslogtreecommitdiff
path: root/src/update-utmp
Commit message (Collapse)AuthorAgeFilesLines
* 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-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: use return value of log_xxx_errno()Yu Watanabe2020-11-201-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-041-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-231-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.
* everywhere: remove configurability of sysv runlevel to target mappingLennart Poettering2015-02-181-5/+3
| | | | | | | | | | | | | | | With this change runlevel 2, 3, 4 are mapped to multi-user.target for good, and 5 to graphical.target. This was already the previous mapping but is now no longer reconfigurable, but hard-coded into the core. This should generally simplify things, but also fix one bug: the sysv-generator previously generated symlinks to runlevel[2-5].target units, which possibly weren't picked up if these aliases were otherwise only referenced by the real names "multi-user.target" and "graphical.target". We keep compat aliases "runlevel[2345].target" arround for cases where this target name is explicitly requested.
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-4/+4
| | | | | | | | | | | If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
* treewide: yet more log_*_errno + return simplificationsMichal Schmidt2014-11-281-4/+2
| | | | | | | | | | | | | Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-5/+5
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-5/+5
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* audit: improve the audit messages we generateLennart Poettering2014-11-041-3/+3
| | | | | always pass along comm, as documented by audit. Always set the correct comm value.
* Remove unnecessary casts in printfsZbigniew Jędrzejewski-Szmek2014-05-151-2/+2
| | | | No functional change expected :)
* utmp: make sure we don't write the utmp reboot record twice on each bootLennart Poettering2014-01-301-24/+7
| | | | (Also, only send the audit msg once, too)
* update-utmp: code modernizationsLennart Poettering2014-01-301-21/+22
|
* bus: use new property retrieval calls everywhereLennart Poettering2013-11-071-33/+18
|