chiark / gitweb /
3 years agoRemove utmp stuff that has found it's way back in.
Sven Eden [Thu, 12 Jan 2017 08:27:29 +0000 (09:27 +0100)]
Remove utmp stuff that has found it's way back in.

3 years agoRemove tmpfiles.d
Sven Eden [Tue, 10 Jan 2017 04:31:13 +0000 (05:31 +0100)]
Remove tmpfiles.d

3 years agoPrep 4xx6: Fix logind_gperf_lookup declaration
Sven Eden [Tue, 10 Jan 2017 04:17:13 +0000 (05:17 +0100)]
Prep 4xx6: Fix logind_gperf_lookup declaration

3 years agoPrep v226: Mask all unneeded functions
Sven Eden [Mon, 9 Jan 2017 05:04:26 +0000 (06:04 +0100)]
Prep v226: Mask all unneeded functions

3 years agoPrep v226: loginctl.c: Fix call to (changed) cg_is_empty_recursive().
Sven Eden [Mon, 9 Jan 2017 05:18:16 +0000 (06:18 +0100)]
Prep v226: loginctl.c: Fix call to (changed) cg_is_empty_recursive().

3 years agoPrep v226: Fix some function prototypes in bus-util.h
Sven Eden [Mon, 9 Jan 2017 05:16:42 +0000 (06:16 +0100)]
Prep v226: Fix some function prototypes in bus-util.h

3 years agoPrep v226: Add src/basic/copy.[hc] to libbasic, the function copy_bytes() is needed...
Sven Eden [Mon, 9 Jan 2017 05:13:40 +0000 (06:13 +0100)]
Prep v226: Add src/basic/copy.[hc] to libbasic, the function copy_bytes() is needed by pager.c

3 years agoPrep v220: Fix src/basic/time-util.h, unmask timezone_is_valid, mask unneeded functions.
Sven Eden [Mon, 9 Jan 2017 04:58:48 +0000 (05:58 +0100)]
Prep v220: Fix src/basic/time-util.h, unmask timezone_is_valid, mask unneeded functions.

3 years agoPrep v226: Apply missing fixes and changes to src/shared
Sven Eden [Mon, 9 Jan 2017 04:53:02 +0000 (05:53 +0100)]
Prep v226: Apply missing fixes and changes to src/shared

3 years agoPrep v226: Apply missing fixes and changes to src/login
Sven Eden [Mon, 9 Jan 2017 04:53:01 +0000 (05:53 +0100)]
Prep v226: Apply missing fixes and changes to src/login

3 years agoPrep v226: Apply missing fixes and changes to src/libelogind
Sven Eden [Mon, 9 Jan 2017 04:53:01 +0000 (05:53 +0100)]
Prep v226: Apply missing fixes and changes to src/libelogind

3 years agoPrep v226: Apply missing fixes and changes to src/basic
Sven Eden [Mon, 9 Jan 2017 04:53:00 +0000 (05:53 +0100)]
Prep v226: Apply missing fixes and changes to src/basic

3 years agoPrep v226: Sync build files with upstream
Sven Eden [Thu, 5 Jan 2017 05:21:16 +0000 (06:21 +0100)]
Prep v226: Sync build files with upstream

3 years agosd-bus: when connecting to a container AF_UNIX bus, return error
Lennart Poettering [Mon, 7 Sep 2015 17:52:11 +0000 (19:52 +0200)]
sd-bus: when connecting to a container AF_UNIX bus, return error

When forking of a child process for connecting to a container, pass
the preicse connection error to the calling process.

We already did this correctly for kdbus busses, let's do so for dbus1
busses, too.

3 years agoUpdated Polish translation
Piotr Drąg [Sun, 6 Sep 2015 18:42:16 +0000 (20:42 +0200)]
Updated Polish translation

3 years agologind: make scope of wall message handling smaller
Lennart Poettering [Sat, 5 Sep 2015 18:24:08 +0000 (20:24 +0200)]
logind: make scope of wall message handling smaller

3 years agosd-bus: make introspection data non-recursive
David Herrmann [Sat, 5 Sep 2015 17:43:29 +0000 (19:43 +0200)]
sd-bus: make introspection data non-recursive

Currently, our introspection data looks like this:

         <interface name="org.freedesktop.DBus.Peer">
         <interface name="org.freedesktop.DBus.Introspectable">
         <interface name="org.freedesktop.DBus.Properties">
         <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"/>

(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.

3 years agosd-bus: derive uid from cgroup if possible
David Herrmann [Sat, 5 Sep 2015 15:54:30 +0000 (17:54 +0200)]
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_elogind 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.

3 years agologin: fix NULL-deref on wall_message
David Herrmann [Sat, 5 Sep 2015 10:56:04 +0000 (12:56 +0200)]
login: fix NULL-deref on wall_message

We treat an empty wall-message equal to a NULL wall-message since:

        commit 5744f59a3ee883ef3a78214bd5236157acdc35ba
        Author: Lennart Poettering <>
        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

3 years agologind: when parsing a boolean via sd-bus the type must be "int"
Lennart Poettering [Fri, 4 Sep 2015 08:35:46 +0000 (10:35 +0200)]
logind: when parsing a boolean via sd-bus the type must be "int"

And not bool.

3 years agologind: treat an empty wall message like a NULL one
Lennart Poettering [Fri, 4 Sep 2015 08:34:47 +0000 (10:34 +0200)]
logind: treat an empty wall message like a NULL one

3 years agosd-login: minor header commenting improvements
Lennart Poettering [Fri, 4 Sep 2015 07:57:51 +0000 (09:57 +0200)]
sd-login: minor header commenting improvements

3 years agosd-login: add new sd_pid_get_cgroup() API
Lennart Poettering [Fri, 4 Sep 2015 07:54:14 +0000 (09:54 +0200)]
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.

3 years agosd-login: rework error handling
Lennart Poettering [Fri, 4 Sep 2015 07:05:52 +0000 (09:05 +0200)]
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.

3 years agocgroup: when comparing agent paths, use path_equal()
Lennart Poettering [Thu, 3 Sep 2015 16:27:19 +0000 (18:27 +0200)]
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.

3 years agoaudit: audit calls should return ENODATA when process are not in an audit session
Lennart Poettering [Thu, 3 Sep 2015 16:24:57 +0000 (18:24 +0200)]
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.

3 years agoutil: add new uid_is_valid() call
Lennart Poettering [Thu, 3 Sep 2015 11:29:53 +0000 (13:29 +0200)]
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.

3 years agosd-bus: when connecting to a container, don't fall back to host bus
Lennart Poettering [Tue, 1 Sep 2015 18:38:37 +0000 (20:38 +0200)]
sd-bus: when connecting to a container, don't fall back to host bus

We should never connect to the host bus as fallback if connecting to a
container failed via one method. Otherwise connecting to a dbus1
container will always result in a connection to the host.

3 years agosd-bus: when connecting to a kdbus container bus pass error up
Lennart Poettering [Tue, 1 Sep 2015 18:36:52 +0000 (20:36 +0200)]
sd-bus: when connecting to a kdbus container bus pass error up

We rely on the correct error used when opening the kdbus device node,
hence let's make sure we pass it up from the namespaced child process to
the process which actually wants to connect.

3 years agocgroup: don't allow hidden cgroups
Lennart Poettering [Tue, 1 Sep 2015 15:54:17 +0000 (17:54 +0200)]
cgroup: don't allow hidden cgroups

We really should care for all cgroups, and not allow hidden ones.

3 years agocgroup: never migrate kernel threads out of the root cgroup
Lennart Poettering [Tue, 1 Sep 2015 15:53:14 +0000 (17:53 +0200)]
cgroup: never migrate kernel threads out of the root cgroup

It won't work anyway.

3 years agoset: return NULL on destructors
Lennart Poettering [Tue, 1 Sep 2015 15:13:53 +0000 (17:13 +0200)]
set: return NULL on destructors

Like we do it pretty much everywhere else.

3 years agologind: Listen to WMI hotkeys to catch SW_DOCK state/events
Martin Pitt [Tue, 1 Sep 2015 08:51:15 +0000 (10:51 +0200)]
logind: Listen to WMI hotkeys to catch SW_DOCK state/events

On Dell and HP laptops the dock state/events (SW_DOCK) come from the "{Dell,HP}
WMI hotkeys" input devices. Tag them as power-switch so that login actually
considers them. Use a general match in case this affects other vendors, too.

Thanks to Andreas Schultz for debugging this!

3 years agosd-login: improve error handling
Lennart Poettering [Mon, 31 Aug 2015 22:40:20 +0000 (00:40 +0200)]
sd-login: improve error handling

let's return ENXIO whenever we don't know something rather than ENOENT.

ENOENT suggests this was really about a file or directory, while ENXIO
is a more generic "not found" indicator.

3 years agologin: support user-bus on dbus1
David Herrmann [Mon, 31 Aug 2015 16:07:46 +0000 (18:07 +0200)]
login: support user-bus on dbus1

dbus-1.10 was just released, including systemd units to run
`dbus-daemon --session` as systemd user unit. This allows using a
user-bus with dbus1, just like we do per default with kdbus.

All the dbus libraries have already been fixed long ago to use the
user-bus as default. Hence, there's no need to set
DBUS_SESSION_BUS_ADDRESS= if we use the user-bus. However, gdm and
friends continue to spawn a session bus if this variable is not set
(instead of checking for the existence of the user-bus). Hence, we force
the user-bus, if it is available, in pam_elogind. Once gdm and friends
are fixed, we can continue to drop this again. However, that might take
a while.

With this in place, all that is needed to make the user-bus work is:
    `systemctl --global enable dbus.socket`

If dbus.socket is not enabled, the legacy session-bus is still used.

Based on a patch by: Jan Alexander Steffens <>

3 years agosd-event: improve debug message when we fail to remove and fd from an epoll
Lennart Poettering [Mon, 31 Aug 2015 11:07:24 +0000 (13:07 +0200)]
sd-event: improve debug message when we fail to remove and fd from an epoll

Let's help users to debug issues with epoll fd removal by printing the
name of the event source.

3 years agoextract_first_word: Refactor EXTRACT_DONT_COALESCE_SEPARATORS handling
Filipe Brandenburger [Mon, 31 Aug 2015 02:40:44 +0000 (19:40 -0700)]
extract_first_word: Refactor EXTRACT_DONT_COALESCE_SEPARATORS handling

Refactor allocation of the result string to the top, since it is
currently done in both branches of the condition.

Remove unreachable code checking for EXTRACT_DONT_COALESCE_SEPARATORS
when state == SEPARATOR (the only place where SEPARATOR is assigned to
state follows a check for EXTRACT_DONT_COALESCE_SEPARATORS that jumps to
the end of the function.)

Tested by running test-util successfully.

Follow up to: 206644aedeb8859801051ac170ec562c6a113a79

3 years agoextract_first_word: Refactor allocation in empty argument case
Filipe Brandenburger [Mon, 31 Aug 2015 02:16:50 +0000 (19:16 -0700)]
extract_first_word: Refactor allocation in empty argument case

This covers the case where an argument is an empty string, such as ''.

Instead of allocating the empty string in the individual conditions when
state == VALUE, just always allocate it at the end of state == START, at
which point we know we will have an argument.

Tested that test-util keeps passing after the refactor.

Follow up to: 14e685c29d5b317b815e3e9f056648027852b07e

3 years agopo: update Polish translation
Piotr Drąg [Sat, 29 Aug 2015 18:33:02 +0000 (20:33 +0200)]
po: update Polish translation

3 years agoutil: make malloc0 ask calloc for one block of size n
Thomas Hindoe Paaboel Andersen [Fri, 28 Aug 2015 19:16:39 +0000 (21:16 +0200)]
util: make malloc0 ask calloc for one block of size n

... instead of an array of n individual bytes.

Silences a lot of warnings in smatch.

3 years agoprocess-util: trivial optimization
Lennart Poettering [Fri, 28 Aug 2015 17:29:03 +0000 (19:29 +0200)]
process-util: trivial optimization

3 years agoutil: treat 'C' and 'POSIX' locale identical
Lennart Poettering [Fri, 28 Aug 2015 16:22:14 +0000 (18:22 +0200)]
util: treat 'C' and 'POSIX' locale identical

3 years agopager: set $LESSCHARSET when we output UTF8 chars
Lennart Poettering [Fri, 28 Aug 2015 16:17:14 +0000 (18:17 +0200)]
pager: set $LESSCHARSET when we output UTF8 chars

This way we can be sure that less has the same idea of the terminal as
we do.

This solves issues in systems that have locale uninitalized, where
systemd would output UTF-8 but less wouldn't allow it and show them as
control characters.

3 years agopager: also redirect stderr
Lennart Poettering [Thu, 27 Aug 2015 22:13:34 +0000 (00:13 +0200)]
pager: also redirect stderr

It's really confusing if stdout goes to the pager, but stderr is written
directly to the screen. Hence, make sure both stdout and stderr are
passed to the pager when doing autopaging.

3 years agocgroup-show: unescape cgroups on presentation
Lennart Poettering [Thu, 27 Aug 2015 22:12:38 +0000 (00:12 +0200)]
cgroup-show: unescape cgroups on presentation

Let's unescape cgroups on presentation, so that we show literal unit

3 years agopager: port fallback pager to use copy_bytes()
Lennart Poettering [Thu, 27 Aug 2015 22:11:49 +0000 (00:11 +0200)]
pager: port fallback pager to use copy_bytes()

3 years agosd-bus: it's not a user error to query the error contained in a bus message
Lennart Poettering [Thu, 27 Aug 2015 10:54:35 +0000 (12:54 +0200)]
sd-bus: it's not a user error to query the error contained in a bus message

It's an OK way to check whether a message contains an erro, let's not
consider this a loggable assertion event.

3 years agobasic: document that people shouldn't use refcnt.h without reason
Lennart Poettering [Wed, 26 Aug 2015 19:04:38 +0000 (21:04 +0200)]
basic: document that people shouldn't use refcnt.h without reason

refcnt.h only exists for cases where objects are simultaneously handled
by different threads. Otherwise it should not be used. The only case
where this applies is sd_bus, really, and pretty much none of our APIs,
since we do not claim thread-safety for them.

3 years agoPrep v225: Added needed udev support and re-enabled some masked cgroup functions.
Sven Eden [Wed, 4 Jan 2017 11:55:04 +0000 (12:55 +0100)]
Prep v225: Added needed udev support and re-enabled some masked cgroup functions.

3 years agoPrep v225: Applying various fixes and changes to src/systemd that got lost during...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/systemd that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/shared that got lost during...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/shared that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/login that got lost during git...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/login that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/libelogind/sd-login that got...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/libelogind/sd-login that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/libelogind/sd-event that got...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/libelogind/sd-event that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/libelogind/sd-bus that got lost...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/libelogind/sd-bus that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/cgroups-agent that got lost...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/cgroups-agent that got lost during git am transfer.

3 years agoPrep v225: Applying various fixes and changes to src/basic that got lost during git...
Sven Eden [Wed, 4 Jan 2017 05:40:46 +0000 (06:40 +0100)]
Prep v225: Applying various fixes and changes to src/basic that got lost during git am transfer.

3 years agoPrep v225: Regenerate
Sven Eden [Wed, 4 Jan 2017 05:39:53 +0000 (06:39 +0100)]
Prep v225: Regenerate

3 years agoPrep v225: Remove some orphaned files
Sven Eden [Wed, 4 Jan 2017 05:18:32 +0000 (06:18 +0100)]
Prep v225: Remove some orphaned files

3 years agoPrep v225: Sync build files with upstream
Sven Eden [Tue, 3 Jan 2017 11:52:57 +0000 (12:52 +0100)]
Prep v225: Sync build files with upstream

3 years agobus-util: make more properties settable in --property=
Lennart Poettering [Tue, 25 Aug 2015 16:39:50 +0000 (18:39 +0200)]
bus-util: make more properties settable in --property=

Add a couple of new properties to the supported set we can pass in
systemd-run's and systemd-nspawn's --property= switch.

3 years agosd-bus: don't list activators as proper peers
David Herrmann [Mon, 24 Aug 2015 11:41:03 +0000 (13:41 +0200)]
sd-bus: don't list activators as proper peers

If a connection passed KDBUS_HELLO_ACTIVATOR, it cannot do I/O on the
bus. Hence, we should not treat it as proper peer. To actually query it,
you have to explicitly ask for activators.

This makes kdbus in-line with what dbus-daemon does.

3 years agologind: get a fresh file descriptor to clean up a VT
Owen W. Taylor [Tue, 18 Aug 2015 19:19:05 +0000 (15:19 -0400)]
logind: get a fresh file descriptor to clean up a VT

When the controlling process exits, any existing file descriptors
for that FD will be marked as hung-up and ioctls on them will
file with EIO. To work around this, open a new file descriptor
for the VT we want to clean up.

Thanks to Ray Strode for help in sorting out the problem and
coming up with a fix!

3 years agologind: use open_terminal() instead of open()
Owen W. Taylor [Tue, 18 Aug 2015 18:41:24 +0000 (14:41 -0400)]
logind: use open_terminal() instead of open()

The open_terminal() function adds retries in case a terminal
is in the process of being closed when we open it, and should
generally be used to open a terminal. We especially need it
for code that a subsequent commit adds that reopens the terminal
at session shut-down time; such races would be more likely in
that case.

Found by Ray Strode.

3 years agoBug #944: Replacement of a free() call by mfree()
Markus Elfring [Mon, 17 Aug 2015 07:10:56 +0000 (09:10 +0200)]
Bug #944: Replacement of a free() call by mfree()

The function "mfree" should be called instead of "free" at a specific
source code place.

3 years agologind: actually fail on OOM
Thomas Hindoe Paaboel Andersen [Thu, 13 Aug 2015 21:36:08 +0000 (23:36 +0200)]
logind: actually fail on OOM

Since dacd6cee76a08331b8c8616c5f30f70ee49aa2f9 the two OOM's are
ignored as the value of r will be overwritten and we only log in
the fail section anyway.

This patch jumps to fail on OOM.

Note that this is different behavior compared to both the current
code and previous to dacd6cee76a08331b8c8616c5f30f70ee49aa2f9. Before
that commit we would log that saving the inhibit data failed, but
still write the file, though without the WHO/WHY section.

CID# 1313545

3 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

3 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.

3 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.

3 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

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

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.

3 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.

3 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.

3 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':

  looking at parent device '/devices/platform/gpio_keys/input/input3':

  looking at parent device '/devices/platform/gpio_keys':

  looking at parent device '/devices/platform':

3 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.

3 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.

3 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.

3 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
- Add smack xattr read apis similar with apply apis as

3 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.

3 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]

3 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

3 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]

3 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.

3 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.

3 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
- was regenerated
- and needed a few addtitions and fixes
- Some masked functions had to be unmasked
- Now superfluous files have been removed

3 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.

3 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/ and
- src/core/
have been deleted as they are not needed.

The other changes are some minor fixes.

3 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 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

All unneeded files have been removed.

3 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"

3 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.*

3 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.

3 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.

3 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.

3 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'

3 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.

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

3 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.
* v219.10.

3 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

* Get paths of halt and reboot.
* (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.

3 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.

3 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