Commit graph

50 commits

Author SHA1 Message Date
Kay Sievers dfb0c6cc3b pam_systemd: rename source file to match the module 2014-06-21 15:44:14 +02:00
Zbigniew Jędrzejewski-Szmek de0671ee7f Remove unnecessary casts in printfs
No functional change expected :)
2014-05-15 15:29:58 +02:00
Lennart Poettering 85c08dc013 pam_systemd: use F_DUPFD_CLOEXEC when dupping session fds
http://lists.freedesktop.org/archives/systemd-devel/2014-May/019034.html
2014-05-13 16:35:34 +02:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Michal Sekletar 3831838ae7 pam: use correct log level 2014-02-10 16:38:28 +01:00
Zbigniew Jędrzejewski-Szmek cda7ecb0a3 pam-module: avoid (null) in debug message 2014-02-08 13:07:39 -05:00
Lennart Poettering 5f41d1f10f logind: rework session shutdown logic
Simplify the shutdown logic a bit:

- Keep the session FIFO around in the PAM module, even after the session
  shutdown hook has been finished. This allows logind to track precisely
  when the PAM handler goes away.

- In the ReleaseSession() call start a timer, that will stop terminate
  the session when elapsed.

- Never fiddle with the KillMode of scopes to configure whether user
  processes should be killed or not. Instead, simply leave the scope
  units around when we terminate a session whose processes should not be
  killed.

- When killing is enabled, stop the session scope on FIFO EOF or after
  the ReleaseSession() timeout. When killing is disabled, simply tell
  PID 1 to abandon the scope.

Because the scopes stay around and hence all processes are always member
of a scope, the system shutdown logic should be more robust, as the
scopes can be shutdown as part of the usual shutdown logic.
2014-02-07 15:14:36 +01:00
Lennart Poettering a4cd87e9dc man: introduce new "Desktop" property for sessions
This is initialized from XDG_SESSION_DESKTOP and is useful for GNOME
to recognize its own sessions. It's supposed to be set to a short string
identifying the session, such as "kde" or "gnome".
2014-02-05 20:44:49 +01:00
Lennart Poettering 49ebd11fb0 logind: make session type and class settable via the same ways
If the session type/class is set via environment variables, use that,
and otherwise fallback to something that is set via the PAM module
command line.
2014-02-05 18:55:18 +01:00
Matthew Monaco d7353ef609 pam_systemd: Ignore vtnr when seat != seat0
logind considers it an error for a seat other than seat0 to have a
non-zero vtnr for CreateSession
2014-01-26 12:25:21 -05:00
Kay Sievers 8042e377b8 pam: skip DBUS_SESSION_BUS_ADDRESS export when kdbus is not active 2014-01-12 01:45:42 +08:00
Kay Sievers 5eecd85f15 Revert "bus: export bus address also when compiled without kdbus"
This reverts commit 9130f2128b.

It's too early to do that. For now we should only "break" the
--enable-kdbus case, not the normal one.
2014-01-11 06:22:19 +08:00
Mantas Mikulėnas 9130f2128b bus: export bus address also when compiled without kdbus
It was removed from user@.service, so it should be added here.
2014-01-08 21:46:38 +08:00
Mantas Mikulėnas 06150d9039 bus: use existing macros from def.h 2014-01-08 21:41:53 +08:00
Kay Sievers 8b255ecd99 pam_systemd: export DBUS_SESSION_BUS_ADDRESS 2014-01-08 18:11:37 +08:00
Lennart Poettering eff0527098 util: unify SO_PEERCRED/SO_PEERSEC invocations
Introduce new call getpeercred() which internally just uses SO_PEERCRED
but checks if the returned data is actually useful due to namespace
quirks.
2013-12-24 15:53:04 +01:00
David Herrmann 92bd5ff3a0 logind: make VT numbers unsigned
Fix the whole code to use "unsigned int" for vtnr. 0 is an invalid vtnr so
we don't need negative numbers at all.

Note that most code already assumes it's unsigned so in case there's a
negative vtnr, our code may, under special circumstances, silently break.
So this patch makes sure all sources of vtnrs verify the validity. Also
note that the dbus api already uses unsigned ints.
2013-11-28 17:38:16 +01:00
Lennart Poettering baae0358f3 pam_systemd: do not set XDG_RUNTIME_DIR if the session's original user is not the same as the newly logged in one
It's better not to set any XDG_RUNTIME_DIR at all rather than one of a
different user. So let's do this.

This changes the bus call parameters of CreateSession(), but that is
explicitly an internal API hence should be fine. Note however, that a
logind restart (the way the RPM postinst scriptlets do it) is necessary
to make things work again.
2013-11-26 05:05:00 +01:00
Thomas Hindoe Paaboel Andersen d5d217eae1 remove unused variables 2013-11-18 23:04:16 +01:00
Lennart Poettering 8159d91a9c bus: port remaining code over to use bus_error_message() 2013-11-08 19:49:49 +01:00
Lennart Poettering 29d230f6f2 pam: the DECIMAL_STR_MAX macro is awesome, let's use it 2013-11-07 16:53:25 +01:00
Zbigniew Jędrzejewski-Szmek 5a330cda0c pam_systemd: dup the fd received from logind
Otherwise sd_bus_message cleanup would close it.
2013-11-06 19:50:18 -05:00
Lennart Poettering d1529c9ea0 pam: externally our booleans are ints, not unsigneds 2013-11-07 00:20:11 +01:00
Lennart Poettering 4d49b48c60 socket: rework things to have only one sockaddr formatter 2013-11-07 00:13:58 +01:00
Kay Sievers 5a0d49a47c pam_systemd: pass 'unsigned' instead of 'bool' to sd_bus_message_read() 2013-11-07 00:05:03 +01:00
Zbigniew Jędrzejewski-Szmek ffcfcb6b2c pam_systemd: port to libsystemd-bus 2013-11-06 14:56:47 -05:00
Zbigniew Jędrzejewski-Szmek 05a049cc44 systemd_pam: treat debug as debug=1 and parse all params
systemd_pam would ignore all params after the first invalid one.
Instead ignore just this one, and parse the rest. There's just
one now, but as a matter of principle ;)

Also, allow debug as an alias for debug=1, and don't treat
invalid debug= options as fatal.
2013-11-06 14:56:47 -05:00
Lennart Poettering cc37738108 logind: port logind to libsystemd-bus 2013-11-05 01:13:05 +01:00
Zbigniew Jędrzejewski-Szmek 970edce6ef execute: more debugging messages 2013-10-03 22:12:32 -04:00
Zbigniew Jędrzejewski-Szmek 5c390a4ae0 Add pam configuration to allow user sessions to work out of the box
systemd-logind will start user@.service. user@.service unit uses
PAM with service name 'systemd-user' to perform account and session
managment tasks. Previously, the name was 'systemd-shared', it is
now changed to 'systemd-user'.

Most PAM installations use one common setup for different callers.
Based on a quick poll, distributions fall into two camps: those that
have system-auth (Redhat, Fedora, CentOS, Arch, Gentoo, Mageia,
Mandriva), and those that have common-auth (Debian, Ubuntu, OpenSUSE).
Distributions that have system-auth have just one configuration file
that contains auth, password, account, and session blocks, and
distributions that have common-auth also have common-session,
common-password, and common-account. It is thus impossible to use one
configuration file which would work for everybody. systemd-user now
refers to system-auth, because it seems that the approach with one
file is more popular and also easier, so let's follow that.
2013-09-11 15:35:06 -04:00
Lennart Poettering fb6becb443 logind: port over to use scopes+slices for all cgroup stuff
In order to prepare things for the single-writer cgroup scheme, let's
make logind use systemd's own primitives for cgroup management.

Every login user now gets his own private slice unit, in which his sessions
live in a scope unit each. Also, add user@$UID.service to the same
slice, and implicitly start it on first login.
2013-07-02 01:48:55 +02:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Lennart Poettering e2acb67baa logind: introduce an explicit session class for cronjobs and similar
cronjobs are neither interactive user session, nor lock screens, nor
login screens, hence they should get their own class.
2013-04-09 22:18:16 +02:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first
by filling the structure with zeros, and then a second
time with the real values. We can let the compiler do
the job for us, avoiding one copy.

A downside of this patch is that text gets slightly
bigger. This is because all zero() calls are effectively
inlined:

$ size build/.libs/systemd
         text    data     bss     dec     hex filename
before 897737  107300    2560 1007597   f5fed build/.libs/systemd
after  897873  107300    2560 1007733   f6075 build/.libs/systemd

… actually less than 1‰.

A few asserts that the parameter is not null had to be removed. I
don't think this changes much, because first, it is quite unlikely
for the assert to fail, and second, an immediate SEGV is almost as
good as an assert.
2013-04-05 19:50:57 -04:00
Martin Pitt 79d860fe78 PAM, uaccess: check for logind, not for systemd
It is possible to build systemd without logind or run logind without systemd
init. Commit 66e41181 fixed sd_booted() to only succeed for systemd init; with
that, testing for systemd init is wrong in the parts that talk to logind.

In particular, this affects the PAM module and the "uaccess" udev builtin.
Change sd_booted() to a new logind_running() which tests for
/run/systemd/seats/.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>

https://bugs.freedesktop.org/show_bug.cgi?id=62754
2013-04-05 18:16:58 +02:00
Harald Hoyer a5c32cff1f honor SELinux labels, when creating and writing config files
Also split out some fileio functions to fileio.c and provide a SELinux
aware pendant in fileio-label.c

see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-14 16:19:38 +01:00
Matthew Monaco 485507b8c0 pam_systemd: new option for the session class 2012-12-24 19:17:48 +01:00
Lennart Poettering 0ad1271f56 pam: properly handle SSH logins lacking the PAM tty field 2012-12-24 00:29:39 +01:00
Lennart Poettering 7708588119 logind: only release logind session from the PAM module if the same module instance actually created it 2012-10-16 19:21:21 +02:00
Lennart Poettering a8573ccc35 pam: check environ[] for XDG_SEAT as fallback
This is useful for systems such as kmscon which want to invoke classic
/sbin/login but use it on multiple seats.
2012-10-01 14:50:05 -04:00
Lennart Poettering 8e7705e52a pam: document that we don't do error checking when parsing vtnr 2012-09-21 16:17:26 +02:00
Colin Guthrie f904bdf2e9 pam: Add session class to the debug log. 2012-09-12 08:19:23 +02:00
Lennart Poettering 5430f7f2bc relicense to LGPLv2.1 (with exceptions)
We finally got the OK from all contributors with non-trivial commits to
relicense systemd from GPL2+ to LGPL2.1+.

Some udev bits continue to be GPL2+ for now, but we are looking into
relicensing them too, to allow free copy/paste of all code within
systemd.

The bits that used to be MIT continue to be MIT.

The big benefit of the relicensing is that closed source code may now
link against libsystemd-login.so and friends.
2012-04-12 00:24:39 +02:00
Kay Sievers d7832d2c6e util: move all to shared/ and split external dependencies in separate internal libraries
Before:
  $ ldd /lib/systemd/systemd-timestamp
  linux-vdso.so.1 =>  (0x00007fffb05ff000)
  libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f90aac57000)
  libcap.so.2 => /lib64/libcap.so.2 (0x00007f90aaa53000)
  librt.so.1 => /lib64/librt.so.1 (0x00007f90aa84a000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f90aa494000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f90aae90000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007f90aa290000)
  libattr.so.1 => /lib64/libattr.so.1 (0x00007f90aa08a000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f90a9e6e000)

After:
  $ ldd systemd-timestamp
  linux-vdso.so.1 =>  (0x00007fff3cbff000)
  libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5eaa1c3000)
  librt.so.1 => /lib64/librt.so.1 (0x00007f5ea9fbb000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f5ea9c04000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f5eaa3fc000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007f5ea9a00000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5ea97e4000)
2012-04-10 14:13:38 +02:00
Lennart Poettering 75c8e3cffd logind: close FIFO before ending sessions cleanly
For clean session endings ask logind explicitly to get rid of the FIFO
before closing it so that the FIFO logic doesn't result in su/sudo to be
terminated immediately.
2012-03-22 02:06:40 +01:00
Lennart Poettering 55efac6cbc login: track login class (i.e. one of "user", "greeter", "lock-screen") for each session
This introduces the new PAM environment variable XDG_SESSION_CLASS. If
not set, defaults to "user".

This is useful for apps that want to distuingish real user logins from
"fake" ones which just exist to show a gdm login screen or a lock
screen.
2012-02-14 21:37:49 +01:00
Lennart Poettering 6ef25fb65e pam: fix build 2012-01-13 20:52:45 +01:00
Lennart Poettering fc7985ed67 pam: work correctly if a seat is specified but not vtnr 2012-01-13 20:51:58 +01:00
Lennart Poettering 81527be142 build-sys: move public header files into a dir of their own 2012-01-05 16:01:58 +01:00
Lennart Poettering be5f4385d6 login: move the PAM module to src/login/ since it is just a client to logind 2011-12-31 18:06:56 +01:00
Renamed from src/pam-module.c (Browse further)