chiark / gitweb /
elogind.git
9 years agoterminal: grdev: refresh device state on hotplug events
David Herrmann [Sat, 20 Sep 2014 07:50:10 +0000 (09:50 +0200)]
terminal: grdev: refresh device state on hotplug events

Whenever we get udev hotplug events, re-read the device state so we
properly detect any changed in the display setups.

9 years agoterminal: grdev: treat udev-devices without devnum as hotplug
David Herrmann [Sat, 20 Sep 2014 07:48:22 +0000 (09:48 +0200)]
terminal: grdev: treat udev-devices without devnum as hotplug

If we get udev-device events via sysview, but they lack devnum
annotations, we know it cannot be a DRM card. Look through it's parents
and treat it as hotplug event in case we find such a card.

This will treat any new/removed connectors as sub-devices of the real
card, instead of as devices on its own.

9 years agoterminal: modeset: forward DEVICE_CHANGE events into grdev
David Herrmann [Sat, 20 Sep 2014 07:46:13 +0000 (09:46 +0200)]
terminal: modeset: forward DEVICE_CHANGE events into grdev

Properly forward DEVICE_CHANGE events into grdev so we can react to
changing display setups.

9 years agoterminal: reduce speed of morphing colors in modeset test
David Herrmann [Sat, 20 Sep 2014 07:45:26 +0000 (09:45 +0200)]
terminal: reduce speed of morphing colors in modeset test

The high frequency of the color-morphing is kinda irritating. Reduce it
to a much lower frequency so you can actually look at it longer than few
seconds.

9 years agoterminal: make drm-connectors first-level devices
David Herrmann [Sat, 20 Sep 2014 07:44:14 +0000 (09:44 +0200)]
terminal: make drm-connectors first-level devices

So far, we only forward DRM cards via sysview APIs. However, with MST,
connectors can be hotplugged, too. Forward the connectors as first-level
devices via sysview so API users can react to changing DRM connectors.

9 years agoterminal: forward DEVICE_CHANGE events via sysview
David Herrmann [Sat, 20 Sep 2014 07:43:16 +0000 (09:43 +0200)]
terminal: forward DEVICE_CHANGE events via sysview

Whe need to react to "change" events on devices, but we want to avoid
duplicating udev-monitors everywhere. Therefore, make sysview forward
change events to the sysview controllers, which can then properly react
to it.

9 years agoterminal: parse ID_SEAT not only for parents but the device itself
David Herrmann [Sat, 20 Sep 2014 07:29:11 +0000 (09:29 +0200)]
terminal: parse ID_SEAT not only for parents but the device itself

When deciding what seat a device is on, we have to traverse all parents
to find one with an ID_SEAT tag, otherwise, input devices plugged on a
seated USB-hub are not automatically attached to the right seat. But any
tags on the main device still overwrite the tags of the childs, so fix our
logic to check the device itself first, before traversing the parents.

9 years agonspawn: don't try to create veth link with too long ifname
Tom Gundersen [Fri, 19 Sep 2014 21:02:00 +0000 (23:02 +0200)]
nspawn: don't try to create veth link with too long ifname

Reported by: James Lott <james@lottspot.com>

9 years agoterminal: add systemd-modeset debugging tool
David Herrmann [Fri, 19 Sep 2014 12:48:54 +0000 (14:48 +0200)]
terminal: add systemd-modeset debugging tool

The systemd-modeset tool is meant to debug grdev issues. It simply
displays morphing colors on any found display. This is pretty handy to
look for tearing in the backends and debug hotplug issues.

Note that this tool requires systemd-logind to be compiled from git
(there're important fixes that haven't been released, yet).

9 years agoterminal: add grdev DRM backend
David Herrmann [Fri, 19 Sep 2014 12:13:06 +0000 (14:13 +0200)]
terminal: add grdev DRM backend

The grdev-drm backend manages DRM cards for grdev. Any DRM card with
DUMB_BUFFER support can be used. So far, our policy is to configure all
available connectors, but keep pipes inactive as long as users don't
enable the displays on top.

We hard-code double-buffering so far, but can easily support
single-buffering or n-buffering. We also require XRGB8888 as format as
this is required to be supported by all DRM drivers and it is what VTs
use. This allows us to switch from VTs to grdev via page-flips instead of
deep modesets.

There is still a lot room for improvements in this backend, but it works
smoothly so far so more enhanced features can be added later.

9 years agoterminal: add graphics interface
David Herrmann [Fri, 19 Sep 2014 12:05:52 +0000 (14:05 +0200)]
terminal: add graphics interface

The grdev layer provides graphics-device access via the
libsystemd-terminal library. It will be used by all terminal helpers to
actually access display hardware.

Like idev, the grdev layer is built around session objects. On each
session object you add/remove graphics devices as they appear and vanish.
Any device type can be supported via specific card-backends. The exported
grdev API hides any device details.

Graphics devices are represented by "cards". Those are hidden in the
session and any pipe-configuration is automatically applied. Out of those,
we configure displays which are then exported to the API user. Displays
are meant as lowest hardware entity available outside of grdev. The
underlying pipe configuration is fully hidden and not accessible from the
outside. The grdev tiling layer allows almost arbitrary setups out of
multiple pipes, but so far we only use a small subset of this. More will
follow.

A grdev-display is meant to represent real connected displays/monitors.
The upper level screen arrangements are user policy and not controlled by
grdev. Applications are free to apply any policy they want.

Real card-backends will follow in later patches.

9 years agologin: pause devices before acknowledging VT switches
David Herrmann [Fri, 19 Sep 2014 11:26:39 +0000 (13:26 +0200)]
login: pause devices before acknowledging VT switches

If a session controller does not need synchronous VT switches, we allow
them to pass VT control to logind, which acknowledges all VT switches
unconditionally. This works fine with all sessions using the dbus API,
but causes out-of-sync device use if we switch to legacy sessions that
are notified via VT signals. Those are processed before logind notices
the session-switch via sysfs. Therefore, leaving the old session still
active for a short amount of time.

This, in fact, may cause the legacy session to prepare graphics devices
before the old session was deactivated, and thus, maybe causing the old
session to interfer with graphics device usage.

Fix this by releasing devices immediately before acknowledging VT
switches. This way, sessions without VT handlers are required to support
async session switching (which they do in that case, anyway).

9 years agosocket: introduce SELinuxContextFromNet option
Michal Sekletar [Thu, 24 Jul 2014 08:40:28 +0000 (10:40 +0200)]
socket: introduce SELinuxContextFromNet option

This makes possible to spawn service instances triggered by socket with
MLS/MCS SELinux labels which are created based on information provided by
connected peer.

Implementation of label_get_child_mls_label derived from xinetd.

Reviewed-by: Paul Moore <pmoore@redhat.com>
9 years agoshared: wtmp-utmp - don't clear store_wtmp in utmp_put_dead_process()
Tom Gundersen [Fri, 19 Sep 2014 06:03:31 +0000 (08:03 +0200)]
shared: wtmp-utmp - don't clear store_wtmp in utmp_put_dead_process()

Also modernize a few other things and add comments to explain CID #1237503
and CID #1237504.

9 years agotest: warn if we could not parse the loop count argument
Thomas Hindoe Paaboel Andersen [Thu, 18 Sep 2014 23:43:04 +0000 (01:43 +0200)]
test: warn if we could not parse the loop count argument

Found by coverity. Fixes: CID#1237512

9 years agoshared/sparse-endian.h: add missing byteswap.h include
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:43 +0000 (15:24 +0200)]
shared/sparse-endian.h: add missing byteswap.h include

9 years agoshared/label.h: add missing stdio.h include
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:42 +0000 (15:24 +0200)]
shared/label.h: add missing stdio.h include

9 years agopty: include linux/ioctl.h for TIOCSIG
David Herrmann [Thu, 18 Sep 2014 22:23:42 +0000 (00:23 +0200)]
pty: include linux/ioctl.h for TIOCSIG

TIOCSIG is linux specific, so include the linux ioctl header to make sure
it's defined. We currently rely on some rather non-obvious recursive
includes. Make sure its always defined regardless of the system headers.

9 years agonss: remove dead code
Thomas Hindoe Paaboel Andersen [Thu, 18 Sep 2014 21:55:46 +0000 (23:55 +0200)]
nss: remove dead code

c > 0 is already guaranteed from earlier checks.

We go from

ms = ALIGN(l+1) +
        sizeof(char*) +
        (c > 0 ? c : 1) * ALIGN(alen) +
        (c > 0 ? c+1 : 2) * sizeof(char*);

to

ms = ALIGN(l+1) +
        sizeof(char*) +
        c * ALIGN(alen) +
        (c+1) * sizeof(char*);

to

ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);

Found by coverity. Fixes: CID#1237570 and CID#1237610

9 years agotimesyncd: check return of setting IP_TOS
Tom Gundersen [Thu, 18 Sep 2014 21:37:07 +0000 (23:37 +0200)]
timesyncd: check return of setting IP_TOS

Fonud by Coverity. Fixes CID #1237534.

9 years agoudevd: don't fail if /run/udev exists
Tom Gundersen [Thu, 18 Sep 2014 19:57:49 +0000 (21:57 +0200)]
udevd: don't fail if /run/udev exists

9 years agoudev: fix typos
Tom Gundersen [Thu, 18 Sep 2014 18:25:33 +0000 (20:25 +0200)]
udev: fix typos

Spotted by Andreas Henriksson.

9 years agoudev: ctrl - log if setting SO_PASSCRED fails
Tom Gundersen [Thu, 18 Sep 2014 17:26:11 +0000 (19:26 +0200)]
udev: ctrl - log if setting SO_PASSCRED fails

No functional change.

Found by Coverity. Fixes CID #1237533.

9 years agoudev: node - warn if chmod/chown fails
Tom Gundersen [Thu, 18 Sep 2014 17:22:09 +0000 (19:22 +0200)]
udev: node - warn if chmod/chown fails

No functional change, just log the warning.

Fonud by Coverity. Fixes CID #1237544.

9 years agoudevadm: hwdb - check return value of fseeko()
Tom Gundersen [Thu, 18 Sep 2014 17:16:54 +0000 (19:16 +0200)]
udevadm: hwdb - check return value of fseeko()

Fonud by Coverity. Fixes CID #996255.

9 years agoudevd: check return of various functions
Tom Gundersen [Thu, 18 Sep 2014 17:07:02 +0000 (19:07 +0200)]
udevd: check return of various functions

One reported by Coverity. Fixes CID #996252.

9 years agoudevd: parse_argv - warn if argumens are invalid
Tom Gundersen [Thu, 18 Sep 2014 17:02:03 +0000 (19:02 +0200)]
udevd: parse_argv - warn if argumens are invalid

Found by Coverity. Fixes CID #1238780.

9 years agojournal-remote: check return code of sd_event_default
Andreas Henriksson [Thu, 18 Sep 2014 15:52:54 +0000 (17:52 +0200)]
journal-remote: check return code of sd_event_default

Handle sd_event_default returning error and bail out properly
as done in every other caller of this function.

Found by coverity. Fixes: CID#1238957

9 years agosysusers: Remove some gcc warnings about uninitialized variables
Philippe De Swert [Thu, 18 Sep 2014 15:56:57 +0000 (18:56 +0300)]
sysusers: Remove some gcc warnings about uninitialized variables

Gcc is spewing some warnings about uninitialized variables.
Let's get rid of the noise.

9 years agocore: Remove uninitialized warnings from bus-endpoint.c
Philippe De Swert [Thu, 18 Sep 2014 15:56:56 +0000 (18:56 +0300)]
core: Remove uninitialized warnings from bus-endpoint.c

Gcc is spewing some warnings about uninitialized variables.
Let's get rid of the noise.

9 years agojournal-upload: Remove compilation warning
Philippe De Swert [Thu, 18 Sep 2014 15:56:55 +0000 (18:56 +0300)]
journal-upload: Remove compilation warning

When compiling we see this curl warning popping up:
src/journal-remote/journal-upload.c:194:17: warning: call to
‘_curl_easy_setopt_err_error_buffer’ declared with attribute
warning: curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE
as argument for this option [enabled by default]
This patch removes the warning (which occurs twice).

9 years agomount: order options before other arguments to mount
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:59 +0000 (15:24 +0200)]
mount: order options before other arguments to mount

9 years agoinclude fcntl.h rather than sys/fcntl.h
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:38 +0000 (15:24 +0200)]
include fcntl.h rather than sys/fcntl.h

9 years agosd-rtnl: rtnl-message: remove unneeded linux includes
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:40 +0000 (15:24 +0200)]
sd-rtnl: rtnl-message: remove unneeded linux includes

9 years agoudev: link-config: remove unneded linux/netdevice.h include
Emil Renner Berthing [Thu, 18 Sep 2014 13:24:39 +0000 (15:24 +0200)]
udev: link-config: remove unneded linux/netdevice.h include

9 years agojournal: Do not count on the compiler initializing found_last to false
Philippe De Swert [Tue, 16 Sep 2014 21:27:16 +0000 (00:27 +0300)]
journal: Do not count on the compiler initializing found_last to false

There is a very unlikely case where this can happen since gcc usually
does the sane thing. But let's make sure found_last is initialized anyway.

Fixes: CID#996386
9 years agoman: use the escape for "-" in example instead of space.
Michael Marineau [Mon, 15 Sep 2014 21:07:39 +0000 (14:07 -0700)]
man: use the escape for "-" in example instead of space.

This sentence can be misread to mean that "\x20" is the escape code for
"-" which is the only character explicitly mentioned. This lead to at
least one user loosing hair over why a mount unit for "/foo/bar-baz"
didn't work. The example escape is arbitrary so lets prevent hair loss.

9 years agoudev: fix path for database names on 'change' event
Robert Milasan [Sat, 13 Sep 2014 13:18:37 +0000 (15:18 +0200)]
udev: fix path for database names on 'change' event

If a device does not have a major/minor number attached, we use different
database names than if it does. On "change" events, we didn't copy the
devnum over, therefore, we used different paths than on 'add' or 'remove'
events (where devnum was properly copied).

Fix this by always copying the devnum into the udev-device.

(David: added commit-log from email)

9 years agobus: fix bus_print_property() to use "int" for booleans
David Herrmann [Thu, 18 Sep 2014 11:28:28 +0000 (13:28 +0200)]
bus: fix bus_print_property() to use "int" for booleans

We always use "int" if we retrieve boolean values from sd-bus, as "bool"
is only a single byte, but full int on va-args.

Thanks to Werner Fink for the report!

9 years agoshared: conf-parser - don't leak memory on error in DEFINE_CONFIG_PARSE_ENUMV
Tom Gundersen [Thu, 18 Sep 2014 11:47:00 +0000 (13:47 +0200)]
shared: conf-parser - don't leak memory on error in DEFINE_CONFIG_PARSE_ENUMV

Found by Coverity. Fixes CID #1237746.

9 years agolibudev: monitor - warn if we fail to request SO_PASSCRED
Tom Gundersen [Thu, 18 Sep 2014 07:20:46 +0000 (09:20 +0200)]
libudev: monitor - warn if we fail to request SO_PASSCRED

The function still succeeds, so there is no functional change. This fixes CID #996288.

9 years agotests: fix resource & mem leaks
Ronny Chevalier [Thu, 18 Sep 2014 10:09:10 +0000 (12:09 +0200)]
tests: fix resource & mem leaks

9 years agosd-bus: sync kdbus.h
Daniel Mack [Thu, 18 Sep 2014 08:25:35 +0000 (10:25 +0200)]
sd-bus: sync kdbus.h

(no API/ABI break this time)

9 years agosystemctl: fix resource leak CID #1237747
Cristian Rodríguez [Thu, 18 Sep 2014 00:56:25 +0000 (21:56 -0300)]
systemctl: fix resource leak CID #1237747

..by simply moving the declaration of "unit" into the STRV_FOREACH
loop as suggested by Andreas.

9 years agoFix resource leak (coverity CID 1237760)
Cristian Rodríguez [Wed, 17 Sep 2014 21:10:21 +0000 (18:10 -0300)]
Fix resource leak (coverity CID 1237760)

9 years agosysv-generator: don't check first if hashmap contains the service name
Thomas Hindoe Paaboel Andersen [Wed, 17 Sep 2014 21:03:27 +0000 (23:03 +0200)]
sysv-generator: don't check first if hashmap contains the service name

Just test if hashmap_get returns null. hashmap_contains does exactly
same thing internally so this is slightly more efficient for the true
case.

Silences a coverity warning too. CID#1237648

9 years agologind: fix typo
Ronny Chevalier [Wed, 17 Sep 2014 18:10:44 +0000 (20:10 +0200)]
logind: fix typo

9 years agoshared: conf-parser
Tom Gundersen [Wed, 17 Sep 2014 20:17:53 +0000 (22:17 +0200)]
shared: conf-parser

Check memory allocation. Found by Coverity.

Fixes CID #1237644.

9 years agoudev: event - modernize spawn_exec()
Tom Gundersen [Wed, 17 Sep 2014 19:53:20 +0000 (21:53 +0200)]
udev: event - modernize spawn_exec()

9 years agoudev: event - explicitly don't read() from invalid fd
Tom Gundersen [Wed, 17 Sep 2014 19:44:56 +0000 (21:44 +0200)]
udev: event - explicitly don't read() from invalid fd

This fixes CID #1237641.

9 years agoudev: event - modernize spawn_read()
Tom Gundersen [Wed, 17 Sep 2014 19:43:57 +0000 (21:43 +0200)]
udev: event - modernize spawn_read()

9 years agonss-resolve: remove dead code
Thomas Hindoe Paaboel Andersen [Wed, 17 Sep 2014 18:48:39 +0000 (20:48 +0200)]
nss-resolve: remove dead code

ifindex < 0 was already checked before entering the loop

Found by coverity. Fixes: CID#1237609

9 years agoudev: rules - close empty file
Tom Gundersen [Wed, 17 Sep 2014 17:53:01 +0000 (19:53 +0200)]
udev: rules - close empty file

If the file is found to be empty, we exit early without closing the file first.

Found by coverity. Fixes CID #1237759.

9 years agolibsystemd-network: dhcp-test - assert that malloc0 succeeds
Tom Gundersen [Wed, 17 Sep 2014 17:07:56 +0000 (19:07 +0200)]
libsystemd-network: dhcp-test - assert that malloc0 succeeds

Otherwise we would get a nullptr dereference later on.

Found by coverity. Fixes CID #1237655.

9 years agonetworkd: dhcp4 - fix unchecked return value
Tom Gundersen [Wed, 17 Sep 2014 17:00:55 +0000 (19:00 +0200)]
networkd: dhcp4 - fix unchecked return value

Found by coverity. CID #1237529 and #1237528.

9 years agobus: fix error leak in bus_node_exists()
David Herrmann [Wed, 17 Sep 2014 08:32:49 +0000 (10:32 +0200)]
bus: fix error leak in bus_node_exists()

If we call into user callbacks, we must always propagate possible errors.
Fix bus_node_exists() to do that and adjust the callers (which already
partially propagated the error).

Also speed up that function by first checking for registered enumerators
and/or object-managers.

9 years agobus: never respond to GetManagedObjects() on sub-paths
David Herrmann [Wed, 17 Sep 2014 07:28:09 +0000 (09:28 +0200)]
bus: never respond to GetManagedObjects() on sub-paths

The dbus-spec clearly specifies that GetManagedObjects() should only work
on the root-path of an object-tree. But on that path, it works regardless
whether there are any objects available or not.

We could, technically, define all sub-paths as a root-path of its own
sub-tree. However, if we do that, we enter undefined territory:

    Imagine only a fallback vtable is registered. We want
    GetManagedObjects() to *NOT* fail with UNKNOWN_METHOD if it is called
    on a valid sub-tree of the fallback. On the other hand, we don't want
    it to work on arbitrary sub-tree. Something like:
        /path/to/fallback/foobar/foobar/foobar/invalid/foobar
    should not work.
    However, there is no way to know which paths on a fallback are valid
    without looking at there registered objects. If no objects are
    registered, we have no way to figure it out.

Therefore, we now try to follow the dbus spec by only returning valid data
on registered root-paths. We treat each path as root which was registered
an object-manager on via add_object_manager(). So applications can now
directly control which paths to place an object-manager on.

We also fix the introspection to not return object-manager interfaces on
non-root paths.

Also fixes some dead-code paths initially reported by Philippe De Swert.

9 years agosysctl: make --prefix allow all kinds of sysctl paths
David Herrmann [Wed, 17 Sep 2014 07:06:49 +0000 (09:06 +0200)]
sysctl: make --prefix allow all kinds of sysctl paths

Currently, we save arguments passed as --prefix directly and compare them
later to absolute sysctl file-system paths. That is, you are required to
specify arguments to --prefix with leading /proc/sys/. This is kinda
uselesss. Furthermore, we replace dots by slashes in the name, which makes
it impossible to match on specific sysfs paths that have dots in their
name (like netdev names). The intention of this argument is clear, but it
never worked as expected.

This patch modifies --prefix to accept any kind of sysctl paths. It
supports paths prefixed with /proc/sys for compatibility (but drops the
erroneous dot->slash conversion), but instead applies normalize_sysctl()
which turns any name or path into a proper path. It then appends
/proc/sys/ so we can properly use it in matches.

Thanks to Jan Synacek <jsynacek@redhat.com> for catching this!

9 years agoutil: remove a unnecessary check
Thomas Hindoe Paaboel Andersen [Tue, 16 Sep 2014 20:58:35 +0000 (22:58 +0200)]
util: remove a unnecessary check

We only break out of the previous loop if fd >= 0 so there is no
use in checking it again.

Found by coverity. Fixes: CID#1237577

9 years agoterminal: remove dead code checking O_WRONLY
David Herrmann [Tue, 16 Sep 2014 21:00:26 +0000 (23:00 +0200)]
terminal: remove dead code checking O_WRONLY

We only reject evdev FDs that are O_WRONLY as they're currently pretty
useless. The following check for O_WRONLY is thus never excercised so drop
it.
Thanks to Thomas Andersen (via coverity)!

9 years agotest: silence a coverity report
Thomas Hindoe Paaboel Andersen [Tue, 16 Sep 2014 19:59:50 +0000 (21:59 +0200)]
test: silence a coverity report

We check the actual contents of the file on the line after but we
might as well also check the number of bytes read here.

Found by coverity. Fixes: CID#1237521

9 years agoshared: fix resource leak in config_parse_default_instance
Andreas Henriksson [Tue, 16 Sep 2014 19:36:26 +0000 (21:36 +0200)]
shared: fix resource leak in config_parse_default_instance

The recently allocated "printed" is not freed on error path.

Found by coverity. Fixes: CID#1237745

9 years agosysv-generator: fix resource leak
Andreas Henriksson [Tue, 16 Sep 2014 19:22:59 +0000 (21:22 +0200)]
sysv-generator: fix resource leak

The "unit" string allocation is not freed on either error or success path.

Found by coverity. Fixes: CID#1237755

9 years agocore: fix resource leak in manager_environment_add
Andreas Henriksson [Tue, 16 Sep 2014 19:11:02 +0000 (21:11 +0200)]
core: fix resource leak in manager_environment_add

Second error path must free the (potentially) allocated memory in the
first code chunk before returning.

Found by coverity. Fixes: CID#1237750

9 years agomissing: memfd_create takes unsigned int flags in final version
Cristian Rodríguez [Tue, 16 Sep 2014 17:17:01 +0000 (14:17 -0300)]
missing: memfd_create takes unsigned int flags in final version

9 years agoterminal: sd_bus_error_get_errno returns positive errno
Thomas Hindoe Paaboel Andersen [Mon, 15 Sep 2014 20:55:36 +0000 (22:55 +0200)]
terminal: sd_bus_error_get_errno returns positive errno

The 3 calls to sd_bus_error_get_errno appear to expect a negative
return value.

This patch negates the returned value so it matches the other error
cases in the 3 functions where sd_bus_error_get_errno is used.

9 years agosd-bus: sd_bus_message_get_errno should only return positive errno
Thomas Hindoe Paaboel Andersen [Mon, 15 Sep 2014 20:36:43 +0000 (22:36 +0200)]
sd-bus: sd_bus_message_get_errno should only return positive errno

sd_bus_message_get_errno can currently return either a number of
different poitive errno values (from bus-error-mapping), or a negative
EINVAL if passed null as parameter.

The check for null parameter was introduced in 40ca29a1370379d43e44c0ed425eecc7218dcbca
at the same as the function was renamed from bus_message_to_errno and
made public API. Before becoming public the function used to return
only negative values.

It is weird to have a function return both positive and negative errno
and it generally looks like a mistake. The function is guarded by the
--enable-kdbus flags so I wonder if we still have time to fix it up?
It does not have any documentation yet. However, except for a few details
it is just a convenient way to call sd_bus_error_get_errno which is documented
to return only positive errno.

This patch makes it return only positive errno and fixes up the two
calls to the function that tried to cope with both positive and negative
values.

9 years agobootchart: oom-check correct variable
Andreas Henriksson [Tue, 16 Sep 2014 17:40:25 +0000 (19:40 +0200)]
bootchart: oom-check correct variable

Coverity warned that we have already dereferenced ps->sample before
null-checking it. I suspect that's not really the issue and that
the check is checking the wrong variable.
Likely the oom-check should be on the just allocated ps->sample->next.

Found by coverity. Fixes: CID#1237765

9 years agobootchart: use safe_atod() rather than strtod()
Tom Gundersen [Tue, 16 Sep 2014 16:42:22 +0000 (18:42 +0200)]
bootchart: use safe_atod() rather than strtod()

9 years agohostname: add missing EMITS_CHANGE annotation
David Herrmann [Tue, 16 Sep 2014 15:33:20 +0000 (17:33 +0200)]
hostname: add missing EMITS_CHANGE annotation

We call into sd-bus to send PropertiesChanged notifications for
"Hostname", but forgot to add the annotation to the bus-vtable. Fix that!

9 years agolibsystemd-network: avoid double-free in error case
Andreas Henriksson [Tue, 16 Sep 2014 13:50:58 +0000 (15:50 +0200)]
libsystemd-network: avoid double-free in error case

Don't manually free 'n' in error path as it's already tagged
_cleanup_free_ and will be freed once it goes out of scope,
leading to double-free in this case.

Found with coverity. Fixes: CID#1237786

9 years agogpt-auto-generator: fix typo
Lukas Nykryn [Tue, 16 Sep 2014 11:50:11 +0000 (13:50 +0200)]
gpt-auto-generator: fix typo

9 years agoudev: rules - add missing whitespace to log message
Tom Gundersen [Mon, 15 Sep 2014 14:36:07 +0000 (16:36 +0200)]
udev: rules - add missing whitespace to log message

9 years agoudevd: use safe_ato*() in place of strto*()
Tom Gundersen [Mon, 15 Sep 2014 12:41:30 +0000 (14:41 +0200)]
udevd: use safe_ato*() in place of strto*()

9 years agoudev: util - use log_level_from_string()
Tom Gundersen [Mon, 15 Sep 2014 12:21:00 +0000 (14:21 +0200)]
udev: util - use log_level_from_string()

9 years agolibudev: util - drop util_delete_path()
Tom Gundersen [Mon, 15 Sep 2014 12:20:32 +0000 (14:20 +0200)]
libudev: util - drop util_delete_path()

Use rmdir_parents() from src/shared instead.

9 years agolibudev: drop util_lookup_{user,group}
Tom Gundersen [Tue, 9 Sep 2014 21:12:14 +0000 (23:12 +0200)]
libudev: drop util_lookup_{user,group}

Use shared versions instead. Difference is with overwriting of repeated user/group
name, and lack of logging.

9 years agoudev: apply permissions to static nodes before signallying READY
Tom Gundersen [Mon, 15 Sep 2014 10:04:29 +0000 (12:04 +0200)]
udev: apply permissions to static nodes before signallying READY

Processes expecting static nodes to have the right permissions may order themselves after systemd-udevd.service,
make sure that actually guarantees what is expected.

9 years agoudev: only print after final log level has been determined
Tom Gundersen [Mon, 15 Sep 2014 09:53:03 +0000 (11:53 +0200)]
udev: only print after final log level has been determined

This delays label_init(), and drops the (duplicate) printing of version
information.

9 years agoudevd: initialize epoll_event structs on allocation
Tom Gundersen [Fri, 12 Sep 2014 14:45:19 +0000 (16:45 +0200)]
udevd: initialize epoll_event structs on allocation

Also move the rest of event initialization next to the event loop (no functional change).

9 years agoudev: don't close std{in,out,err}
Tom Gundersen [Fri, 12 Sep 2014 14:22:44 +0000 (16:22 +0200)]
udev: don't close std{in,out,err}

Rather than printing debug output to stderr and redirecting this to /dev/null when not wanted,
use the correct log_*() function in the first place.

9 years agoudev: drop duplicate logging
Tom Gundersen [Fri, 12 Sep 2014 14:17:00 +0000 (16:17 +0200)]
udev: drop duplicate logging

Once upon a time logging during early boot was unreliable, so extra logging messages were
sent by udev to stderr. That is no longer a concern, so drop all fprintf() calls from udved.

9 years agoudev: split out parse_argv()
Tom Gundersen [Fri, 12 Sep 2014 12:42:59 +0000 (14:42 +0200)]
udev: split out parse_argv()

Also rename some global variables to arg_* to make it clearer where they come from.

9 years agoudev: split out help and modernise a bit
Tom Gundersen [Fri, 12 Sep 2014 12:18:06 +0000 (14:18 +0200)]
udev: split out help and modernise a bit

9 years agoman: sd_bus_error typo fix
Thomas Hindoe Paaboel Andersen [Mon, 15 Sep 2014 21:17:57 +0000 (23:17 +0200)]
man: sd_bus_error typo fix

9 years agoterminal: fix missing hashmap_new() conversions
David Herrmann [Mon, 15 Sep 2014 15:12:41 +0000 (17:12 +0200)]
terminal: fix missing hashmap_new() conversions

hashmap_new() now takes *_ops instead of individual functions. Fix up any
missing invokations of it that haven't been converted already.

9 years agoremove unneeded error.h includes
Emil Renner Berthing [Mon, 15 Sep 2014 13:29:18 +0000 (15:29 +0200)]
remove unneeded error.h includes

These are the only two places where this glibc-specific
header is included. However none of the definitions in it
seem to be used, so just remove the includes.

9 years agosd-bus: use proper ITERATOR_FIRST abstraction
Michal Schmidt [Mon, 4 Aug 2014 20:54:10 +0000 (22:54 +0200)]
sd-bus: use proper ITERATOR_FIRST abstraction

Do not assume hashmap iterators are pointers.
They may be structs in an alternative hashmap implementation.

9 years agohashmap: minor hashmap_replace optimization
Michal Schmidt [Sun, 10 Aug 2014 21:35:27 +0000 (23:35 +0200)]
hashmap: minor hashmap_replace optimization

When hashmap_replace detects no such key exists yet, it calls hashmap_put that
performs the same check again. Avoid that by splitting the core of hashmap_put
into a separate function.

9 years agohashmap, set: remove unused functions
Michal Schmidt [Thu, 31 Jul 2014 16:04:20 +0000 (18:04 +0200)]
hashmap, set: remove unused functions

The following hashmap_* and set_* functions/macros have never had any
users in systemd's history:

  *_iterate_backwards
  *_iterate_skip
  *_last
  *_FOREACH_BACKWARDS

Remove this dead code.

9 years agohashmap: introduce hash_ops to make struct Hashmap smaller
Michal Schmidt [Tue, 12 Aug 2014 23:00:18 +0000 (01:00 +0200)]
hashmap: introduce hash_ops to make struct Hashmap smaller

It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.

9 years agobuild: colorize gcc only if on tty
Michal Schmidt [Fri, 15 Aug 2014 14:33:03 +0000 (16:33 +0200)]
build: colorize gcc only if on tty

Rather than forcing gcc to always produce colorized error messages
whether on tty or not, enable automatic colorization by ensuring
GCC_COLORS is set to a non-empty string.

Doing it this way removes the need for workarounds in ~/.emacs or
~/.vimrc for "M-x compile" or ":make", respectively, to work.

9 years agotest: fix test of uid-range
Thomas Hindoe Paaboel Andersen [Sun, 14 Sep 2014 20:25:58 +0000 (22:25 +0200)]
test: fix test of uid-range

The number of uid's in the range should be tested instead of written
directly.

The test still passes with the fix checks.

Found with Coverity. Fixes: CID#1237714 - 1237722

9 years agosd-dhcp: fix test of magic cookie
Thomas Hindoe Paaboel Andersen [Sun, 14 Sep 2014 20:06:37 +0000 (22:06 +0200)]
sd-dhcp: fix test of magic cookie

The magic cookie is set in dhcp_message_init. Test the magic cookie
value intead of writing the last 3/4 of it directly.

Found with Coverity. Fixes: CID#1237732 CID#1237734 CID#1237735

9 years agoresolved: fall back to hardcoded ifindex when checking if a link is the loopback
Tom Gundersen [Sat, 13 Sep 2014 18:41:35 +0000 (20:41 +0200)]
resolved: fall back to hardcoded ifindex when checking if a link is the loopback

Reported by Philippe De Swert <philippedeswert@gmail.com>.

Coverity CID#1237656

9 years agonetworkd: remove vestigial event sources
Dave Reisner [Sat, 13 Sep 2014 18:10:33 +0000 (14:10 -0400)]
networkd: remove vestigial event sources

187fe1db took advantage of floating events, but didn't remove pointers
it made superfluous.

9 years agocore: use correct function to free CalendarSpec
Dave Reisner [Sat, 13 Sep 2014 15:18:26 +0000 (11:18 -0400)]
core: use correct function to free CalendarSpec

9 years agocore: fix a potential mem leak
Thomas Hindoe Paaboel Andersen [Sat, 13 Sep 2014 10:35:06 +0000 (12:35 +0200)]
core: fix a potential mem leak

Found with Coverity. Fixes: CID#996438

9 years agoanalyze: fix mem leak
Thomas Hindoe Paaboel Andersen [Sat, 13 Sep 2014 10:29:43 +0000 (12:29 +0200)]
analyze: fix mem leak

Found with Coverity. Fixes: CID#1237756

9 years agocore: smack-setup: Actually allow for succesfully loading CIPSO policy
Philippe De Swert [Fri, 12 Sep 2014 13:49:48 +0000 (16:49 +0300)]
core: smack-setup: Actually allow for succesfully loading CIPSO policy

The line under the last switch statement  *loaded_policy = true;
would never be executed. As all switch cases return 0. Thus the
policy would never be marked as loaded.

Found with Coverity. Fixes: CID#1237785