1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 10:25:37 +03:00
Commit Graph

22076 Commits

Author SHA1 Message Date
Piotr Drąg
eb3ef64961 Updated Polish translation 2015-09-06 20:42:16 +02:00
Lennart Poettering
480a4b9777 Merge pull request #1153 from evverx/dot-alias-handling
analyze: add "alias" handling to dot subcommand
2015-09-06 12:34:09 +02:00
Evgeny Vereshchagin
83efb7c227 analyze: add "alias" handling to dot subcommand
`systemd-analyze dot default.target` works fine
2015-09-06 06:10:16 +03:00
Lennart Poettering
25b31f2fbd Merge pull request #1159 from AnchorCat/polkit-details/v2
Provide unit name and operation in manage-units polkit checks (v2)
2015-09-06 02:00:05 +02:00
Lennart Poettering
9efce95846 Merge pull request #1162 from dvdhrm/bus-recursive-nodes
sd-bus: make introspection data non-recursive
2015-09-06 01:58:48 +02:00
Lennart Poettering
87766aa462 Merge pull request #1161 from dvdhrm/include-order2
CODING_STYLE: mandate alphabetical include order (v2)
2015-09-06 01:30:08 +02:00
Kay Sievers
718909ec33 Merge pull request #1160 from dvdhrm/bus-user
sd-bus: derive uid from cgroup if possible
2015-09-05 23:06:31 +02:00
David Herrmann
44eb1adda9 sd-bus: make introspection data non-recursive
Currently, our introspection data looks like this:

        <node>
         <interface name="org.freedesktop.DBus.Peer">
           ...
         </interface>
         <interface name="org.freedesktop.DBus.Introspectable">
           ...
         </interface>
         <interface name="org.freedesktop.DBus.Properties">
           ...
         </interface>
         <node name="org"/>
         <node name="org/freedesktop"/>
         <node name="org/freedesktop/login1"/>
         <node name="org/freedesktop/login1/user"/>
         <node name="org/freedesktop/login1/user/self"/>
         <node name="org/freedesktop/login1/user/_1000"/>
         <node name="org/freedesktop/login1/seat"/>
         <node name="org/freedesktop/login1/seat/self"/>
         <node name="org/freedesktop/login1/seat/seat0"/>
         <node name="org/freedesktop/login1/session"/>
         <node name="org/freedesktop/login1/session/self"/>
         <node name="org/freedesktop/login1/session/c1"/>
        </node>

(ordered alphabetically for better visibility)

This is grossly incorrect. The spec says that we're allowed to return
non-directed children, however, it does not allow us to return data
recursively in multiple parents. If we return "org", then we must not
return anything else that starts with "org/".

It is unclear, whether we can include child-nodes as a tree. Moreover, it
is usually not what the caller wants. Hence, this patch changes sd-bus to
never return introspection data recursively. Instead, only a single
child-layer is returned.

This patch relies on enumerators to never return hierarchies. If someone
registers an enumerator via sd_bus_add_enumerator, they better register
sub-enumerators if they support *TRUE* hierarchies. Each enumerator is
treated as a single layer and not filtered.
Enumerators are still allowed to return nested data. However, that data
is still required to be a single hierarchy. For instance, returning
"/org/foo" and "/com/bar" is fine, but including "/com" or "/org" in that
dataset is not.
This should be the default for enumerators and I see no reason to filter
in sd-bus. Moreover, filtering that data-set would require to sort the
strv by path and then do prefix-filtering. This is O(n log n), which
would be fine, but still better to avoid.

Fixes #664.
2015-09-05 19:43:29 +02:00
David Herrmann
b47c788854 TODO: update networkd section
Remove two freshly implemented features, and add TSO support as a new
one.
2015-09-05 18:29:14 +02:00
David Herrmann
54c1f2d761 CODING_STYLE: mandate alphabetical include order
systemd-internal headers must not rely on include order. That means, they
either must contain forward-declarations of used types/functions, or they
must include all dependencies on their own. Therefore, there is no reason
to mandate an include order on the call-side.

However, global includes should always be ordered first. We don't want
local definitions to leak into global includes, possible changing their
behavior. Apparently, namespacing is a complex problem that people are
incapable of implementing properly..

Apart from "global before local", there is no reason to mandate a random
include order (which we happen to do right now). Instead, mandate
alphabetical ordering. The current rules do not have any benefit at all.
They neither reduce include-complexity, nor allow easy auditing of
include files. But with alphabetical ordering, we get duplicate-detection
for free, it gets *much much* easier to figure out whether a header is
already included, and it is trivial to add new headers.
2015-09-05 18:24:26 +02:00
David Herrmann
64ce4ad758 sd-bus: derive uid from cgroup if possible
Whenever we run in a user context, sd_bus_{default_user,open_user}() and
friends should always connect to the user-bus of the current context,
instead of deriving the uid from getuid(). This allows us running
programs via sudo/su, without the nasty side-effect of accidentally
connecting to the root user-bus.

This patch enforces the idea of making su/sudo *not* opening sessions by
default. That is, all they do is raising privileges, but keeping
everything set as before. You can still use su/sudo to open real sessions
by requesting a login-session (or loading pam_systemd otherwise).
However, in this case XDG_RUNTIME_DIR= will not be set (as usual in these
cases), hence, you will not be able to connect to *any* user-bus.

Long story short: With this patch applied, both:
        - ./busctl --user
        - sudo ./busctl --user
..will successfully connect to the user-bus of the local user.

Fixes #390.
2015-09-05 18:07:53 +02:00
Michael Chapman
88ced61bf9 core: pass details to polkit for some unit actions
The following details are passed:

- unit: the primary name of the unit upon which the action was
        invoked (i.e. after resolving any aliases);
- verb: one of 'start', 'stop', 'reload', 'restart', 'try-restart',
        'reload-or-restart', 'reload-or-try-restart', 'kill',
        'reset-failed', or 'set-property', corresponding to the
        systemctl verb used to invoke the action.

Typical use of these details in a polkit policy rule might be:

  // Allow alice to manage example.service;
  // fall back to implicit authorization otherwise.
  polkit.addRule(function(action, subject) {
      if (action.id == "org.freedesktop.systemd1.manage-units" &&
          action.lookup("unit") == "example.service" &&
          subject.user == "alice") {
          return polkit.Result.YES;
      }
  });

We also supply a custom polkit message that includes the unit's name and
the requested operation.
2015-09-06 00:07:17 +10:00
Michael Chapman
403ed0e5c9 bus-util: support details in CheckAuthorization calls
Extra details for an action can be supplied when calling polkit's
CheckAuthorization method. Details are a list of key/value string pairs.
Custom policy can use these details when making authorization decisions.
2015-09-06 00:07:16 +10:00
David Herrmann
17258f5f27 Merge pull request #1140 from poettering/sd-event-signals
A variety of sd-event, sd-login and cgroup fixes
2015-09-05 15:20:21 +02:00
Lennart Poettering
a67c56bff4 sd-login: minor header commenting improvements 2015-09-05 14:56:23 +02:00
Lennart Poettering
f5aaf57562 sd-login: add new sd_pid_get_cgroup() API
This adds a new sd_pid_get_cgroup() call to sd-login which may be used
to query the control path of a process. This is useful for programs when
making use of delegation units, in order to figure out which subtree has
been delegated.

In light of the unified control group hierarchy this is finally safe to
do, hence let's add a proper API for it, to make it easier to use this.
2015-09-05 14:56:23 +02:00
Daniel Mack
c7430c3d1a Merge pull request #1157 from dvdhrm/logind-wallfix
login: fix NULL-deref on wall_message
2015-09-05 14:33:56 +02:00
Daniel Mack
a2b8814fa6 Merge pull request #1145 from systemd-mailing-devs/1441372815-12195-1-git-send-email-hdegoede@redhat.com
hwdb: Add Thinkpad T550 / W550s to 70-pointingstick.hwdb
2015-09-05 14:32:56 +02:00
David Herrmann
3d1c455f9a login: fix NULL-deref on wall_message
We treat an empty wall-message equal to a NULL wall-message since:

        commit 5744f59a3e
        Author: Lennart Poettering <lennart@poettering.net>
        Date:   Fri Sep 4 10:34:47 2015 +0200

            logind: treat an empty wall message like a NULL one

Fix the shutdown scheduler to not deref a NULL pointer, but properly
check for an empty wall-message.

Fixes: #1120
2015-09-05 12:56:04 +02:00
Lennart Poettering
335250e7bd Merge pull request #1150 from evverx/update-systemctl-completion
shell-completion: update systemctl bash completion
2015-09-05 12:25:52 +02:00
Lennart Poettering
33ce5f6a0b Merge pull request #1149 from martinpitt/fix-dhcp-error-codes
networkd: adjust error codes for nonexisting DHCP data
2015-09-05 12:21:20 +02:00
Lennart Poettering
f4906a277b Merge pull request #1146 from martinpitt/master
tests: Skip tests which need to access /sys/fs/cgroup if that is not …
2015-09-05 12:14:55 +02:00
David Herrmann
c9912c5eaf NEWS: add entries for v226
Initial set of features for the upcoming v226 release next week. This is
mostly about the unified cgroup hierarchy and DHCP.
2015-09-05 11:09:44 +02:00
Evgeny Vereshchagin
3a221b5df8 shell-completion: update systemctl bash completion
Many new options have been added since the bash completion was last
updated.
2015-09-04 23:04:10 +03:00
Martin Pitt
397d15fd39 networkd: adjust error codes for nonexisting DHCP data
Commit 0339cd770 changed libsystemd-network's error code for missing DHCP lease
data from ENOENT to ENODATA. Adjust networkd accordingly.

This fixes interfaces being stuck in "degraded/configuring" mode forever.

https://github.com/systemd/systemd/issues/1147
2015-09-04 21:22:44 +02:00
Martin Pitt
3b3a64d754 tests: Skip tests which need to access /sys/fs/cgroup if that is not available
Commit efdb023 ("core: unified cgroup hierarchy support") introduced a new
error ENOEXEC in cg_unified() if /sys/fs/cgroup/ is not available. Adjust the
"skip" checks in various tests accordingly.

Add a corresponding "skip" check to test-bus-creds as well, as
sd_bus_creds_new_from_pid() now calls cg_unified() as well.

This re-fixes "make check" in build chroots without /sys/fs/cgroup.

https://github.com/systemd/systemd/issues/1132
2015-09-04 16:34:21 +02:00
Hans de Goede
056119922d hwdb: Add Thinkpad T550 / W550s to 70-pointingstick.hwdb
Like many other recent thinkpads the factory default pointingstick
sensitivity on these devices is quite low, making the pointingstick
very slow in moving the cursor.

This extends the existing hwdb rules for tweaking the sensitivity to
also apply to the T550 / W550s models.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1200717
2015-09-04 16:01:41 +02:00
Lennart Poettering
794ec1eb8b Merge pull request #1142 from dvdhrm/proxy-nofile
bus-proxy: increase NOFILE limit
2015-09-04 12:45:10 +02:00
Daniel Mack
f6bd4cb69e Merge pull request #1141 from poettering/logind-fixes
Various logind fixes
2015-09-04 12:13:45 +02:00
David Herrmann
ed15589c98 bus-proxy: increase NOFILE limit
The bus-proxy manages the kdbus connections of all users on the system
(regarding the system bus), hence, it needs an elevated NOFILE.
Otherwise, a single user can trigger ENFILE by opening NOFILE connections
to the bus-proxy.

Note that the bus-proxy still does per-user accounting, indirectly via
the proxy/fake API of kdbus. Hence, the effective per-user limit is not
raised by this. However, we now prevent one user from consuming the whole
FD limit of the shared proxy.

Also note that there is no *perfect* way to set this. The proxy is a
shared object, so it needs a larger NOFILE limit than the highest limit
of all users. This limit can be changed dynamically, though. Hence, we
cannot protect against it. However, a raised NOFILE limit is a privilege,
so we just treat it as such and basically allow these privileged users to
be able to consume more resources than normal users (and, maybe, cause
some limits to be exceeded by this).

Right now, kdbus hard-codes 1024 max connections per user on each bus.
However, we *must not* rely on this. This limits could be easily dropped
entirely, as the NOFILE limit is a suitable limit on its on.
2015-09-04 11:13:32 +02:00
Lennart Poettering
2cf088b56d logind: when parsing a boolean via sd-bus the type must be "int"
And not bool.
2015-09-04 10:36:08 +02:00
Lennart Poettering
5744f59a3e logind: treat an empty wall message like a NULL one 2015-09-04 10:34:47 +02:00
Lennart Poettering
19af675e99 cgroups: delegation to unprivileged services is safe in the unified hierarchy
Delegation to unpriviliged processes is safe in the unified hierarchy,
hence allow it. This has the benefit of permitting "systemd --user"
instances to further partition their resources between user services.
2015-09-04 09:23:07 +02:00
Lennart Poettering
707b66c663 sd-login: rework error handling
Makre sure we always return sensible errors for the various, following
the same rules, and document them in a comment in sd-login.c. Also,
update all relevant man pages accordingly.
2015-09-04 09:07:31 +02:00
Lennart Poettering
9da4cb2be2 sd-event: make sure RT signals are not dropped
RT signals operate in a queue, and we should be careful to never merge
two queued signals into one. Hence, makes sure we only ever dequeue a
single signal at a time and leave the remaining ones queued in the
signalfd. In order to implement correct priorities for the signals
introduce one signalfd per priority, so that we only process the highest
priority signal at a time.
2015-09-04 09:07:31 +02:00
Lennart Poettering
348637b28a test: add one more test case for parse_pid() 2015-09-04 09:07:31 +02:00
Lennart Poettering
98e4d8d763 nspawn: enable all controllers we can for the "payload" subcgroup we create
In the unified hierarchy delegating controller access is safe, hence
make sure to enable all controllers for the "payload" subcgroup if we
create it, so that the container will have all controllers enabled the
nspawn service itself has.
2015-09-04 09:07:31 +02:00
Lennart Poettering
5f4c5fef66 cgroup: always read the supported controllers from the root cgroup of the local container
Otherwise we might end up thinking that we support more controllers than
actually enabled for the container we are running in.
2015-09-04 09:07:31 +02:00
Lennart Poettering
ba09d9c687 cgroup: fix potential access of uninitialized variable 2015-09-04 09:07:31 +02:00
Lennart Poettering
1c80e42512 cgroup-util: make cg_pid_get_path() return -ENODATA when controller can't be found
If the controller managed by systemd cannot found in /proc/$PID/cgroup,
return ENODATA, the usual error for cases where the data being looked
for does not exist, even if the process does.
2015-09-04 09:07:31 +02:00
Lennart Poettering
989189eabf cgroup: fix potential bad memory access 2015-09-04 09:07:31 +02:00
Lennart Poettering
9a66c87a23 cgroup: make sure cg_is_empty_recursive() returns 1 for non-existing cgroups
Previously, on the legacy hierarchy a non-existing cgroup was considered
identical to an empty one, but the unified hierarchy the check for a
non-existing one returned ENOENT.
2015-09-04 09:07:31 +02:00
Lennart Poettering
b8725df8b3 cgroup: when comparing agent paths, use path_equal()
After all a path is a path is a path and we should use path_equal() to
comapre those.
2015-09-04 09:07:31 +02:00
Lennart Poettering
d7e46e01ac audit: audit calls should return ENODATA when process are not in an audit session
ENODATA is how we usually indicate such "missing info" cases, so we
should do this here, too.
2015-09-04 09:07:31 +02:00
Lennart Poettering
ef5c570edf util: document why parse_uid() returns ENXIO
parse_uid() returns EINVAL for invalid strings, but ENXIO for the
(uid_t) -1 user ids in order to distinguish these two cases. Document
this.
2015-09-04 09:07:31 +02:00
Lennart Poettering
b3ac818be8 core: split up manager_get_unit_by_pid()
Let's move the actual cgroup part of it into a new separate function
manager_get_unit_by_pid_cgroup(), and then make
manager_get_unit_by_pid() just a wrapper that also checks the two pid
hashmaps.

Then, let's make sure the various calls that want to deliver events to
the owners of a PID check both hashmaps and the cgroup and deliver the
event to *each* of them. OTOH make sure bus calls like GetUnitByPID()
continue to check the PID hashmaps first and the cgroup only as
fallback.
2015-09-04 09:07:31 +02:00
Lennart Poettering
569b19d8fe cgroup: move controller to dirname translation into join_path_legacy()
Let's simplify things a bit.
2015-09-04 09:07:30 +02:00
Lennart Poettering
a1f686daf5 util: add new uid_is_valid() call
This simply factors out the uid validation checks from parse_uid() and
uses them everywhere. This simply verifies that the passed UID is
neither 64bit -1 nor 32bit -1.
2015-09-04 09:07:30 +02:00
Lennart Poettering
fea72cc033 macro: introduce new PID_TO_PTR macros and make use of them
This adds a new PID_TO_PTR() macro, plus PTR_TO_PID() and makes use of
it wherever we maintain processes in a hash table. Previously we
sometimes used LONG_TO_PTR() and other times ULONG_TO_PTR() for that,
hence let's make this more explicit and clean up things.
2015-09-04 09:07:30 +02:00
Lennart Poettering
a8ba86ce6a man: always use the same example in nss module documentation
Show the same recommended example file in all three man pages, just
highlight the different, relevant parts.

This should be less confusing for users, and clarify what we actually
recommend how /etc/nsswitch.conf is set up.
2015-09-04 09:07:30 +02:00