1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 18:27:04 +03:00
Commit Graph

10089 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
ba52f15a58 networkctl: avoid potential use of unitialized variables
Those values are based on a file we read from disk, so we should
verify everything we receive, and make sure everything we print
is sensible.

Also, print fractional seconds for TTL.
2015-01-01 13:36:44 -05:00
Zbigniew Jędrzejewski-Szmek
1bf7dd6e7d networkctl: remove unused variable 2015-01-01 13:36:43 -05:00
Zbigniew Jędrzejewski-Szmek
ef75325319 network: fix scanf/printf format
usec_t is defined as 64 bit wide, but long is 32 bit on many archs.
2015-01-01 13:36:43 -05:00
Zbigniew Jędrzejewski-Szmek
e65ef51dee missing: add __NR_renameat2 2015-01-01 13:36:43 -05:00
Zbigniew Jędrzejewski-Szmek
2e219e5672 Remove "to allow" from policy messages
It carries no additional information and forces a passive sentence
structure which is longer and harder to parse.
2015-01-01 09:45:04 -05:00
Piotr Drąg
a4a57bb6ce machined: fix grammar in org.freedesktop.machine1.policy.in
[zj: change "in into" to "into".]

https://bugs.freedesktop.org/show_bug.cgi?id=87722
2015-01-01 09:45:04 -05:00
David Herrmann
ee14ebf211 lldp: fix sd_lldp_save()
Fix a bunch of needless memzero() calls, a bunch of use-after-free
regarding _cleanup_free_ and drop unused variables.

Hint: Do NOT use _cleanup_free_ for temporary strappend() helpers that are
freed multiple times. All you safe is the last free() call, which is
really not worth the trouble resetting it to NULL all the time.
2014-12-31 16:28:48 +01:00
David Herrmann
7d4866548d lldp: fix uninitialized cleanup var #2
Another uninitialized variable marked as _cleanup_. Set it to NULL to
avoid accessing uninitialized memory.
2014-12-31 16:07:17 +01:00
David Herrmann
e7a2419a2a lldp: fix uninitialized cleanup var
Make sure to set _cleanup_ variables to NULL. Otherwise, we free
uninitialized objects.
2014-12-31 16:04:55 +01:00
David Herrmann
c5285fbfce import: fix mem-leak in CurlGlue
Make sure to actually free the underlying object in CurlGlue unref.
2014-12-31 16:01:37 +01:00
David Herrmann
580e55da11 lldp: fix double free
'k' is marked as _cleanup_free_ so reset it to NULL if we free it
explicitly.
2014-12-31 15:58:27 +01:00
David Herrmann
fbee1d8587 networkctl: fix strappend() error checking
Make sure to test the right variable for NULL.
2014-12-31 15:56:11 +01:00
David Herrmann
889cec8d58 network: add malloc-assertion in test
Make sure malloc() really returns non-NULL in lldp test.
2014-12-31 15:55:10 +01:00
David Herrmann
06a079055a machinectl: remove dead code
'r' is not touched after the previous error-checking 100 lines above. Drop
that code.
2014-12-31 15:52:23 +01:00
David Herrmann
a38f05b7f7 Revert commit f131770b "tree-wide: spelling fixes"
This partially reverts:

    commit f131770b14
    Author: Veres Lajos <vlajos@gmail.com>
    Date:   Mon Dec 29 09:45:58 2014 +0000

        tree-wide: spelling fixes

The commit in question changed a binary file. I didn't look at the diff in
particular, so I have no idea what exactly was changed. However, the file
is generated and it looked highly suspiciuous. Therefore, I reverted that
part.

Note that this is generated by "make update-unifont" so really no reason
to touch at all.
2014-12-31 13:34:21 +01:00
Veres Lajos
f131770b14 tree-wide: spelling fixes
https://github.com/vlajos/misspell_fixer

b6fdeb618c
Thanks to Torstein Husebo <torstein@huseboe.net>.
2014-12-30 20:07:04 -05:00
Robert Milasan
fd51179d5c accelerometer: display short options too 2014-12-30 19:12:50 -05:00
Zbigniew Jędrzejewski-Szmek
a39b4bdd10 systemctl: do not repeat hibernate/sleep attempts
If some sleep operation was not possible (e.g. because swap is missing),
we would try twice: once through logind, which would result in a clean error:
  Failed to execute operation: Sleep verb not supported
and then second time by starting the appropriate unit directly, which is
more messy. If logind tells us that something is not possible (or already
in progress), report that to the user and quit. If logind is present and working
we should not try to work around it.

Loosely based on https://bugs.freedesktop.org/show_bug.cgi?id=87832.
2014-12-30 18:39:52 -05:00
Zbigniew Jędrzejewski-Szmek
caffa4ef70 bus: replace ENOSYS return codes with EBADR/ENOTSUP
ENOSYS is used to signify compiled-out functionality. Using it for
different kinds of error is misleading.

For BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, logind-action.c uses ENOTSUP
already, so changing it to ENOTSUP makes the dbus and action paths
behave the same.
2014-12-30 18:39:52 -05:00
Robert Milasan
7fcf5779b4 accelerometer: drop unused -x option 2014-12-30 22:05:39 +01:00
David Herrmann
d95eb43e90 bus: add sd_bus_emit_object_{added/removed}()
This implements two new helpers, discussed on systemd-devel about 1 year
ago:
    sd_bus_emit_object_added()
    sd_bus_emit_object_removed()

Both calls are equivalent to their respective counterpart
sd_bus_emit_interfaces_{added/removed}(), but can figure out the list of
interfaces themselves, instead of requiring the caller to provide them.
Furthermore, both calls properly deal with builtin interfaces provided via
org.freedesktop.DBus.* and alike.

Both calls simply traverse a node and all its parent nodes to figure out a
list of all interfaces registered as vtable or fallback. It then appends
each of them, similar to the interfaces_{added/removed}() helpers.

Note that interfaces_{added/removed}() runs a parent traversal for *each*
passed interface. Therefore, it can simply bail out, once it found a
parent node that implements a given interface.
With object_{added/removed}() we cannot know the registered interfaces in
advance, thus, we cannot run one traversal per node. Instead, we run a
single traversal and remember all interfaces that we added. Therefore, a
child-interface overrides all conflicting parent-interfaces. We keep a
"Set *s" context to track those while climbing up the tree.
2014-12-30 11:37:35 +01:00
David Herrmann
7d9fcc2bf6 bus: fix capabilities on big-endian
The kernel provides capabilities as a u32 array, sd-bus uses an u8 array.
This works fine on little-endian as both are encoded the same way.
However, this fails on big-endian if we do not perform sufficient
byte-swapping on each u32 entry.

This patch makes sd-bus use u32, too. We avoid changing any kernel
provided data so we can keep pointing into kdbus pool buffers which
contain u32 arrays.
2014-12-30 09:09:41 +01:00
David Herrmann
34a5d5e526 bus: drop creds->capability_size
The number of available caps can be read from
/proc/sys/kernel/cap_last_cap during runtime. Our helper cap_last_cap()
does that, so there's no reason to remember the size of any capability
cache. We can just pre-allocate arrays with a suitable size for all
available caps and reject any higher caps.

The kernel capability API uses u32 as base so make sure we do the same.
Note that this is specified by POSIX, so it's unlikely to change.
2014-12-30 08:42:53 +01:00
David Herrmann
180a60bc87 macro: add DIV_ROUND_UP()
This macro calculates A / B but rounds up instead of down. We explicitly
do *NOT* use:
        (A + B - 1) / A
as it suffers from an integer overflow, even though the passed values are
properly tested against overflow. Our test-cases show this behavior.

Instead, we use:
        A / B + !!(A % B)

Note that on "Real CPUs" this does *NOT* result in two divisions. Instead,
instructions like idivl@x86 provide both, the quotient and the remainder.
Therefore, both algorithms should perform equally well (I didn't verify
this, though).
2014-12-30 01:39:01 +01:00
Lennart Poettering
c00a4c8f55 Revert "machined: don't force terminate registered machines"
This reverts commit 206e7a5f7b.

We actually want to allow shutting down containers that use
RegisterMachine() rather than CreateMachine() to register their own
unit. It should be safe to do so, since the primary usecase for
RegisterMachine() are container managers that run only a single
container within their own unit, such as systemd-nspawn.
2014-12-29 20:13:58 +01:00
Lennart Poettering
e5f5b5b9c9 machined: ignore spurious error 2014-12-29 19:08:50 +01:00
Lennart Poettering
814a3fdfdc nspawn: report back to systemd only very late whether we are OK
That way, systemd can actually figure out if everything is OK with
nspawn.
2014-12-29 17:54:33 +01:00
Lennart Poettering
d8f52ed25a machinectl: add "enable" and "disable" verbs for enabling/disabling systemd-nspawn for containers
This is basically just a shortcut for "systemctl enable
systemd-nspawn@<foobar>.service", but does escaping.
2014-12-29 17:00:05 +01:00
Lennart Poettering
ebd011d95b machinectl: add new "start" verb to start a container as a service in nspawn 2014-12-29 17:00:05 +01:00
David Herrmann
679bda6a73 bus-proxy: fix sd_bus_reply_*() usage
We *must* not use sd_bus_reply_*() as it does not set the sender field
correctly. Use the synthetic_reply_*() helpers instead!
2014-12-29 15:43:57 +01:00
David Herrmann
80b4378314 capability: use /proc/sys/kernel/cap_last_cap
This file was introduced with linux-3.2, use it instead of probing for it
via prctl(PR_CAPBSET_READ).

For now, keep the old code for backwards compat. We can drop it once 3.2
is our lowest requirement.

The test-cap-list code is extended to verify cap_last_cap() is the same as
we'd get via prctl probing and /proc.
2014-12-29 14:05:38 +01:00
Tom Gundersen
2f0af4e120 core: loopback - correctly fail the loopback_check if somehow the rtnl calls fail 2014-12-29 13:07:03 +01:00
David Herrmann
315a73d97f bus: fix typo
Drop spurious 'we'.
2014-12-29 12:55:28 +01:00
Tom Gundersen
09773ef446 rtnl: recv_message - don't enforce sender uid
All we care about is that the kernel (pid==0) sent the message. Verifying the sender uid
seems to break when using userns.

Reported by Stéphane Graber.
2014-12-29 02:20:04 +01:00
Tom Gundersen
2da780b976 test: loopback - parse logging env var 2014-12-29 01:59:49 +01:00
Tom Gundersen
b551ddd380 sd-rtnl: rtnl_call - don't dispatch wqueue after timeout has passed
Only a minor change as the timeout would be hit soon thereafetr at the next loop.
2014-12-29 01:59:49 +01:00
Tom Gundersen
f55dc7c96e sd-rtnl: rtnl_poll - fix typo
This caused rtnl_poll to always return true immediately in sd_rtnl_call().
2014-12-29 01:59:49 +01:00
Tom Gundersen
c7460cce79 sd-rtnl: recv_message - drop message when peeking fails
Read the message form the socket or we will loop trying to read the
same message repeatedly.
2014-12-29 01:59:49 +01:00
Tom Gundersen
0b2bbbdf2f sd-rtnl: recv_message - don't fail on interrupt
We should just try again instead.
2014-12-29 01:59:49 +01:00
Tom Gundersen
2263bb9a92 sd-rtnl: recv_message - log when dropping message
We drop messages received from the wrong uid/pid, log this at debug level.
2014-12-29 00:19:36 +01:00
Tom Gundersen
e95e909d82 core: loopback - simplify check_loopback()
We no longer configure the addresses on the loopback interface, but simply bring it up
and let the kernel do the rest. Also change the check to only check if the interface
is up, rather than checking for the IPv4 loopback address.
2014-12-28 15:58:27 +01:00
Sylvain Plantefève
94b5088c8d machined: Fix MarkReadOnly method's name on bus 2014-12-28 13:05:08 +01:00
Sylvain Plantefève
1517ab5d18 libsystemd: Fix minor typo in comment 2014-12-28 13:04:46 +01:00
Lennart Poettering
1ddb263d21 machined: don't look for images on each property get, but cache the image object inbetween 2014-12-28 02:44:37 +01:00
Lennart Poettering
f02ca52281 util: treat -1 as special size in format_bytes() 2014-12-28 02:08:40 +01:00
Lennart Poettering
b6b1849830 machined: add support for reporting image size via btrfs quota 2014-12-28 02:08:40 +01:00
Lennart Poettering
d7b8eec7dc tmpfiles: add new line type 'v' for creating btrfs subvolumes 2014-12-28 02:08:40 +01:00
Lennart Poettering
ebd93cb684 machinectl/machined: implement "rename", "clone", "read-only" verbs for machine images 2014-12-28 02:08:40 +01:00
Lennart Poettering
086821244b machined: add "machinectl remove" for removing images 2014-12-28 02:08:40 +01:00
Lennart Poettering
1b9cebf638 nspawn: use the same image discovery logic in nspawn as in machined 2014-12-28 02:08:40 +01:00