chiark / gitweb /
elogind.git
7 years agoCoverity #1299015
reverendhomer [Sat, 8 Aug 2015 06:49:39 +0000 (09:49 +0300)]
Coverity #1299015

bus can never be NULL due to assert

7 years agosd-daemon: return EBADF for invalid fd numbers
Zbigniew Jędrzejewski-Szmek [Fri, 7 Aug 2015 15:30:18 +0000 (11:30 -0400)]
sd-daemon: return EBADF for invalid fd numbers

This matches what open(2) and other system functions do.

7 years agosd-bus: ignore BLOOM_FILTER kdbus items
Lennart Poettering [Thu, 6 Aug 2015 12:48:33 +0000 (15:48 +0300)]
sd-bus: ignore BLOOM_FILTER kdbus items

The kernel nowadays sends these along, and that's OK, hence don't even
debug log about it, but completely ignore it.

7 years agoUse getxpid syscall on alpha for raw_getpid()
Matt Turner [Tue, 4 Aug 2015 21:47:01 +0000 (14:47 -0700)]
Use getxpid syscall on alpha for raw_getpid()

Alpha does not have a getpid syscall, but rather has getxpid to match
OSF/1.

7 years agobasic: add LIST_INSERT_BEFORE
Alex Crawford [Tue, 4 Aug 2015 06:11:53 +0000 (23:11 -0700)]
basic: add LIST_INSERT_BEFORE

Similar in function to LIST_INSERT_AFTER, this will insert a new element
into the list before the specified position. If the specified position
is NULL, the element is added as the tail of the list.

7 years agoterminal-util: no real reason to assert on O_CREAT
Lennart Poettering [Mon, 3 Aug 2015 17:06:01 +0000 (19:06 +0200)]
terminal-util: no real reason to assert on O_CREAT

That's just handle this as a normal error.

7 years agoterminal-util: when resetting terminals, don't wait for carrier
Lennart Poettering [Mon, 3 Aug 2015 17:04:08 +0000 (19:04 +0200)]
terminal-util: when resetting terminals, don't wait for carrier

In case of non-CLOCAL lines (i.e. those with carrier detect configured)
we shouldnt wait for a carrier if all we try to do is reset the TTY.
Hence, whenever we open such a TTY pass O_NONBLOCK.

Note that we continue to open ttys we intend to write to without
O_ONBLOCK, we only add it in cases we invoke ioctl()s or other terminal
operations without reading or writing to the device.

Fixes #835.

7 years agologind: add standard gpio power button support
Kefeng Wang [Mon, 3 Aug 2015 01:55:07 +0000 (09:55 +0800)]
logind: add standard gpio power button support

Many boards like hisilicon D02 board use standard gpio key to power down system.
A description of gpio-key in dts shown below,

gpio_keys {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;

pwrbutton {
label = "Power Button";
gpios = <&porta 8 1>;
linux,code = <116>;  // KEY_POWER, used by SC System Power Down
};
};

-bash-4.3# udevadm info -a /dev/input/event3

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/gpio_keys/input/input3/event3':
    KERNEL=="event3"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/platform/gpio_keys/input/input3':
    KERNELS=="input3"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="gpio_keys"
    ATTRS{phys}=="gpio-keys/input0"
    ATTRS{uniq}==""
    ATTRS{properties}=="0"

  looking at parent device '/devices/platform/gpio_keys':
    KERNELS=="gpio_keys"
    SUBSYSTEMS=="platform"
    DRIVERS=="gpio-keys"
    ATTRS{keys}=="116"
    ATTRS{switches}==""
    ATTRS{driver_override}=="(null)"
    ATTRS{disabled_keys}==""
    ATTRS{disabled_switches}==""

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

7 years agosd-bus: cleanup bus_reset_parsed_address()
Namhyung Kim [Sat, 1 Aug 2015 15:59:42 +0000 (00:59 +0900)]
sd-bus: cleanup bus_reset_parsed_address()

Both strv_free() and mfree() return NULL pointer after free.

7 years agosd-bus: use mfree() in bus_reset_queues()
Namhyung Kim [Sat, 1 Aug 2015 15:59:42 +0000 (00:59 +0900)]
sd-bus: use mfree() in bus_reset_queues()

Recently mfree() was introduced to reduce work of tedious free + reset
pointers.  Use it in bus_reset_queues() too.

7 years agosd-bus: cleanup bus_close_fds()
Namhyung Kim [Sat, 1 Aug 2015 15:35:22 +0000 (00:35 +0900)]
sd-bus: cleanup bus_close_fds()

The safe_close() already checks the fd and returns -1.

7 years agosmack-util: revise smack-util apis and add read smack attr apis
WaLyong Cho [Mon, 27 Jul 2015 17:43:55 +0000 (02:43 +0900)]
smack-util: revise smack-util apis and add read smack attr apis

- Add smack xattr lookup table
- Unify all of mac_smack_apply_xxx{_fd}() to mac_smack_apply() and
  mac_smack_apply_fd().
- Add smack xattr read apis similar with apply apis as
  mac_smack_read{_fd}().

7 years agoPrep v224: Major cleanup of unneeded functions and some source files.
Sven Eden [Tue, 3 Jan 2017 10:22:56 +0000 (11:22 +0100)]
Prep v224: Major cleanup of unneeded functions and some source files.

7 years agoPrep v224: Cleaned up src/basic/util.[ch]
Sven Eden [Tue, 3 Jan 2017 10:20:52 +0000 (11:20 +0100)]
Prep v224: Cleaned up src/basic/util.[ch]

This lead to the deletion of src/basic/device-nodes.h and
src/basic/env-util.h. Both are not needed by elogind.

Further removed the superfluous src/boot/efi/disk.[ch]

7 years agoPrep v224: Sync root build files with upstream
Sven Eden [Tue, 3 Jan 2017 09:08:11 +0000 (10:08 +0100)]
Prep v224: Sync root build files with upstream

7 years agoPrep v223: Remove superfluous src/resolve/resolved-llmnr.[hc]
Sven Eden [Tue, 3 Jan 2017 08:48:33 +0000 (09:48 +0100)]
Prep v223: Remove superfluous src/resolve/resolved-llmnr.[hc]

7 years agoPrep v220: Updated src/basic/missing.h to upstream version.
Sven Eden [Tue, 3 Jan 2017 08:41:39 +0000 (09:41 +0100)]
Prep v220: Updated src/basic/missing.h to upstream version.

7 years agoPrep v223: Sync basic build system with upstream.
Sven Eden [Tue, 3 Jan 2017 08:38:07 +0000 (09:38 +0100)]
Prep v223: Sync basic build system with upstream.

7 years agoPrep v222: Update build system:
Sven Eden [Fri, 30 Dec 2016 14:43:50 +0000 (15:43 +0100)]
Prep v222: Update build system:

- The content of the man pages directory has been overhauled
- Makefile-man.am was regenerated
- Makefile.am and configure.ac needed a few addtitions and fixes
- Some masked functions had to be unmasked
- Now superfluous files have been removed

7 years agoPrep v220: Update non-critical root files to the upstream versions.
Sven Eden [Fri, 30 Dec 2016 14:20:35 +0000 (15:20 +0100)]
Prep v220: Update non-critical root files to the upstream versions.

7 years agoPrep v221: Some more cleanup and a few fixes
Sven Eden [Fri, 30 Dec 2016 13:09:01 +0000 (14:09 +0100)]
Prep v221: Some more cleanup and a few fixes

The files
- src/core/org.freedesktop.systemd.policy.in.in and
- src/core/systemd.pc.in
have been deleted as they are not needed.

The other changes are some minor fixes.

7 years agoPrep v221: Update and clean up build system to sync with upstream
Sven Eden [Fri, 16 Dec 2016 11:09:41 +0000 (12:09 +0100)]
Prep v221: Update and clean up build system to sync with upstream

This commit replays the moving around of source files that have been
done between systemd-219 and systemd-221.

Further the Makefile.am is synchronized with the upstream version and
then "re-cleaned".

A lot of functions, that are not used anywhere in elogind have been
coated into #if 0/#endif directives to further shorten the list of
dependencies.

All unneeded files have been removed.

7 years agoPrep v220: Apply "Fixes to user and session saving"
Sven Eden [Mon, 5 Dec 2016 08:21:35 +0000 (09:21 +0100)]
Prep v220: Apply "Fixes to user and session saving"

7 years agoPrep v220: elogind does not need to register with systemd1.*
Sven Eden [Thu, 1 Dec 2016 08:33:44 +0000 (09:33 +0100)]
Prep v220: elogind does not need to register with systemd1.*

7 years agoPrep v220: Update src/login/org.freedesktop.login1.conf to the most recent version.
Sven Eden [Wed, 30 Nov 2016 12:28:38 +0000 (13:28 +0100)]
Prep v220: Update src/login/org.freedesktop.login1.conf to the most recent version.

7 years agoPrep v220: Remove all source files, taht are not needed to build elogind.
Sven Eden [Wed, 30 Nov 2016 08:44:44 +0000 (09:44 +0100)]
Prep v220: Remove all source files, taht are not needed to build elogind.
Prep v220: Remove not needed headers, round 1
Prep v220: Remove not needed headers, round 2
Prep v220: Remove not needed headers, round 3
Prep v220: Remove empty source directories
Prep v220: Remove non-empty source directories, that aren't needed by elogind
Prep v220: Remove all root directories that aren't referenced by the elogind build chain.
Prep v220: remove superfluous src/import directory and systemd configurations and policies.

7 years agoPrep v220: Use new cgroups functions
Sven Eden [Mon, 28 Nov 2016 03:53:40 +0000 (04:53 +0100)]
Prep v220: Use new cgroups functions
Prep v220: Update logind and loginctl to upstream version.
Prep v220: src/shared/rm-rf.c does not need to be able to handle btrfs subvolumes for elogind.

7 years agoMerge remaining elogind/master root files of the systemd upstream tag 'v220'
Sven Eden [Fri, 25 Nov 2016 07:49:28 +0000 (08:49 +0100)]
Merge remaining elogind/master root files of the systemd upstream tag 'v220'

7 years agoClassify processes from sessions into cgroups
Andy Wingo [Sun, 6 Mar 2016 15:02:31 +0000 (16:02 +0100)]
Classify processes from sessions into cgroups

Create a private cgroup tree associated with no controllers, and use it
to map PIDs to sessions.  Since we use our own path structure, remove
internal cgroup-related helpers that interpret the cgroup path structure
to pull out users, slices, and scopes.

7 years agoStop sessions on ReleaseSession
Andy Wingo [Tue, 1 Sep 2015 10:30:17 +0000 (12:30 +0200)]
Stop sessions on ReleaseSession

7 years agoFix the login monitor
Andy Wingo [Tue, 1 Sep 2015 09:54:25 +0000 (11:54 +0200)]
Fix the login monitor

* src/login/logind.c (main): Create /run/systemd/machines, so that the
  login monitor works.
* configure.ac: v219.10.

7 years agoHandle suspend/hibernate/hybrid-suspend/shutdown/reboot directly
Andy Wingo [Sun, 23 Aug 2015 12:54:39 +0000 (14:54 +0200)]
Handle suspend/hibernate/hybrid-suspend/shutdown/reboot directly

* configure.ac: Get paths of halt and reboot.
* Makefile.am (systemsleepdir, systemshutdowndir): New variables.  Look
  in them for hooks to run.

* src/login/logind-action.c: Inline the salient bits from systemd's
  system-sleep.c here.

* src/login/logind-dbus.c (execute_shutdown_or_sleep): Call our own
  shutdown_or_sleep helper instead of invoking a systemd method.

* src/login/logind.h: Declare shutdown_or_sleep.

7 years agoBeginnings of handling suspend/etc within logind
Andy Wingo [Sun, 23 Aug 2015 10:28:10 +0000 (12:28 +0200)]
Beginnings of handling suspend/etc within logind

Since we are catching the keys, we might as well just do
suspend/reboot/etc handling here.

7 years agoRemove systemd subscription and user/session units
Andy Wingo [Sun, 23 Aug 2015 09:50:26 +0000 (11:50 +0200)]
Remove systemd subscription and user/session units

This removes attempts by logind to listen to systemd messages over the
bus, and to start and/or manage units associated with sessions and
users.

7 years agoRemove support for auto-spawning VTs
Andy Wingo [Sun, 23 Aug 2015 09:17:14 +0000 (11:17 +0200)]
Remove support for auto-spawning VTs

Auto-spawning VTs requires systemd in practice.  If you're using systemd
you can just use its logind :)

7 years agoActually working with pam
Andy Wingo [Thu, 20 Aug 2015 08:53:41 +0000 (10:53 +0200)]
Actually working with pam

* src/login/logind-user.c (user_start): Don't start slices and
  systemd-user services.

* src/login/logind-dbus.c (method_create_session): Send a reply directly
  instead of waiting on systemd that isn't there.

* configure.ac: Bump version.

7 years agoCreate /run/systemd as needed
Andy Wingo [Thu, 20 Aug 2015 07:21:04 +0000 (09:21 +0200)]
Create /run/systemd as needed

* src/login/logind.c (main): Also create /run/systemd at startup.
* configure.ac: Bump to 219.3.

7 years agologind: release VT-positions when closing sessions
David Herrmann [Fri, 31 Jul 2015 14:52:29 +0000 (16:52 +0200)]
logind: release VT-positions when closing sessions

Make sure we release VT-positions when a session is closed. Otherwise,
lingering sessions will occupy VTs and prevent next logins from
succeeding.

Note that we already release session-devices when closing a session, so
there cannot be anyone using the VT anymore.

7 years agobus-proxy: make StartServiceByName synchronous
David Herrmann [Fri, 31 Jul 2015 11:25:04 +0000 (13:25 +0200)]
bus-proxy: make StartServiceByName synchronous

The StartServiceByName() call was provided by dbus-daemon to activate a
service without sending a message. On receiption, dbus-daemon schedules
an activation request (different modes are supported) and sends back the
reply once activation is done.

With kdbus, we marked StartServiceByName() as deprecated. There is no
real reason to start services explicitly. Instead, applications should
just *use* the service and rely on it being activated implicitly.
However, we provide compatibility with dbus-daemon and implement
StartServiceByName() on the proxy via a call to
org.freedesktop.DBus.Peer.Ping() on the destination. This will activate
the peer implicitly as part of the no-op Ping() method call (regardless
whether the peer actually implements that call).

Now, the problem is, StartServiceByName() was synchronous on dbus-daemon
but isn't on bus-proxy. Hence, on return, there is no guarantee that
ListNames includes the activated name. As this is required by some
applications, we need to make this synchronous.

This patch makes the proxy track the Ping() method call and send the
reply of StartServiceByName() only once Ping() returned. We do not look
at possible errors of Ping(), as there is no strict requirement for the
peer to implement org.freedesktop.DBus.Peer. Furthermore, any interesting
error should have already been caught by sd_bus_send() before.

Note:
        This race was triggered by gdbus. The gdbus-proxy implementation
        relies on a name to be available after StartServiceByName()
        returns. This is highly fragile and should be dropped by gdbus.
        Even if the call is synchronous, there is no reason whatsoever to
        assume the service did not exit-on-idle before ListNames()
        returns.
        However, this race is much less likely than the startup race, so
        we try to be compatible to dbus-daemon now.

7 years agosd-bus: fix parsing of KDBUS_CMD_LIST
David Herrmann [Thu, 30 Jul 2015 12:12:09 +0000 (14:12 +0200)]
sd-bus: fix parsing of KDBUS_CMD_LIST

We *must not* assume that an entry returned by KDBUS_CMD_LIST only
carries a single KDBUS_ITEM_OWNED_NAME. Similarly, we already parse
multiple such items for message-metadata, so make sure we support the
same on KDBUS_CMD_LIST.

By relying on the kernel to return all names separately, we limit the
kernel API significantly. Stop this and let the kernel decide how to
return its data.

7 years agosd-boot: stub - export LoaderDevicePartUUID
Kay Sievers [Wed, 29 Jul 2015 17:26:49 +0000 (19:26 +0200)]
sd-boot: stub - export LoaderDevicePartUUID

7 years agosd-bus: fix encoding/decoding gvariant root container
David Herrmann [Wed, 29 Jul 2015 13:58:25 +0000 (15:58 +0200)]
sd-bus: fix encoding/decoding gvariant root container

The gvariant root container contains a 'variant' at the end, which embeds
the whole message body. This variant *must* contain a structure so we are
compatible to dbus1. Otherwise, it could encode at most 1 type, instead
of a full signature.

Our gvariant message parser already parses the variant-content as a
structure, so we're mostly good. However, it does *not* include the
opening and closing parantheses, nor does it parse them.

This patch fixes the decoder to verify a message contains the
parantheses, and also make the encoder add those parantheses into the
marshaled message.

7 years agosocket-util: library calls shouldn't log on their own
Lennart Poettering [Wed, 29 Jul 2015 10:33:44 +0000 (12:33 +0200)]
socket-util: library calls shouldn't log on their own

Instead, make sure that all callers log properly.

7 years agoresolved: never attempt to resolve loopback addresses via DNS/LLMNR/mDNS
Lennart Poettering [Wed, 29 Jul 2015 10:22:55 +0000 (12:22 +0200)]
resolved: never attempt to resolve loopback addresses via DNS/LLMNR/mDNS

We already refuse to resolve "localhost", hence we should also refuse
resolving "127.0.0.1" and friends.

7 years agonetworkd: vxlan add support for GBP
Susant Sahani [Wed, 29 Jul 2015 08:35:34 +0000 (14:05 +0530)]
networkd: vxlan add support for GBP

This patch add support for vxlan  VXLAN Group Policy Option.

https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00
http://lwn.net/Articles/628683/

7 years agosd-netlink: introduce api for new NL type NLA_FLAG
Susant Sahani [Wed, 29 Jul 2015 06:29:16 +0000 (11:59 +0530)]
sd-netlink: introduce api for new NL type NLA_FLAG

7 years agosd-netlink: add support for new type NETLINK_TYPE_FLAG
Susant Sahani [Wed, 29 Jul 2015 05:47:08 +0000 (11:17 +0530)]
sd-netlink: add support for new type NETLINK_TYPE_FLAG

NETLINK_TYPE_FLAG is NLA_FLAG.

This new type will be used in NLA_FLAG for example

IFLA_VXLAN_GBP  and IFLA_VXLAN_REMCSUM_NOPARTIAL

7 years agosd-netlink: add support for vxlan attributes
Susant Sahani [Wed, 29 Jul 2015 05:44:28 +0000 (11:14 +0530)]
sd-netlink: add support for vxlan attributes

7 years agosd-bus: fix marshaling of unary type
David Herrmann [Tue, 28 Jul 2015 16:16:16 +0000 (18:16 +0200)]
sd-bus: fix marshaling of unary type

The unary type has a fixed size of 1 in gvariant. Make sure we properly
encode it as such. Right now, we encode/decode it as empty sequence.

7 years agosd-bus: drop redundant code
David Herrmann [Tue, 28 Jul 2015 16:13:33 +0000 (18:13 +0200)]
sd-bus: drop redundant code

If c->item_size is 0, the next item to parse in a structure is empty.
However, this also implies that the signature must be empty. The latter
case is already handled just fine by enter_struct_or_dict_entry() so
there is no reason to handle the same case in the caller.

7 years agosd-bus: don't assert() on valid signatures
David Herrmann [Tue, 28 Jul 2015 14:46:51 +0000 (16:46 +0200)]
sd-bus: don't assert() on valid signatures

Right now sd_bus_message_skip() will abort execution if passed a
signature of the unary type "()". Regardless whether this should be
supported or not, we really must not abort. Drop the incorrect assertion
and add a test-case for this.

7 years agohwdb: add min/max/resolution override for Appletouch one-button touchpads
Peter Hutterer [Mon, 27 Jul 2015 22:17:04 +0000 (08:17 +1000)]
hwdb: add min/max/resolution override for Appletouch one-button touchpads

Macbook2,1, late 2006 model.

https://bugzilla.redhat.com/show_bug.cgi?id=1246651

7 years agohwdb: add resolution values for Asus K52JT touchpad
Peter Hutterer [Mon, 27 Jul 2015 10:04:25 +0000 (20:04 +1000)]
hwdb: add resolution values for Asus K52JT touchpad

https://bugs.freedesktop.org/show_bug.cgi?id=91364

7 years agosd-netlink: Add macvtap support
Susant Sahani [Mon, 27 Jul 2015 05:48:07 +0000 (11:18 +0530)]
sd-netlink: Add macvtap support

7 years agoman: typo fixes
Thomas Hindoe Paaboel Andersen [Sat, 25 Jul 2015 21:15:05 +0000 (23:15 +0200)]
man: typo fixes

7 years agonetlink-types: use consistent whitespace at EOL
Zbigniew Jędrzejewski-Szmek [Sat, 25 Jul 2015 01:41:35 +0000 (21:41 -0400)]
netlink-types: use consistent whitespace at EOL

Follow up for v222-124-g79e27dbcb1.

7 years agosd-bus: remove _VTABLE from new method vtable initialiser
daurnimator [Fri, 24 Jul 2015 12:59:19 +0000 (22:59 +1000)]
sd-bus: remove _VTABLE from new method vtable initialiser

7 years agosd-bus: add 'offset' member for vtable methods
daurnimator [Fri, 24 Jul 2015 12:22:54 +0000 (22:22 +1000)]
sd-bus: add 'offset' member for vtable methods

Defaults to zero, which retains the current behaviour.
Fixes #577

7 years agosd-bus: don't treat KDBUS_ITEM_TIMESTAMP as unknown item
David Herrmann [Fri, 24 Jul 2015 10:37:12 +0000 (12:37 +0200)]
sd-bus: don't treat KDBUS_ITEM_TIMESTAMP as unknown item

In bus_kernel_translate_message(), we print a DEBUG message on unknown
items. But right now, we also print this message for KDBUS_ITEM_TIMESTAMP
despite parsing it properly. Fix this!

7 years agotreewide: fix typos
Torstein Husebø [Fri, 24 Jul 2015 09:14:01 +0000 (11:14 +0200)]
treewide: fix typos

7 years agounits: order networkd after sysctl
Tom Gundersen [Thu, 23 Jul 2015 18:58:33 +0000 (20:58 +0200)]
units: order networkd after sysctl

This way networkd will correctly and race-freely inherit the default settings
applied by sysctl.

Suggested in issue #468.

7 years agoresolved: rr - ignore pseudo types in NSEC(3) bitmaps
Tom Gundersen [Thu, 23 Jul 2015 11:48:56 +0000 (13:48 +0200)]
resolved: rr - ignore pseudo types in NSEC(3) bitmaps

7 years agosd-netlink: add bridge NL params
Susant Sahani [Thu, 23 Jul 2015 09:09:43 +0000 (09:09 +0000)]
sd-netlink: add bridge NL params

7 years agosd-netlink: add tunnel params
Susant Sahani [Wed, 22 Jul 2015 09:29:23 +0000 (14:59 +0530)]
sd-netlink: add tunnel params

7 years agosd-bus: fix path of object-manager signals
David Herrmann [Tue, 21 Jul 2015 10:59:56 +0000 (12:59 +0200)]
sd-bus: fix path of object-manager signals

Each signal of the ObjectManager interface carries the path of the object
in question as an argument. Therefore, a caller will deduce the object
this signal is generated for, by parsing the _argument_. A caller will
*not* use the object-path of the message itself (i.e., message->path).
This is done on purpose, so the caller can rely on message->path to be
the path of the actual object-manager that generated this signal, instead
of the path of the object that triggered this signal.

This commit fixes all InterfacesAdded/Removed signals to use the path of
the closest object-manager as message->path. 'closest' in this case means
closest parent with at least one object-manager registered.

This fix raises the question what happens if we stack object-managers in
a hierarchy. Two implementations are possible: First, we report each
object only on the nearest object-manager. Second, we report it on each
parent object-manager. This patch chooses the former. This is compatible
with other existing ObjectManager implementations, which are required to
call GetManagedObjects() recursively on each object they find, which
implements the ObjectManager interface.

7 years agologind: fix write_string_file() fallout
Daniel Mack [Mon, 20 Jul 2015 21:17:37 +0000 (23:17 +0200)]
logind: fix write_string_file() fallout

WRITE_STRING_FILE_ATOMIC is only valid if WRITE_STRING_FILE_CREATE is also
given. IOW, an atomic file write operation is only possible when creating a
file is also being asked for.

This is a regression from the recent write_string_file() rework.

7 years agoshared: dns-name - introduce dns_label_unescape_suffix()
Tom Gundersen [Mon, 20 Jul 2015 14:01:03 +0000 (16:01 +0200)]
shared: dns-name - introduce dns_label_unescape_suffix()

Intended to be called repeatedly, and returns then successive unescaped labels
from the most to the least significant (left to right).

This is slightly inefficient as it scans the string three times (two would be
sufficient): once to find the end of the string, once to find the beginning
of each label and lastly once to do the actual unescaping. The latter two
could be done in one go, but that seemed unnecessarily convoluted.

7 years agoshared: dns-name - use the canonical dns name ordering
Tom Gundersen [Mon, 20 Jul 2015 14:01:03 +0000 (16:01 +0200)]
shared: dns-name - use the canonical dns name ordering

The canonical DNS name ordering considers the rightmost label the most significant,
we were considering it the least significant. This is important when implementing
NSEC, which relies on the correct order.

7 years agosd-netlink: add tunnel NL parameters
Susant Sahani [Mon, 20 Jul 2015 04:47:14 +0000 (10:17 +0530)]
sd-netlink: add tunnel NL parameters

7 years agoshared: dns-name - add dns_name_between()
Tom Gundersen [Mon, 20 Jul 2015 00:02:45 +0000 (02:02 +0200)]
shared: dns-name - add dns_name_between()

Given three DNS names this function indicates if the second argument lies
strictly between the first and the third according to the canonical DNS
name order. Note that the order is circular, so the last name is
considered to be before the first.

7 years agologind: never select closing sessions for a VT
David Herrmann [Thu, 16 Jul 2015 16:46:12 +0000 (18:46 +0200)]
logind: never select closing sessions for a VT

If a session is in closing state (and already got rid of its VT), then
never re-select it for that VT. There is no reason why we should grant
something to a session that is already going away *AND* already got rid
of exactly that.

7 years agologind: prefer new sessions over older ones on VT switches
David Herrmann [Thu, 16 Jul 2015 16:18:01 +0000 (18:18 +0200)]
logind: prefer new sessions over older ones on VT switches

Our seat->positions[] array keeps track of the 'preferred' session on a
VT. The only situation this is used, is to select the session to activate
when a VT is activated. In the normal case, there's only one session per
VT so the selection is trivial.

Older greeters, however, implement take-overs when they start sessions on
the same VT that the greeter ran on. We recently limited such take-overs
to VTs where a greeter is running on, to force people to never share VTs
in new code that is written.

For legacy reasons, we need to be compatible to old greeters, though.
Hence, we allow those greeters to implement take-over. In such take-overs,
however, we should really make sure that the new sessions gets preferred
over the old one under all circumstances. Hence, make sure we override
the previous preferred session with a new session.

7 years agonetworkd: move config_parse_vxlan_group_address
Susant Sahani [Thu, 16 Jul 2015 14:44:05 +0000 (20:14 +0530)]
networkd: move config_parse_vxlan_group_address

move config_parse_vxlan_group_address from
networkd.h to networkd-netdev-vxlan.h

7 years agobus-proxy: never pass on unmatched broadcasts
David Herrmann [Thu, 16 Jul 2015 13:14:43 +0000 (15:14 +0200)]
bus-proxy: never pass on unmatched broadcasts

The lovely libvirtd goes into crazy mode if it receives broadcasts that
it didn't subscribe to. With bus-proxyd, this might happen in 2 cases:

    1) The kernel passes us an unmatched signal due to a false-positive
       bloom-match.

    2) We generate NameOwnerChanged/NameAcquired/NameLost locally even
       though the peer didn't subscribe to it.

dbus-daemon is reliable in what signals it passes on. So make sure we
follow that style. Never ever send a signal to a local peer if it doesn't
match an installed filter of that peer.

7 years agosd-bus: fix invalid stack access on test-bus-marshal
David Herrmann [Thu, 16 Jul 2015 12:57:59 +0000 (14:57 +0200)]
sd-bus: fix invalid stack access on test-bus-marshal

Make sure we actually parse "unsigned long long" if we encode a uint64_t.
Otherwise, we will get random data from the stack.

7 years agosd-bus: properly match ID changes
David Herrmann [Thu, 16 Jul 2015 12:37:08 +0000 (14:37 +0200)]
sd-bus: properly match ID changes

If the caller does not specify arg1 for NameOwnerChanged matches, we
really must take the ID from arg2 or arg3, if provided. They are
guaranteed to be identical to arg1 if either is supplied, but there is no
strict requiredment that arg1 is supplied. Hence, make sure to always
take the more restrictive match. Otherwise, we install rather wide
matches without anyone requiring them.

7 years agosd-bus: destination-matches cannot match NameOwnerChanged
David Herrmann [Thu, 16 Jul 2015 12:35:15 +0000 (14:35 +0200)]
sd-bus: destination-matches cannot match NameOwnerChanged

Make sure we don't install NameOwnerChanged matches if the caller passed
a destination='' match (except if it is the broadcast address). Per spec,
all NameOwnerChanged signals are broadcasts.

Only the NameLost/NameAcquired signals are unicasts, but those are never
received through sd-bus. Instead, the bus-proxy synthesizes them and it
already installs proper matches for them.

7 years agosd-bus: fix gvariant structure encoding
David Herrmann [Thu, 16 Jul 2015 09:00:55 +0000 (11:00 +0200)]
sd-bus: fix gvariant structure encoding

In gvariant, all fixed-size objects need to be sized a multiple of their
alignment. If a structure has only fixed-size members, it is required to
be fixed size itself. If you imagine a structure like (ty), you have an
8-byte member followed by an 1-byte member. Hence, the overall inner-size
is 9. The alignment of the object is 8, though. Therefore, the specs
mandates final padding after fixed-size structures, to make sure it's
sized a multiple of its alignment (=> 16).

On the gvariant decoder side, we already account for this in
bus_gvariant_get_size(), as we apply overall padding to the size of the
structure. Therefore, our decoder correctly skips such final padding when
parsing fixed-size structure.

On the gvariant encoder side, however, we don't account for this final
padding. This patch fixes the structure and dict-entry encoders to
properly place such padding at the end of non-uniform fixed-size
structures.

The problem can be easily seen by running:
    $ busctl --user monitor
and
    $ busctl call --user org.freedesktop.systemd1 / org.foobar foobar "(ty)" 777 8

The monitor will fail to parse the message and print an error. With this
patch applied, everything works fine again.

This patch also adds a bunch of test-cases to force non-uniform
structures with non-pre-aligned positions.

Thanks to Jan Alexander Steffens <jan.steffens@gmail.com> for spotting
this and narrowing it down to non-uniform gvariant structures. Fixes #597.

7 years agosd-bus: fix object tree to be deeper than 2 levels
David Herrmann [Wed, 15 Jul 2015 12:35:15 +0000 (14:35 +0200)]
sd-bus: fix object tree to be deeper than 2 levels

So right now our object-tree is limited to 2 levels at most
('/' and '/foo/...../bar'). We never link any intermediate levels, even
though that was clearly the plan. Fix the bus_node_allocate() helper to
actually link all intermediate nodes, too, not just the root node.

This fixes a simple inverse ptr-diff bug.

The downside of this fix is that we clearly never tested (nor used) the
object tree in any way. The only reason that the introspection works is
that our enumerators shortcut the object tree.

Lets see whether that code actually works..

Thanks to: Nathaniel McCallum <nathaniel@themccallums.org>
..for reporting this. See #524 for an actual example code.

7 years agosd-device: never return NULL+0
David Herrmann [Wed, 15 Jul 2015 10:30:08 +0000 (12:30 +0200)]
sd-device: never return NULL+0

It is highly confusing if a getter function returns 0, but the value is
set to NULL. This, right now, triggers assertions as code relies on the
returned values to be non-NULL.

Like with sd-bus-creds and friends, return 0 only if a value is actually
available.

Discussed with Tom, and actually fixes real bugs as in #512.

7 years agonetworkd: tap add support for vnet_hdr
Susant Sahani [Tue, 14 Jul 2015 08:25:52 +0000 (13:55 +0530)]
networkd: tap add support for vnet_hdr

 This patch adds support to configure IFF_VNET_HDR flag
for a tap device. It allows whether sending and receiving
large pass larger (GSO) packets. This greatly increases the
achievable throughput.

7 years agodoc: configure docbook stylesheet to generate reproducible IDs
Johan Ouwerkerk [Mon, 13 Jul 2015 08:39:09 +0000 (10:39 +0200)]
doc: configure docbook stylesheet to generate reproducible IDs

This makes auto generated anchor tags in HTML output reproducible.

7 years agoUse a top-to-bottom numbering scheme for generating ids of subheadings and terms...
Johan Ouwerkerk [Sun, 12 Jul 2015 01:07:24 +0000 (03:07 +0200)]
Use a top-to-bottom numbering scheme for generating ids of subheadings and terms. This scheme fixes permalinks to distinguish between items that would previously have the same ID attribute.

Where possible the generated ID values are the same as those generated with the previous versions of the stylesheet
to retain backwards compatibility with published links.

As a side effect of the changes xsltproc should no longer complain about duplicate IDs during build.

7 years agologind: bring bus policy up-to-date
Lennart Poettering [Sat, 11 Jul 2015 20:00:26 +0000 (17:00 -0300)]
logind: bring bus policy up-to-date

A while back we opened up all of logind's bus calls to unprivileged
users, via PK. However, the dbus1 policy wasn't updated accordingly.

With this change, the dbus1 policy is opened up for all bus calls that
should be available to unprivileged clients.

(also rearranges some calls in the vtable, to make more sense, and be in
line with the order in the bus policy file)

Fixes #471.

7 years agoresolved: use a #define for LLMNR port
Daniel Mack [Fri, 10 Jul 2015 19:28:09 +0000 (15:28 -0400)]
resolved: use a #define for LLMNR port

De-duplicate some magic numbers.

7 years agoresolved: move LLMNR related functions into separate file
Daniel Mack [Fri, 10 Jul 2015 19:02:38 +0000 (15:02 -0400)]
resolved: move LLMNR related functions into separate file

7 years agologind: rename 'pos' to 'position'
David Herrmann [Fri, 10 Jul 2015 13:08:24 +0000 (15:08 +0200)]
logind: rename 'pos' to 'position'

Spell out the proper name. Use 'pos' over 'position', and also update the
logind state file to do the same. Note that this breaks live updates.
However, we only save 'POSITION' on non-seat0, so this shouldn't bother
anyone for real. If you run multi-seat setups, you better restart a
machine on updates, anyway.

7 years agologind: allow greeters to take over VTs
David Herrmann [Fri, 10 Jul 2015 12:53:08 +0000 (14:53 +0200)]
logind: allow greeters to take over VTs

Make sure a greeter can forcefully spawn a session on a VT that is
in-use. A recent patch prevented this (this used to be possible for all
session types) as it is highly fragile. However, as it turns out,
greeters seem to rely on that feature. Therefore, make sure we allow it
explicitly for greeters.

7 years agonss-mymachines: map userns users of containers to real user names
Lennart Poettering [Thu, 9 Jul 2015 17:46:20 +0000 (14:46 -0300)]
nss-mymachines: map userns users of containers to real user names

Given a container "foo", that maps user id $UID to container user, using
user namespaces, this NSS module extenstion will now map the $UID to a
name "vu-foo-$TUID" for the translated UID $UID.

Similar, userns groups are mapped to "vg-foo-$TGID" for translated GIDs
of $GID.

This simple change should make userns users more discoverable. Also,
given that many tools like "adduser" check NSS before allocating a UID,
should lower the chance of UID range conflicts between tools.

7 years agosd-bus: include queried path in GetManagedObjects
David Herrmann [Thu, 9 Jul 2015 11:27:57 +0000 (13:27 +0200)]
sd-bus: include queried path in GetManagedObjects

If GetManagedObjects is called on /foo/bar, then it should also include
the object /foo/bar, if it exists. Right now, we only include objects
underneath /foo/bar/.

This follows the behavior of existing dbus implementations.

Obsoletes #527 and fixes #525. Reported by: Nathaniel McCallum

7 years agosd-bus: sd_bus_slot_get_description() should return const strings
David Herrmann [Thu, 9 Jul 2015 08:40:41 +0000 (10:40 +0200)]
sd-bus: sd_bus_slot_get_description() should return const strings

All other *_get_description() functions use 'const char**', so make sure
sd_bus_slot_get_description() does the same.

This changes API, but ABI stays stable. I think this is fine, but I
wouldn't mind bumping SONAME.

Reported in #528.

7 years agoproperty callback returns are consistent
Umut Tezduyar Lindskog [Wed, 8 Jul 2015 12:35:32 +0000 (14:35 +0200)]
property callback returns are consistent

It is no different to return 0 over 1 in the property
callback. It is confusing to return 1 which made me think
1 has a special purpose. This way code is consistent with
the rest of the tree.

7 years agologind: fail on CreateSession if already in session
David Herrmann [Tue, 7 Jul 2015 17:38:41 +0000 (19:38 +0200)]
logind: fail on CreateSession if already in session

Right now, if you're already in a session and call CreateSession, we
return information about the current session of yours. This is highy
confusing and a nasty hack. Avoid that, and instead return a commonly
known error, so the caller can detect that.

This has the side-effect, that we no longer override XDG_VTNR and XDG_SEAT
in pam_systemd, if you're already in a session. But this sounds like the
right thing to do, anyway.

7 years agologind: allow sessions to share a VT if it's a greeter
David Herrmann [Tue, 7 Jul 2015 17:13:52 +0000 (19:13 +0200)]
logind: allow sessions to share a VT if it's a greeter

Old gdm and lightdm start the user-session during login before they
destroy the greeter-session. Therefore, the user-session will take over
the VT from the greeter. We recently prevented this by never allowing
multiple sessions on the same VT. Fix this now, by explicitly allowing
this if the owning session is a GREETER.

Note that gdm no longer behaves like this. Instead, due to wayland, they
always use a different VT for each session. All other login-managers are
highly encouraged to destroy the greeter-session _before_ starting the
user-session. We now work around this, but this will probably not last
forever (and will already have nasty side-effects on the greeter-session).

7 years agoRemove repeated 'the's
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jul 2015 11:40:53 +0000 (07:40 -0400)]
Remove repeated 'the's

7 years agologin: use normal comparison to zero for integers
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jul 2015 00:04:13 +0000 (20:04 -0400)]
login: use normal comparison to zero for integers

! is supposed to be used for booleans and pointers.

7 years agotree-wide: fix write_string_file() user that should not create files
Daniel Mack [Mon, 6 Jul 2015 23:27:20 +0000 (19:27 -0400)]
tree-wide: fix write_string_file() user that should not create files

The latest consolidation cleanup of write_string_file() revealed some users
of that helper which should have used write_string_file_no_create() in the
past but didn't. Basically, all existing users that write to files in /sys
and /proc should not expect to write to a file which is not yet existant.

7 years agofileio: consolidate write_string_file*()
Daniel Mack [Mon, 6 Jul 2015 23:19:25 +0000 (19:19 -0400)]
fileio: consolidate write_string_file*()

Merge write_string_file(), write_string_file_no_create() and
write_string_file_atomic() into write_string_file() and provide a flags mask
that allows combinations of atomic writing, newline appending and automatic
file creation. Change all users accordingly.

7 years agofileio: add 'enforce_newline' argument to write_string_stream()
Daniel Mack [Mon, 6 Jul 2015 21:31:44 +0000 (17:31 -0400)]
fileio: add 'enforce_newline' argument to write_string_stream()

Add a flag to control whether write_string_stream() should always enforce a
trailing newline character in the file.

7 years agodocs: add .gitignore
Kay Sievers [Mon, 6 Jul 2015 15:46:43 +0000 (17:46 +0200)]
docs: add .gitignore