Commit Graph

34 Commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering bb0c0d6f29 core: add credentials logic
Fixes: #15778 #16060
2020-08-25 19:45:35 +02:00
Lennart Poettering e04ed6db6b exit-status: rename EXIT_STATUS_GLIBC → EXIT_STATUS_LIBC
After all these two exit codes are defined by ISO C as part of the C
library, and it's not the GNU implementation defines them.
2019-07-29 19:05:25 +02:00
Zbigniew Jędrzejewski-Szmek 23d5dd1687 shared/exit-status: use Bitmap instead of Sets
I opted to embed the Bitmap structure directly in the ExitStatusSet.
This means that memory usage is a bit higher for units which don't define
this setting:

Service changes:
        /* size: 2720, cachelines: 43, members: 73 */
        /* sum members: 2680, holes: 9, sum holes: 39 */
        /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */
        /* last cacheline: 32 bytes */

        /* size: 2816, cachelines: 44, members: 73 */
        /* sum members: 2776, holes: 9, sum holes: 39 */
        /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */

But this way the code is simpler and we do less pointer chasing.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek f0d67dcddd shared/exit-status: add exit_status_from_string() 2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek e1714f0250 shared/exit-status: turn status level into a bitmask, add "test"
The "test" doesn't really test much automatically, but it is still useful
to look at the mappings.
2019-07-29 15:54:45 +02:00
Michal Sekletar b070c7c0e1 core: introduce NUMAPolicy and NUMAMask options
Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.

Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.
2019-06-24 16:58:54 +02:00
Lennart Poettering 3584d3ca4f exit-status: introduce EXIT_EXCEPTION mapping to 255 2018-11-20 17:04:07 +01:00
Zbigniew Jędrzejewski-Szmek d284b82b3e Move various files that don't need to be in basic/ to shared/
This doesn't have much effect on the final build, because we link libbasic.a
into libsystemd-shared.so, so in the end, all the object built from basic/
end up in libsystemd-shared. And when the static library is linked into binaries,
any objects that are included in it but are not used are trimmed. Hence, the
size of output artifacts doesn't change:

$ du -sb /var/tmp/inst*
54181861	/var/tmp/inst1    (old)
54207441	/var/tmp/inst1s   (old split-usr)
54182477	/var/tmp/inst2    (new)
54208041	/var/tmp/inst2s   (new split-usr)

(The negligible change in size is because libsystemd-shared.so is bigger
by a few hundred bytes. I guess it's because symbols are named differently
or something like that.)

The effect is on the build process, in particular partial builds. This change
effectively moves the requirements on some build steps toward the leaves of the
dependency tree. Two effects:
- when building items that do not depend on libsystemd-shared, we
  build less stuff for libbasic.a (which wouldn't be used anyway,
  so it's a net win).
- when building items that do depend on libshared, we reduce libbasic.a as a
  synchronization point, possibly allowing better parallelism.

Method:
1. copy list of .h files from src/basic/meson.build to /tmp/basic
2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less
2018-11-20 07:27:37 +01:00
Kay Sievers a095315b3c build-sys: split internal basic/ library from shared/
basic/      can be used by everything
            cannot use anything outside of basic/

libsystemd/ can use basic/
            cannot use shared/

shared/     can use libsystemd/
2015-06-11 10:52:46 +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
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
Daniel Mack 060e088e94 exit-status: add new exit code for custom endpoint errors 2014-09-08 14:12:56 +02:00
Daniel Mack 5b89f67f03 exit-status: fix URL in comment
The LSB sites have moved, so update the URL.
2014-09-05 13:48:05 +02:00
Lennart Poettering 55ebf98cbe core: introduce exit_status_set_is_empty() to make things a bit easier to read 2014-07-03 15:50:31 +02:00
Lennart Poettering 3e2d435b3d exit-status: rename ExitStatusSet's "code" field to "status"
We should follow the naming scheme waitid() uses, not come up with our
own reversed one...
2014-07-03 15:37:46 +02:00
Lennart Poettering 37520c1bec core: introduce new RestartForceExitStatus= service setting
This does the inverse of RestartPreventExitStatus=: it forces a restart
of a service when a certain exit status is returned by a service
process.
2014-07-03 12:51:07 +02:00
Lennart Poettering a4152e3fe2 kdbus: when uploading bus name policy, resolve users/groups out-of-process
It's not safe invoking NSS from PID 1, hence fork off worker processes
that upload the policy into the kernel for busnames.
2014-06-05 13:09:46 +02:00
Lennart Poettering 3900e5fdff socket: add SocketUser= and SocketGroup= for chown()ing sockets in the file system
This is relatively complex, as we cannot invoke NSS from PID 1, and thus
need to fork a helper process temporarily.
2014-06-05 09:55:53 +02:00
Lennart Poettering 7f8aa67131 core: remove tcpwrap support
tcpwrap is legacy code, that is barely maintained upstream. It's APIs
are awful, and the feature set it exposes (such as DNS and IDENT
access control) questionnable. We should not support this natively in
systemd.

Hence, let's remove the code. If people want to continue making use of
this, they can do so by plugging in "tcpd" for the processes they start.
With that scheme things are as well or badly supported as they were from
traditional inetd, hence no functionality is really lost.
2014-03-24 20:07:42 +01:00
Lennart Poettering 4d7213b274 core: move ShowStatus type into the core
Let's make the scope of the show-status stuff a bit smaller, and make it
private to the core, rather than shared API in shared/.
2014-03-03 21:23:12 +01:00
Lennart Poettering e66cf1a3f9 core: introduce new RuntimeDirectory= and RuntimeDirectoryMode= unit settings
As discussed on the ML these are useful to manage runtime directories
below /run for services.
2014-03-03 17:55:32 +01:00
Lennart Poettering 4298d0b512 core: add new RestrictAddressFamilies= switch
This new unit settings allows restricting which address families are
available to processes. This is an effective way to minimize the attack
surface of services, by turning off entire network stacks for them.

This is based on seccomp, and does not work on x86-32, since seccomp
cannot filter socketcall() syscalls on that platform.
2014-02-26 02:19:28 +01:00
Michael Scherer eef65bf3ee core: Add AppArmor profile switching
This permit to switch to a specific apparmor profile when starting a daemon. This
will result in a non operation if apparmor is disabled.
It also add a new build requirement on libapparmor for using this feature.
2014-02-21 03:44:20 +01:00
Lennart Poettering ac45f971a1 core: add Personality= option for units to set the personality for spawned processes 2014-02-19 03:27:03 +01:00
Lennart Poettering b6e2f3293d core: fixate show_status earlier, so that we actually print the welcome message
Previously, we'd fixed show_state only after printing the welcome
message which had the effect that the welcome message was almost always
suppressed.
2014-02-17 16:17:08 +01:00
Michael Scherer 7b52a628f8 exec: Add SELinuxContext configuration item
This permit to let system administrators decide of the domain of a service.
This can be used with templated units to have each service in a différent
domain ( for example, a per customer database, using MLS or anything ),
or can be used to force a non selinux enabled system (jvm, erlang, etc)
to start in a different domain for each service.
2014-02-10 13:18:16 +01:00
Zbigniew Jędrzejewski-Szmek d450b6f2a9 manager: add systemd.show_status=auto mode
When set to auto, status will shown when the first ephemeral message
is shown (a job has been running for five seconds). Then until the
boot or shutdown ends, status messages will be shown.

No indication about the switch is done: I think it should be clear
for the user that first the cylon eye and the ephemeral messages appear,
and afterwards messages are displayed.

The initial arming of the event source was still wrong, but now should
really be fixed.
2014-01-27 23:17:03 -05:00
Zbigniew Jędrzejewski-Szmek 44a6b1b680 Add __attribute__((const, pure, format)) in various places
I'm assuming that it's fine if a _const_ or _pure_ function
calls assert. It is assumed that the assert won't trigger,
and even if it does, it can only trigger on the first call
with a given set of parameters, and we don't care if the
compiler moves the order of calls.
2013-05-02 22:52:09 -04:00
Lukas Nykryn 96342de68d service: add options RestartPreventExitStatus and SuccessExitStatus
In some cases, like wrong configuration, restarting after error
does not help, so administrator can specify statuses by RestartPreventExitStatus
which will not cause restart of a service.

Sometimes you have non-standart exit status, so this can be specified
by SuccessfulExitStatus.
2012-08-14 14:46:03 +02:00
Shawn Landden c2f1db8f83 use #pragma once instead of foo*foo #define guards
#pragma once has been "un-deprecated" in gcc since 3.3, and is widely supported
in other compilers.

I've been using and maintaining (rebasing) this patch for a while now, as
it annoyed me to see #ifndef fooblahfoo, etc all over the place,
almost arrogant about the annoyance of having to define all these names to
perform a commen but neccicary functionality, when a completely superior
alternative exists.

I havn't sent it till now, cause its kindof a style change, and it is bad
voodoo to mess with style that has been established by more established
editors. So feel free to lambast me as a crazy bafoon.

v2 - preserve externally used headers
2012-07-19 12:30:59 +02:00
Lennart Poettering 8351ceaea9 execute: support syscall filtering using seccomp filters 2012-07-17 04:17:53 +02:00
Lennart Poettering 5430f7f2bc relicense to LGPLv2.1 (with exceptions)
We finally got the OK from all contributors with non-trivial commits to
relicense systemd from GPL2+ to LGPL2.1+.

Some udev bits continue to be GPL2+ for now, but we are looking into
relicensing them too, to allow free copy/paste of all code within
systemd.

The bits that used to be MIT continue to be MIT.

The big benefit of the relicensing is that closed source code may now
link against libsystemd-login.so and friends.
2012-04-12 00:24:39 +02:00
Kay Sievers d7832d2c6e util: move all to shared/ and split external dependencies in separate internal libraries
Before:
  $ ldd /lib/systemd/systemd-timestamp
  linux-vdso.so.1 =>  (0x00007fffb05ff000)
  libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f90aac57000)
  libcap.so.2 => /lib64/libcap.so.2 (0x00007f90aaa53000)
  librt.so.1 => /lib64/librt.so.1 (0x00007f90aa84a000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f90aa494000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f90aae90000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007f90aa290000)
  libattr.so.1 => /lib64/libattr.so.1 (0x00007f90aa08a000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f90a9e6e000)

After:
  $ ldd systemd-timestamp
  linux-vdso.so.1 =>  (0x00007fff3cbff000)
  libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5eaa1c3000)
  librt.so.1 => /lib64/librt.so.1 (0x00007f5ea9fbb000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f5ea9c04000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f5eaa3fc000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007f5ea9a00000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5ea97e4000)
2012-04-10 14:13:38 +02:00
Renamed from src/exit-status.h (Browse further)