Commit graph

1810 commits

Author SHA1 Message Date
Lennart Poettering 8b0849e971 core: rework cgroup path parse logic
Various cleanups, be stricter when parsing unit paths.

Most importantly: return the root slice "-.slice" when asked for slice
of paths that contain no slice component.
2015-04-30 00:49:41 +02:00
Lennart Poettering cfeaa44a09 sd-bus: properly handle creds that are known but undefined for a process
A number of fields do not apply to all processes, including: there a
processes without a controlling tty, without parent process, without
service, user services or session. To distuingish these cases from the
case where we simply don't have the data, always return ENXIO for them,
while returning ENODATA for the case where we really lack the
information.

Also update the credentials dumping code to show this properly. Fields
that are known but do not apply are now shown as "n/a".

Note that this also changes some of the calls in process-util.c and
cgroup-util.c to return ENXIO for these cases.
2015-04-29 21:45:58 +02:00
Lennart Poettering 597466f497 exit-status: introduce common exit_status_set_test() call for testing exit status set membership 2015-04-28 21:34:23 +02:00
Thomas Hindoe Paaboel Andersen 8431778882 path-util: fix fstat fallback in fd_is_mount_point 2015-04-26 16:02:21 +02:00
Lennart Poettering 0f5a8be5fe sysctl: minor simplifications 2015-04-24 19:56:47 +02:00
Daniel Mack 99f710dde8 shared/utmp-wtmp: add parameter for origin tty and callback userdata
Instead of looking up the tty from STDIN, let utmp_wall() take an argument
to specify an origin tty for the wall message. Only if that argument is
NULL do the STDIN lookup.

Also add an void *userdata argument that is handed back to the callback
function.
2015-04-24 17:48:12 +02:00
Lennart Poettering 3f72b427b4 path-util: make use of "mnt_id" field exported in /proc/self/fdinfo/<fd> to test for mount points
It's a very recent kernel addition, but certainly makes sense to
support.
2015-04-23 13:40:54 +02:00
Martin Pitt 470dca63cd util: Fix assertion in split() on missing '
When parsing a unit with a trailing slash after an escaped line break, like

  ExecStart=/bin/echo 'foo \
    bar'

the split() function (through config_parse()) asserted and crashed pid 1:

  Assertion 'current[*l + 1] == quotechars[0]' failed at ../src/shared/util.c:583, function split(). Aborting.

Fix this by returning an error in this case ("trailing garbage").

Add corresponding test case. Also fix the missing "unit" argument of
config_parse_exec() in the comment.

https://launchpad.net/bugs/1447243
2015-04-23 01:14:07 +02:00
Lennart Poettering e346512c68 journalctl: rework code that checks whether we have access to /var/log/journal
- fix some memory leaks on error conditions

- handle all error cases properly, and log about failures

- move HAVE_ACL and no-HAVE_ACL code closer to each other
2015-04-22 22:56:24 +02:00
Lennart Poettering 3986b2581c btrfs-util: support recursive removal of read-only subvolumes
When deleting a read-only subsvolume with a sub-subvolume, we need to
mark it writable first, otherwise the removal will not work.
2015-04-22 17:09:20 +02:00
Lennart Poettering ffb296b2c2 btrfs-util: fix creating recursive read-only snapshots
When creating recursive read-only snapshots we need to mark the snapshot
writable immediately before creating subsnapshots within it, otherwise
the operation for it will fail.
2015-04-22 16:52:53 +02:00
Lennart Poettering 625728941d btrfs-util: be more careful when invoking btrfs file system ioctls
If we get passed an fd that does not refer to a regular file or
directory, we should not issue btrfs ioctls on it, since it might end up
in a device driver or similar (note that DRM for example uses the same
ioctl numbers as some file system ioctls).

Hence, let's make sure to always check if something is a regular file or
directory, or is on btrfs before invoking the respective ioctls. It's
better to be safe than sorry.
2015-04-22 13:27:53 +02:00
Lennart Poettering 21222ea5cd btrfs-util: introduce btrfs_is_filesystem() and make use of it where appropriate
Let's unify the code that checks whether an fd is on btrfs a bit.

(Also, rename btrfs_is_snapshot() to btrfs_is_subvol(), since that's
usually how this is referred to in our code)
2015-04-22 13:27:53 +02:00
Lennart Poettering 03091baac3 util: make sure fd refers to regular file or directory when applying file attributes
Before invoking file system ioctls we need to make sure that the
specified fd actually refers to a file system object, and not a device
node or similar. Otherwise we might by accident invoke unrelated device
driver ioctls. For example, DRM ioctls use the same ioctl numbers as the
various file system ioctls.
2015-04-22 13:27:53 +02:00
Lennart Poettering e911de996a core: make unit deserialization more defensive 2015-04-21 20:23:41 +02:00
Lennart Poettering 10a8700606 tree-wide: get rid of more strerror() calls 2015-04-21 18:05:44 +02:00
Lennart Poettering 158350e869 log: move log_syntax() into src/shared/log.c, and make it more similar to the other log functions 2015-04-21 17:43:55 +02:00
Raul Gutierrez S 30a5b7820c util: fix typo 2015-04-20 08:54:01 +02:00
Martin Pitt 9f8f87e375 exit-status: Fix "NOTINSSTALLED" typo 2015-04-18 22:38:13 +01:00
Tom Gundersen aa02962840 shared: move assert_return_errno() from libudev
This should not be used for any new code, as we don't set errno in new code,
but there are several legacy users, so let's keep it in shared.
2015-04-16 16:47:23 +01:00
Zbigniew Jędrzejewski-Szmek 3ef11dcfde shared/hashmap: normalize whitespace 2015-04-12 16:59:04 -04:00
David Herrmann ad922737f7 bus: implement bus_label_unescape_n()
This is like bus_label_unescape() but takes a maximum length instead of
relying on NULL-terminated strings. This is highly useful to unescape
labels that are not at the end of a path.
2015-04-11 13:14:57 +02:00
David Herrmann cfe561a456 hashmap: return NULL from destructor
We _always_ return NULL from destructors to allow direct assignments to
the variable holding the object. Especially on hashmaps, which treat NULL
as empty hashmap, this is pretty neat.
2015-04-11 13:14:41 +02:00
Ronny Chevalier 3c8000956a shared: move replace_env* from util to env-util 2015-04-11 00:34:03 +02:00
Ronny Chevalier 288a74cce5 shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
Ronny Chevalier 3df3e884ae shared: add random-util.[ch] 2015-04-11 00:11:13 +02:00
Ronny Chevalier 0b452006de shared: add process-util.[ch] 2015-04-10 23:54:49 +02:00
Ronny Chevalier 6482f6269c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
Thomas Hindoe Paaboel Andersen 733dbdc534 efivars: fix build for non-efi 2015-04-10 23:00:07 +02:00
Tom Gundersen 2e036c4eae shared: boot-timestamps - remove ifdef
No need to ifdef out efi code as the functions are always defined.
2015-04-10 19:55:49 +02:00
Tom Gundersen b28ce7c6db shared: efivars - fix compile on non-EFI systems
systemctl and logind were unconditionally using functions that were not compiled
on non-EFI systems. Add stubs returning -EOPNOTSUPP to fix compile again.
2015-04-10 19:55:49 +02:00
Tom Gundersen 9df49b3358 shared: efivars - is_efi_*() returns bool instead of int
There was a bug where is_efi_*() could return a negative error value, which would be treated as 'true',
just make this a bool in the helper library to avoid the problem.
2015-04-10 19:55:49 +02:00
Lennart Poettering f0bc504794 device-nodes: minor simplifications 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 6dd67163b8 util: remove normalize_env_assignment(), it's unused 2015-04-10 16:23:46 +02:00
Ronny Chevalier 0d67448869 shared: fix memleak
path was used for 2 purposes but it was not freed before being reused.
2015-04-10 15:44:02 +02:00
Lennart Poettering e1eaca26cb util: mark unquote() static, so that new code doesn't use this anymore 2015-04-10 12:16:54 +02:00
Lennart Poettering 8ebac1f9a6 util: fix unicode decoding in unquote_first_word() 2015-04-10 11:56:04 +02:00
Lennart Poettering f3ee629711 util: when unescaping C escape sequences support C++11 \u and \U unicode literals
We simply recode them in utf8.
2015-04-10 11:28:34 +02:00
Thomas Hindoe Paaboel Andersen 96406c1a27 util: fix a typo in comment 2015-04-09 23:58:28 +02:00
Ronny Chevalier cd977dca10 util: cunescape - fix memleak in error path 2015-04-09 18:47:52 +02:00
Lennart Poettering 019c7fba75 util: add shell_maybe_quote() call for preparing a string for shell cmdline inclusion
If necessary the passed string is enclosed in "", and all special
characters escapes.

This also ports over usage in bus-util.c and job.c to use this, instead
of a incorrect local implementation that forgets to properly escape.
2015-04-09 18:32:21 +02:00
Lennart Poettering 1ed8f8c16d util: merge change_attr_fd() and chattr_fd() 2015-04-08 20:47:35 +02:00
Lennart Poettering 4a280a7e78 util: add minimal OrderedSet type
OrderedSet implements a Set-like structure, but maintains insertion
ordered. It is hence to Set what OrderedHashmap is for Hashmap.

Internally, this is only a wrapper around OrderedHashmap for now, but
this could one day be improved and be added to hashmap.c natively.
2015-04-08 17:22:15 +02:00
Alexander Sverdlin b06ac35c79 missing.h: Define IFA_F_NOPREFIXROUTE
Fixes second systemd compilation problem against Linux 3.12 uapi
headers.

IFA_F_NOPREFIXROUTE is a usual #define appeared in Linux 3.14, so
AC_CHECK_DECLS is not necessary.
2015-04-08 12:59:40 +02:00
Ronny Chevalier 39505e3c3b remove duplicated includes 2015-04-08 02:42:50 +02:00
Lennart Poettering 34f7b9f98f missing.h: define IFA_FLAGS if it is missing 2015-04-07 21:09:18 +02:00
Jan Janssen 5bdf22430e logind,systemctl: add reboot to EFI firmware support 2015-04-07 18:51:45 +02:00
Lennart Poettering da00518b3f path-util: fix more path_is_mount e792e890f fallout 2015-04-07 16:03:45 +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