summaryrefslogtreecommitdiff
path: root/src/delta
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+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: unify how we define bit mak enumsLennart Poettering2018-06-121-3/+3
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* path-util: introduce path_simplify()Yu Watanabe2018-06-031-1/+1
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* 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.
* fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()Lennart Poettering2018-03-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This rearranges chase_symlinks() a bit: if no special flags are specified it will now revert to behaviour before b12d25a8d631af00b200e7aa9dbba6ba4a4a59ff. However, if the new CHASE_TRAIL_SLASH flag is specified it will follow the behaviour introduced by that commit. I wasn't sure which one to make the beaviour that requires specification of a flag to enable. I opted to make the "append trailing slash" behaviour the one to enable by a flag, following the thinking that the function should primarily be used to generate a normalized path, and I am pretty sure a path without trailing slash is the more "normalized" one, as the trailing slash is not really a part of it, but merely a "decorator" that tells various system calls to generate ENOTDIR if the path doesn't refer to a path. Or to say this differently: if the slash was part of normalization then we really should add it in all cases when the final path is a directory, not just when the user originally specified it. Fixes: #8544 Replaces: #8545
* tree-wide: voidify pager_open()Yu Watanabe2018-03-191-1/+1
| | | | | | 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.
* tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS childrenLennart Poettering2018-02-221-0/+1
| | | | | | | | | | | | | | | | | | In a number of occasions we use FORK_CLOSE_ALL_FDS when forking off a child, since we don't want to pass fds to the processes spawned (either because we later want to execve() some other process there, or because our child might hang around for longer than expected, in which case it shouldn't keep our fd pinned). This also closes any logging fds, and thus means logging is turned off in the child. If we want to do proper logging, explicitly reopen the logs hence in the child at the right time. This is particularly crucial in the umount/remount children we fork off the shutdown binary, as otherwise the children can't log, which is why #8155 is harder to debug than necessary: the log messages we generate about failing mount() system calls aren't actually visible on screen, as they done in the child processes where the log fds are closed.
* Merge pull request #7540 from fbuihuu/systemd-delta-tweaksZbigniew Jędrzejewski-Szmek2018-01-161-23/+19
|\ | | | | Systemd delta tweaks
| * delta: don't ignore PREFIX when the given argument is PREFIX/SUFFIXFranck Bui2017-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, when systemd-delta was asked for overwritten configuration files in a directory specified by PREFIX/SUFFIX, it ignored the given PREFIX and listed all overwritten files matching the subdirectory specified by SUFFIX. Hence we could get the following: $ ./build/systemd-delta /usr/local/lib/systemd/system [REDIRECTED] /etc/systemd/system/default.target → /usr/lib/systemd/system/default.target [EXTENDED] /usr/lib/systemd/system/systemd-sysctl.service → /usr/lib/systemd/system/systemd-sysctl.service.d/50-kernel-uname_r.conf systemd-delta showed overwritten configuration files in /usr/lib whereas only overwritten ones in /usr/local/lib should have been reported (none in my case). With the patch applied, we now get: $ ./build/systemd-delta /usr/local/lib/systemd/system 0 overridden configuration files found.
| * delta: extend skip logic to work on full directory paths (prefix+suffix)Franck Bui2017-12-041-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than only checking that a prefix path is a symlink to another prefix path (this can happen with split-usr=true and /lib a symlink to /usr/lib), extend the logic in should_skip_prefix() so that the check is done on the full directory path (prefix + suffix). This allows to catch such cases as well: # ls -ld /lib /lib/udev drwxr-xr-x 1 root root 86 Nov 22 13:14 /lib lrwxrwxrwx 1 root root 13 Sep 4 17:47 /lib/udev -> /usr/lib/udev where prefix=/lib and suffix=udev/rules.d
| * delta: check if a prefix needs to be skipped only onceFranck Bui2017-12-041-7/+0
| | | | | | | | | | | | The condition is already tested later by process_fix() therefore there's no need the check in process_suffix_chop() since it will end up calling process_fix() anyways.
* | process-util: rework wait_for_terminate_and_warn() to take a flags parameterLennart Poettering2018-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This renames wait_for_terminate_and_warn() to wait_for_terminate_and_check(), and adds a flags parameter, that controls how much to log: there's one flag that means we log about abnormal stuff, and another one that controls whether we log about non-zero exit codes. Finally, there's a shortcut flag value for logging in both cases, as that's what we usually use. All callers are accordingly updated. At three occasions duplicate logging is removed, i.e. where the old function was called but logged in the caller, too.
* | process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-01-041-2/+2
| |
* | tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-15/+10
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* 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.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-2/+2
| | | | | | | | | | | | | | | 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
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* delta: sort files and dirs before processingZbigniew Jędrzejewski-Szmek2017-07-101-44/+83
| | | | | | | | | | This should make output deterministic, and independent of the directory layout on disk. Just using ordered hashmaps would be enough to make the output deterministic on a specific machine, but to make it identical on different machines with the same set of files and directories, names are sorted after being use. Fixes #6157.
* tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)Reverend Homer2016-12-091-7/+3
|
* fs-util: add flags parameter to chase_symlinks()Lennart Poettering2016-12-011-3/+3
| | | | | | Let's remove chase_symlinks_prefix() and instead introduce a flags parameter to chase_symlinks(), with a flag CHASE_PREFIX_ROOT that exposes the behaviour of chase_symlinks_prefix().
* tree-wide: stop using canonicalize_file_name(), use chase_symlinks() insteadLennart Poettering2016-12-011-6/+7
| | | | | | | | Let's use chase_symlinks() everywhere, and stop using GNU canonicalize_file_name() everywhere. For most cases this should not change behaviour, however increase exposure of our function to get better tested. Most importantly in a few cases (most notably nspawn) it can take the correct root directory into account when chasing symlinks.
* delta: skip symlink paths when split-usr is enabled (#4591)Felipe Sateler2016-11-061-0/+31
| | | | | | | | | If systemd is built with --enable-split-usr, but the system is indeed a merged-usr system, then systemd-delta gets all confused and reports that all units and configuration files have been overridden. Skip any prefix paths that are symlinks in this case. Fixes: #4573
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-4/+4
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* tree-wide: rename draw_special_char to special_glyphZbigniew Jędrzejewski-Szmek2016-05-091-10/+10
| | | | | | | | | That function doesn't draw anything on it's own, just returns a string, which sometimes is more than one character. Also remove "DRAW_" prefix from character names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't draw anything, and are always used as an argument to special_glyph(). Rename "DASH" to "MDASH", as there's more than one type of dash.
* Merge pull request #2671 from 0xAX/move-pager-open-to-one-placeZbigniew Jędrzejewski-Szmek2016-02-251-9/+1
|\ | | | | tree-wide: merge pager_open_if_enabled() to the pager_open()
| * 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: minor formatting inconsistency cleanupsVito Caputo2016-02-231-1/+1
|/
* delta: minor coding style fixesLennart Poettering2016-02-111-22/+21
| | | | no change in behaviour
* 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.
* treewide: apply errno.cocciMichal Schmidt2015-11-091-2/+1
| | | | with small manual cleanups for style.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move more locale-related calls to locale-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: introduce dirent-util.[ch] for directory entry callsLennart Poettering2015-10-271-0/+1
| | | | Also, move a couple of more path-related functions to path-util.c.
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-0/+1
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-10/+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-5/+5
| | | | | | 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.
* tree-wide: whenever we fork off a foreign child process reset signal ↵Lennart Poettering2015-06-101-1/+8
| | | | | | | | | | mask/handlers Also, when the child is potentially long-running make sure to set a death signal. Also, ignore the result of the reset operations explicitly by casting them to (void).
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* shared: add process-util.[ch]Ronny Chevalier2015-04-101-0/+1
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+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.
* delta: fix output alignment of [REDIRECTED] entriesIvan Shapovalov2014-12-141-1/+1
|
* delta: Fix broken separator supportAlison Chaiken2014-11-301-1/+1
| | | | | | systemd-delta man page promises that multiple types of deltas will be concatenated if they are listed with a comma as separator. Replace FOREACH_WORD() with FOREACH_WORD_SEPARATOR() to restore the functionality.
* delta: diff returns 1 when files differ, ignore thisZbigniew Jędrzejewski-Szmek2014-11-291-1/+1
| | | | https://bugs.debian/org/771397
* treewide: another round of simplificationsMichal Schmidt2014-11-281-4/+3
| | | | | Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-3/+3
| | | | | | | | | | | 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.