Commit graph

185 commits

Author SHA1 Message Date
Lennart Poettering 8fcde01280 util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering f4f15635ec util-lib: move a number of fs operations into fs-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering c8b3094de5 util-lib: split out file attribute calls to chattr-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 0d39fa9c69 util-lib: move more file I/O related calls into fileio.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering b1d4f8e154 util-lib: split out user/group/uid/gid calls into user-util.[ch] 2015-10-26 01:24:38 +01:00
Lennart Poettering c004493cde util-lib: split out IO related calls to io-util.[ch] 2015-10-26 01:24:38 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file 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.
2015-10-24 23:05:02 +02:00
Lennart Poettering 4f5dd3943b util: split out escaping code into escape.[ch]
This really deserves its own file, given how much code this is now.
2015-10-24 23:04:42 +02:00
Lennart Poettering 0f03c2a4c0 path-util: unify how we process paths specified on the command line
Let's introduce a common function that makes relative paths absolute and
warns about any errors while doing so.
2015-10-24 23:03:49 +02:00
Lennart Poettering 0f47436510 util-lib: get_current_dir_name() can return errors other than ENOMEM
get_current_dir_name() can return a variety of errors, not just ENOMEM,
hence don't blindly turn its errors to ENOMEM, but return correct errors
in path_make_absolute_cwd().

This trickles down into a couple of other functions, some of which
receive unrelated minor fixes too with this commit.
2015-10-24 23:03:49 +02:00
Thomas Hindoe Paaboel Andersen 2bb158c1ce tmpfiles: simplify mountpoint detection
No functional change. Just a simplification. A || (!A && B) is
the same as A || B

Introduced in 78a92a5a23
2015-10-23 22:35:03 +02:00
Lennart Poettering 5fb13eb51b tmpfiles: introduce "q" and "Q" for creating quota-enabled btrfs subvolumes
This allows us to set up the quota group hierarchy in a reasonable way
on btrfs file systems.
2015-10-22 01:59:25 +02:00
Lennart Poettering 3f6fd1ba65 util: introduce common version() implementation and use it everywhere
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.
2015-09-29 21:08:37 +02:00
Richard Maw 12ba2c44dd util: Don't interpret quotes by default in extract_first_word
This adds an EXTRACT_QUOTES option to allow the previous behaviour, of
not interpreting any character inside ' or " quotes as separators.
2015-08-07 15:50:42 +00:00
Richard Maw 6868560773 util: change unquote_*_word to extract_*_word
It now takes a separators argument, which defaults to WHITESPACE if NULL
is passed.
2015-08-07 15:50:42 +00:00
Thomas Hindoe Paaboel Andersen 7d6884b65e tree-wide: fix indentation 2015-08-06 00:44:19 +02:00
Lennart Poettering ad75a97f7d tmpfiles: downgrade errors when a file system does not support file attributes
This downgrades errors from setting file attributes via tmpfiles to
warnings and makes them non-fatal.

Also, as a special case, if a file system does not support file
attributes at all, then the message is downgraded to debug, so that it
is not seen at all.

With this change reiserfs should not see any messages at all anymore
(since it apparently does not implement file attributes at all), but XFS
will still get a warning but no failure. The warning is something the
XFS kernel folks should fix though, by adjusting their file attributes
behaviour to be identical to ext234's.

Fixes #560.
2015-07-22 22:02:14 +02:00
Zbigniew Jędrzejewski-Szmek 1542c01b1d tmpfiles: only root-owned aquota.* files are special
Fixes #188.
2015-06-17 15:46:32 +02:00
Lennart Poettering 1b26f09eb0 tmpfiles: make sure "R" lines also remove subvolumes 2015-06-15 19:28:55 +02:00
Lennart Poettering a542c4dc43 tmpfiles: use lstat() instead of stat() when checking whether a file system object already exists 2015-05-15 21:48:20 +02:00
Lennart Poettering 7b135a7399 tmpfiles: don't fail if we cannot create a subvolume because a file system is read-only but a dir already exists anyway
https://bugs.freedesktop.org/show_bug.cgi?id=90281
2015-05-15 21:47:22 +02:00
Lennart Poettering 1d13f648d0 util: add generic calls for prefixing a root directory to a path
So far a number of utilities implemented their own calls for this, unify
them in prefix_root() and prefix_roota(). The former uses heap memory,
the latter allocates from the stack via alloca().

Port over most users of a --root= logic.
2015-05-13 17:42:10 +02:00
Michael Olbrich f44b28fda0 tmpfiles: try to handle read-only file systems gracefully
On read-only filesystems trying to create the target will not fail with
EEXIST but with EROFS. Handle EROFS by checking if the target already
exists, and if empty when truncating.
This avoids reporting errors if tmpfiles doesn't actually needs to do
anything.

[zj: revert condition to whitelist rather then blacklisting, and add goto
to avoid stat'ting twice.]
2015-05-06 00:10:40 -04:00
Lennart Poettering ef43a39176 tmpfiles: use an ordered hashmap for the tmpfiles items
We should try to execute them in the same order they appear in the
configuration files, as it is documented. Hence move to an ordered
hashmap.

(Note though, that this still doesn't execute them completely in order:
we will still apply non-glob lines before glob-lines, and reorder lines
prefixing each other and that apply to the same paths).

http://lists.freedesktop.org/archives/systemd-devel/2015-March/029055.html
2015-04-22 18:20:27 +02:00
Lennart Poettering aa5f6817bc tmpfiles: consider an argument of "-" as non-specified 2015-04-21 01:10:19 +02:00
Lennart Poettering 48b8aaa827 tmpfiles: don't follow symlinks when adjusting ACLs, fille attributes, access modes or ownership 2015-04-13 15:23:52 +02:00
Zbigniew Jędrzejewski-Szmek dd449aca61 tmpfiles: use qsort_safe 2015-04-12 10:20:24 -04:00
Ronny Chevalier 6482f6269c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
Thomas Hindoe Paaboel Andersen 75c2a9fd13 tmpfiles: fix build with clang
Clang is not happy about using the cleanup attribute in switches
2015-04-10 23:28:08 +02:00
Lennart Poettering 5c5ccf12b6 tmpfiles: add specifier expansion for L and C lines, too 2015-04-10 18:07:04 +02:00
Lennart Poettering 17493fa5d1 tmpfiles: enforce ordering when executing lines
Always create files first, and then adjust their ACLs, xattrs, file
attributes, never the opposite. Previously the order was not
deterministic, thus possibly first adjusting ACLs/xattrs/file
attributes before actually creating the items.
2015-04-10 16:23:47 +02:00
Lennart Poettering 90937fe3d3 tmpfiles: eat up empty columns 2015-04-10 16:23:46 +02:00
Lennart Poettering bd550f78eb tmpfiles: substitute % specifiers in arguments for writing files and xattrs 2015-04-10 16:23:46 +02:00
Lennart Poettering c82500c6fb tmpfiles: warn if we get an argument on lines that don't take any 2015-04-10 16:23:46 +02:00
Lennart Poettering 3ea40b7810 tmpfiles: mostly revert 71044f609b
Add a comment why returning a positive error is OK and intended in this
case.

(It's still a nasty hack to do this though!)
2015-04-10 16:23:46 +02:00
Lennart Poettering 2ff7b0a542 util: unify how we parse mode_t strings 2015-04-10 16:23:46 +02:00
Lennart Poettering 71044f609b tmpfiles: properly return error code from path_set_acl() 2015-04-09 13:13:07 +02:00
Lennart Poettering 34f6453603 tmpfiles: add file attribute calls to list of glob needing commands 2015-04-09 13:13:07 +02:00
Lennart Poettering 88ec4dfa28 tmpfiles: rework file attribute code
- Stick to one type for the flags field: unsigned. This appears to be
  what the kernel uses, and there's no point in using something else.

- compress the flags array by avoiding sparse entries

- extend some error messages to not use abbreviated words

- avoid TTOCTTOU issues by invoking fstat() after open() when applying
  file flags

- add explanation why we need to check the file type with fstat().

- don't needlessly abbreviate "attribute" as "attrib", in particually as
  "chattr" abbreviates it as "attr" rather than "attrib".
2015-04-08 22:35:52 +02:00
Lennart Poettering 1ed8f8c16d util: merge change_attr_fd() and chattr_fd() 2015-04-08 20:47:35 +02:00
Lennart Poettering 527b7a421f util: rework cunescape(), improve error handling
Change cunescape() to return a normal error code, so that we can
distuingish OOM errors from parse errors.

This also adds a flags parameter to control whether "relaxed" or normal
parsing shall be done. If set no parse failures are generated, and the
only reason why cunescape() can fail is OOM.
2015-04-07 15:42:25 +02:00
Lennart Poettering c687863750 util: rework rm_rf() logic
- Move to its own file rm-rf.c

- Change parameters into a single flags parameter

- Remove "honour sticky" logic, it's unused these days
2015-04-06 10:57:53 +02:00
Lennart Poettering 4034a06ddb util: rework word parsing and c unescaping code
When parsing words from input files, optionally automatically unescape
the passed strings, controllable via a new flags parameter.

Make use of this in tmpfiles, and port everything else over, too.

This improves parsing quite a bit, since we no longer have to process the
same string multiple times with different calls, where an earlier call
might corrupt the input for a later call.
2015-03-26 11:56:22 +01:00
Lennart Poettering 1532227a19 tmpfiles: minor simplification 2015-03-26 11:56:22 +01:00
Thomas Hindoe Paaboel Andersen a4135d3234 tmpfiles: avoid out of bounds read
Otherwise this will go wrong for 'v'.
2015-03-24 23:53:09 +01:00
Goffredo Baroncelli 22c3a6cadb Allow systemd-tmpfiles to set the file/directory attributes
Allow systemd-tmpfiles to set the file/directory attributes, like
chattr(1) does. Two more commands are added: 'H' and 'h' to set the
attributes, recursively and not.
2015-03-19 22:20:12 -04:00
Zbigniew Jędrzejewski-Szmek 51bfdaf66c tmpfiles: remove redundant debug message
Mar 13 19:48:30 adam.happyassassin.net systemd-tmpfiles[970]: "/var/lib/machines" has right mode 40700
Mar 13 19:48:30 adam.happyassassin.net systemd-tmpfiles[970]: /var/lib/machines created successfully.
2015-03-14 23:03:21 -04:00
David Herrmann 15411c0cb1 tree-wide: there is no ENOTSUP on linux
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13 14:10:39 +01:00