Commit Graph

353 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 886cf317c4 coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01: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
Lennart Poettering 818623aca5
Merge pull request #10860 from keszybz/more-cleanup-2
Do more stuff from main macros
2018-11-21 11:07:31 +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
Lennart Poettering bd0ce2447d tmpfiles: also order glob child/parent relationships
This is necessary so that "r" can be nested and are always executed in
the same order.

Fixes: #10191
2018-11-20 16:36:29 +01:00
Lennart Poettering 09f467ac24 tmpfiles: fix typo 2018-11-20 16:32:19 +01:00
Lennart Poettering 44ac4f8854 tmpfiles: label phases explicitly 2018-11-20 16:15:09 +01:00
Lennart Poettering 48d9690430 tmpfiles: behind → below in log msgs
As suggested here:

https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207
2018-11-20 15:56:55 +01:00
Zbigniew Jędrzejewski-Szmek 7fa0269bca
Merge pull request #10850 from poettering/log-setup
reduce some logging boilerplate
2018-11-20 13:36:45 +01:00
Zbigniew Jędrzejewski-Szmek 606b0b64a7
Merge pull request #10538 from poettering/tmpfiles-reorder
tmpfiles: remove children before their parents plus other fixlets
2018-11-20 13:00:28 +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
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 2c57597745 tmpfiles: 'D' doesn't do globs for creation, shouldn't do for removal either 2018-11-08 09:52:16 +01:00
Lennart Poettering 64adb37968 tmpfiles: always remove/clean-up before creating
Let's always clean the platform before we build something new.

Fixes: #9508
2018-11-08 09:52:16 +01:00
Lennart Poettering 21af33863f tmpfiles: log when we skip an entry due to autofs 2018-11-08 09:52:16 +01:00
Lennart Poettering 811a158778 tmpfiles: create parents before children, but remove children before parents
Previously, we'd always process parents before children. With this
change we are a bit more careful and create parents before children but
clean up children before parents.

The "done" boolean by item is replaced by a mask so that we can descent
and ascend for the right operations only.

See: #9508
2018-11-08 09:52:16 +01:00
Lennart Poettering 133bbca42e tmpfiles: no need to set zero initialization of first enum value 2018-11-08 09:52:16 +01:00
Lennart Poettering 599ebe29a3 tmpfiles: instead of accessing global 'arg_operation' pass it through the stack
Just some refactoring, no change in behaviour.
2018-11-08 09:52:16 +01:00
Lennart Poettering 1a967b6bb1 tmpfiles: replace the three arg_create/arg_remove/arg_clean booleans with a single bitmask
No change in behaviour, just a bit of refactoring.
2018-11-08 09:52:16 +01:00
Lennart Poettering ccd114f0f9 tmpfiles: fix minor memory leak on error path 2018-11-08 09:52:16 +01:00
Lennart Poettering 81fa4479f8 tmpfiles: use free_and_replace() where appropriate 2018-11-08 09:52:16 +01:00
Lennart Poettering 7ab7529d45 tmpfiles: why memset() and memcpy() if we have '=' and structured initialization? 2018-11-08 09:52:16 +01:00
Lennart Poettering 96d10d7837 tmpfiles: rename "count" → "n_items"
"count" is so very generic. Let's follow our usual naming logic here,
and rename this to "n_items", to make clear what we count here.
2018-11-08 09:52:16 +01:00
Lennart Poettering 647687141a tmpfiles: rename second parameter to GREEDY_REALLOC() 'allocated'
We pretty much always name it like that, and it is very descriptive,
hence let's stick to that nomenclature here.
2018-11-08 09:52:16 +01:00
Lennart Poettering 2a98ae4a05 tmpfiles: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Davide Cavalca b75f0c69b3 shared: add %g, %G specifiers for group / gid (#10368) 2018-10-13 17:26:48 +09:00
Lennart Poettering db9a42545a chattr: optionally, return the old flags when updating them 2018-10-08 21:40:44 +02:00
William Douglas 6d7b543342 RFC tmpfiles: Allow configuration to ignore execution errors
This is an implementation that covers making errors encountered when writing
file content optionally fatal. If this is something that folks would want I'll
add handling of this for all the other directives. I'd appreciate suggestions
on how this might better be structured as well (use of a goto fail or such) as
I'm not super happy with the approach.
2018-09-25 23:30:30 +02:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Franck Bui 4dc7bfdf4f tmpfiles: use fd_get_path() even less excessively
A follow-up for commit 9d874aec45.

This patch makes "path" parameter mandatory in fd_set_*() helpers removing the
need to use fd_get_path() when NULL was passed. The caller is supposed to pass
the fd anyway so assuming that it also knows the path should be safe.

Actually, the only case where this was useful (or used) was when we were
walking through directory trees (in item_do()). But even in those cases the
paths could be constructed trivially, which is still better than relying on
fd_get_path() (which is an ugly API).

A very succinct test case is also added for 'z/Z' operators so the code dealing
with recursive operators is tested minimally.
2018-08-21 19:48:08 +02:00
Zbigniew Jędrzejewski-Szmek 7692fed98b
Merge pull request #9783 from poettering/get-user-creds-flags
beef up get_user_creds() a bit and other improvements
2018-08-21 10:09:33 +02:00
Lennart Poettering fafff8f1ff user-util: rework get_user_creds()
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a
flags argument for it to select "clean" behaviour. This flags parameter
also learns to other new flags:

- USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for
  root/nobody are only synthesized as fallback. Normally, the synthesized
  records take precedence over what is in the user database.  With this
  flag set this is reversed, and the user database takes precedence, and
  the synthesized records are only used if they are missing there. This
  flag should be set in cases where doing NSS is deemed safe, and where
  there's interest in knowing the correct shell, for example if the
  admin changed root's shell to zsh or suchlike.

- USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by
  numeric value, and there's no user/group record for it accept it
  anyway. This allows us to fix #9767

This then also ports all users to set the most appropriate flags.

Fixes: #9767

[zj: remove one isempty() call]
2018-08-20 15:58:21 +02:00
Zbigniew Jędrzejewski-Szmek 5664144bd3
Merge pull request #9809 from poettering/tmpfiles-cleanup
various tmpfiles fixes
2018-08-20 12:51:57 +02: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
Franck Bui f17a8d6178 tmpfiles: don't adjust qgroups on existing subvolumes
The qgroup logic (types 'q' and 'Q') only has an effect if there's no previous
setup at all, and any explicitly configured subvolumes with their qgroups are
left entirely unmodified.

The idea is that if users want a different logic than the one we set up by
default, then by all means they should do that before hand, and tmpfiles won't
override their logic.
2018-08-08 12:37:35 +02:00
Lennart Poettering c3e03778d6 tmpfiles: return correct error variable after fd_reopen() 2018-08-08 11:59:39 +02:00
Lennart Poettering 713998cfc8 tmpfiles: reindent one comment less weirdly 2018-08-08 11:59:39 +02:00
Lennart Poettering a5df05ff20 tmpfiles: use correct error variable 2018-08-08 11:59:39 +02:00
Lennart Poettering 15b45fac87 tmpfiles: clarify that we ignore file attribute setting errors 2018-08-08 11:59:39 +02:00
Lennart Poettering 09f12798c9 tmpfiles: add log message where we previously failed silently 2018-08-08 11:59:39 +02:00
Lennart Poettering 9d874aec45 tmpfiles: use fd_get_path() less excessively
fd_get_path() is an ugly API, as it creates ambiguities related to the
" (deleted)" suffix /proc/$PID/fd/$FD shows. Let's use it a bit less
excessively, and whenever we have a good valid path already, let's
simply pass that along, instead of forgetting it in one stackframe and
reacquiring it in the next.
2018-08-08 11:59:39 +02:00
Franck Bui addc3e302d tmpfiles: don't follow unsafe transitions in path_set_*()
Since all path_set_*() helpers don't follow symlinks, it's possible to use
chase_symlinks(CHASE_NOFOLLOW) flag to both open the files specified by the
passed paths and check their validity (unlike their counterpart fd_set_*()
helpers).
2018-07-30 16:04:20 +02:00
Franck Bui 7ea5a87f92 tmpfiles: make create_fifo() safe 2018-07-30 15:54:03 +02:00
Franck Bui a2fc2f8dd3 tmpfiles: introduce create_fifo() 2018-07-30 15:54:03 +02:00
Franck Bui 5494602195 tmpfiles: introduce empty_directory() 2018-07-30 15:54:03 +02:00
Franck Bui 4c39d899ff tmpfiles: introduce create_directory() and create_subvolume() and make them safe 2018-07-30 15:54:03 +02:00
Franck Bui 4ad3684410 tmpfiles: introduce create_directory_or_subvolume()
No functional changes.
2018-07-30 15:54:03 +02:00
Franck Bui c7700a7748 tmpfiles: make create_device() safe 2018-07-30 15:54:03 +02:00
Franck Bui 074bd73fd3 tmpfiles: introduce create_device() 2018-07-30 15:54:03 +02:00
Franck Bui 16ba55adb1 tmpfiles: make copy_files() safe 2018-07-30 15:54:02 +02:00