Commit graph

1446 commits

Author SHA1 Message Date
Josh Triplett 7f0a55d432 Introduce CONF_DIRS_NULSTR helper to define standard conf dirs
Several different systemd tools define a nulstr containing a standard
series of configuration file directories, in /etc, /run, /usr/local/lib,
/usr/lib, and (#ifdef HAVE_SPLIT_USR) /lib.  Factor that logic out into
a new helper macro, CONF_DIRS_NULSTR.
2014-11-26 19:11:37 -05:00
Zbigniew Jędrzejewski-Szmek 4104970ef7 manager: log some fatal errors at emergency level
This adds a new log_emergency() function, which is equivalent to
log_error() for non-PID-1, and logs at the highest priority for PID 1.
Some messages which occur before freezing are converted to use it.
2014-11-26 15:16:53 -05:00
Lennart Poettering 2e8574290d util: mark page_size() as pure 2014-11-25 19:24:45 +01:00
Lennart Poettering 62028d9c2b util: skip incomplete ucred information in getpeersec() 2014-11-25 14:28:34 +01:00
WaLyong Cho 2ca620c4ed smack: introduce new SmackProcessLabel option
In service file, if the file has some of special SMACK label in
ExecStart= and systemd has no permission for the special SMACK label
then permission error will occurred. To resolve this, systemd should
be able to set its SMACK label to something accessible of ExecStart=.
So introduce new SmackProcessLabel. If label is specified with
SmackProcessLabel= then the child systemd will set its label to
that. To successfully execute the ExecStart=, accessible label should
be specified with SmackProcessLabel=.
Additionally, by SMACK policy, if the file in ExecStart= has no
SMACK64EXEC then the executed process will have given label by
SmackProcessLabel=. But if the file has SMACK64EXEC then the
SMACK64EXEC label will be overridden.

[zj: reword man page]
2014-11-24 10:20:53 -05:00
Zbigniew Jędrzejewski-Szmek b63bd1090b Do not check for existence of remote binaries
systemd-run would fail when run with -M or -H and an absolute path,
if this path did not exists locally. Allow it to continue, since we
don't have a nice way of checking if the binary exists remotely.

The case where -M or -H is used and a local path is unchanged, and we
still iterate over $PATH to find the binary. We need to convert to an
absolute path, and we don't have a nice mechanism to check remotely,
so we assume that the binary will be located in the same place locally
and remotely.

http://lists.freedesktop.org/archives/systemd-devel/2014-November/025418.html
2014-11-22 18:01:43 -05:00
Zbigniew Jędrzejewski-Szmek 8ecec322fe missing: add IFLA_BRPORT_LEARNING and friends
IFLA_BRPORT_LEARNING was added in v3.10-rc4-583-g9ba18891f7,
and IFLA_BRPORT_UNICAST_FLOOD in v3.10-rc4-584-g867a59436f.
2014-11-22 17:12:44 -05:00
Zbigniew Jędrzejewski-Szmek 568981d2ac missing: add __NR_getrandom for a few more archs
Mips has getrandom() too, but there's just too many variants
for me too care. Either someone who cares does it, or they get
compile-time warnings with old kernel headers.
2014-11-22 12:04:53 -05:00
Jakub Filak ad450c3e04 util: add functions getting proc cwd and root
/proc/[pid]/cwd and /proc/[pid]/root are symliks to corresponding
directories

The added functions returns values of that symlinks.
2014-11-21 00:32:02 +01:00
Lennart Poettering 575ccc1b69 set: make set_consume() actually free the allocated string if the string already is in the set 2014-11-20 00:01:05 +01:00
Susant Sahani 9593d9d9d5 log: unchecked return value from library
fix 1237557 Unchecked return value from library
2014-11-17 10:57:00 +01:00
Lennart Poettering 781fa93815 busctl: add new "call" command to invoke methods on a service 2014-11-14 13:18:51 +01:00
Daniel Mack 63cc4c3138 sd-bus: sync with kdbus upstream (ABI break)
kdbus has seen a larger update than expected lately, most notably with
kdbusfs, a file system to expose the kdbus control files:

 * Each time a file system of this type is mounted, a new kdbus
   domain is created.

 * The layout inside each mount point is the same as before, except
   that domains are not hierarchically nested anymore.

 * Domains are therefore also unnamed now.

 * Unmounting a kdbusfs will automatically also detroy the
   associated domain.

 * Hence, the action of creating a kdbus domain is now as
   privileged as mounting a filesystem.

 * This way, we can get around creating dev nodes for everything,
   which is last but not least something that is not limited by
   20-bit minor numbers.

The kdbus specific bits in nspawn have all been dropped now, as nspawn
can rely on the container OS to set up its own kdbus domain, simply by
mounting a new instance.

A new set of mounts has been added to mount things *after* the kernel
modules have been loaded. For now, only kdbus is in this set, which is
invoked with mount_setup_late().
2014-11-13 20:41:52 +01:00
Lennart Poettering f88e6be5ee strv: rework strv_split_quoted() to use unquote_first_word()
This should make the unquoting scheme a bit less naive.
2014-11-10 23:45:12 +01:00
Ronny Chevalier c73d180dc4 shared: explicitly ignore the return value of wait_for_terminate
CID#1237532
CID#1237523
CID#1237522
2014-11-10 20:18:49 +01:00
Jan Synacek aedd4012f4 shared/install: when unit contains only Also=, report 'indirect'
If a unit contains only Also=, with no Alias= or WantedBy=, it shouldn't
be reported as static. New 'indirect' status shall be introduced.

https://bugzilla.redhat.com/show_bug.cgi?id=864298
2014-11-10 19:58:21 +01:00
Tom Gundersen 9a67bcf275 shared: add readlink_value
Reads the basename of the target of a symlink.
2014-11-07 19:46:14 +01:00
Lennart Poettering 144b3d9e09 utf8: when looking at the next unichar, honour the size parameter, in utf8_is_printable_newline() 2014-11-07 16:36:14 +01:00
Lennart Poettering f9aa541380 log: explicitly ignore return value of parse_proc_cmdline()
CID# 1251162
2014-11-07 16:36:14 +01:00
Lennart Poettering f4934dfaaa util: simplify normalize_env_assignment() a bit 2014-11-07 01:19:56 +01:00
Lennart Poettering b5e1fad5b1 util: file_is_priv_sticky() is used internally in util.c only nowadays, make it static 2014-11-07 01:19:56 +01:00
Lennart Poettering f32d2db140 util: rework /proc/cmdline parser to use unquote_first_word() 2014-11-07 01:19:56 +01:00
Lennart Poettering b5884878a2 util: simplify proc_cmdline() to reuse get_process_cmdline()
Also, make all parsing of the kernel cmdline non-fatal.
2014-11-07 01:19:56 +01:00
Lennart Poettering f2997962ff fileio: simplify write_string_file_atomic() by reusing write_string_stream() 2014-11-07 01:19:56 +01:00
Lennart Poettering 84ee096044 copy: change error code when hitting copy limit to EFBIG
After all, this is about files, not arguments, hence EFBIG is more
appropriate than E2BIG
2014-11-07 01:19:56 +01:00
Lennart Poettering cda134ab1e copy: teach copy_bytes() sendfile() support, and then replace sendfile_full() by it 2014-11-07 01:19:56 +01:00
Lennart Poettering 0c2576ef74 util: make use of isempty() where appropriate 2014-11-07 01:19:56 +01:00
Lennart Poettering 64e18fd626 switch-root: explain why we don't care about base_filesystem_create() failing 2014-11-06 20:00:01 +01:00
Michal Schmidt 2d58aa4692 shared: create files even if the SELinux policy has no context for them
The SELinux policy defines no context for some files. E.g.:
  $ matchpathcon /run/lock/subsys /dev/mqueue
  /run/lock/subsys        <<none>>
  /dev/mqueue     <<none>>

We still need to be able to create them.
In this case selabel_lookup_raw() returns ENOENT. We should then skip
setfscreatecon(), but still return success.
It was broken since c34255bdb2 ("label: unify code to make directories,
symlinks").
2014-11-06 17:02:21 +01:00
Harald Hoyer 6d0f91bf55 switch_root: do not fail, if base_filesystem_create() failed
Not all switch roots are like base_filesystem_create() wants them
to look like. They might even boot, if they are RO and don't have the FS
layout. Just ignore the error and switch_root nevertheless.

base_filesystem_create() should have logged, what went wrong.
2014-11-06 15:28:42 +01:00
Lennart Poettering 134e56dcc5 shared: rename condition-util.[ch] to condition.[ch]
Now that we only have one file with condition implementations around, we
can drop the -util suffix and simplify things a bit.
2014-11-06 14:21:11 +01:00
Lennart Poettering 651c33185e condition: order condition types the same way in man page, enum, tables
Yes, sometimes I develop OCD.
2014-11-06 14:21:11 +01:00
Lennart Poettering 59fccdc587 core: introduce the concept of AssertXYZ= similar to ConditionXYZ=, but fatal for a start job if not met 2014-11-06 14:21:11 +01:00
Lennart Poettering cc50ef134b condition: record test state internally and beef it up to be a full enum 2014-11-06 14:21:10 +01:00
Lennart Poettering b80ba1da1c condition: add more test cases 2014-11-06 14:21:10 +01:00
Lennart Poettering a4705396ad condition: internalize condition test functions
Also, implement the negation check inside of condition_test() instead of
individually in each test function.
2014-11-06 14:21:10 +01:00
Lennart Poettering d1bddcec98 condition: unify condition logic in one file 2014-11-06 14:21:10 +01:00
Lennart Poettering 592fd144ae condition: properly allow passing back errors from condition checks 2014-11-06 14:21:10 +01:00
Lennart Poettering 4a6ca457eb util: minor modernisations 2014-11-05 19:46:07 +01:00
Lennart Poettering 07318c2908 condition: rewrite condition_test_kernel_command_line() based on unquote_first_word() 2014-11-05 19:46:07 +01:00
Lennart Poettering a931ad47a8 core: introduce new Delegate=yes/no property controlling creation of cgroup subhierarchies
For priviliged units this resource control property ensures that the
processes have all controllers systemd manages enabled.

For unpriviliged services (those with User= set) this ensures that
access rights to the service cgroup is granted to the user in question,
to create further subgroups. Note that this only applies to the
name=systemd hierarchy though, as access to other controllers is not
safe for unpriviliged processes.

Delegate=yes should be set for container scopes where a systemd instance
inside the container shall manage the hierarchies below its own cgroup
and have access to all controllers.

Delegate=yes should also be set for user@.service, so that systemd
--user can run, controlling its own cgroup tree.

This commit changes machined, systemd-nspawn@.service and user@.service
to set this boolean, in order to ensure that container management will
just work, and the user systemd instance can run fine.
2014-11-05 18:49:14 +01:00
Tom Gundersen 617e794652 shared: unaligned - use void* instead of unaligned be16_t* 2014-11-05 16:54:22 +01:00
Tom Gundersen 7c63b23f49 shared: ptyfwd - make coverity happy
Explicitly ignore return value of ioctl to set window size.

Fixes CID#1250804 and CID#1250800.
2014-11-05 16:54:22 +01:00
Lennart Poettering db74cc0d47 util: when sealing memfds, also use F_SEAL_SEAL
Let's be strict here, since its better to be safe than sorry.
2014-11-04 18:52:34 +01:00
David Herrmann dfb05a1cf5 barrier: explicitly ignore return values of barrier_place()
The barrier implementation tracks remote states internally. There is no
need to check the return value of any barrier_*() function if the caller
is not interested in the result. The barrier helpers only return the state
of the remote side, which is usually not interesting as later calls to
barrier_sync() will catch this, anyway.

Shut up coverity by explicitly ignoring return values of barrier_place()
if we're not interested in it.
2014-11-04 09:49:43 +01:00
David Herrmann 44dd2c6e86 util: introduce negative_errno()
Imagine a constructor like this:

        int object_new(void **out) {
                void *my_object;
                int r;

                ...
                r = ioctl(...);
                if (r < 0)
                        return -errno;
                ...

                *out = my_object;
                return 0;
        }

We have a lot of those in systemd. If you now call those, gcc might inline
the call and optimize it. However, gcc cannot know that "errno" is
negative if "r" is. Therefore, a caller like this will produce warnings:

        r = object_new(&obj);
        if (r < 0)
                return r;

        obj->xyz = "foobar";

In case the ioctl in the constructor fails, gcc might assume "errno" is 0
and thus the error-handling is not triggered. Therefore, "obj" is
uninitialized, but accessed. Gcc will warn about that.

The new negative_errno() helper can be used to mitigate those warnings.
The helper is guaranteed to return a negative integer. Furthermore, it
spills out runtime warnings if "errno" is non-negative.

Instead of returning "-errno", you can use:
        return negative_errno();

gcc will no longer assume that this can return >=0, thus, it will not warn
about it.

Use this new helper in libsystemd-terminal to fix some grdev-drm warnings.
2014-11-04 08:27:31 +01:00
Vicente Olivert Riera e6c019026b Properly define the __NR_memfd_create macro for MIPS
This macro exists for MIPS since v3.17:
  https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=42944521af97a3b25516f15f3149aec3779656dc
2014-11-04 08:27:31 +01:00
Lennart Poettering 1248e84008 journal: when dumping log data with missing COMM fields, show "unknown" instead
A small readability improvement...
2014-11-04 00:28:33 +01:00
Lennart Poettering cfb1f5df7c core: introduce ConditionSecurity=audit
And conditionalize journald audit support with it
2014-11-03 21:51:28 +01:00
Lennart Poettering 875c2e220e journald: if available pull audit messages from the kernel into journal logs 2014-11-03 21:51:28 +01:00