Skip to content

Y2038: use logind instead of utmp#541

Merged
thkukuk merged 1 commit intolinux-pam:masterfrom
thkukuk:logind
Feb 28, 2023
Merged

Y2038: use logind instead of utmp#541
thkukuk merged 1 commit intolinux-pam:masterfrom
thkukuk:logind

Conversation

@thkukuk
Copy link
Contributor

@thkukuk thkukuk commented Feb 22, 2023

The struct utmp from glibc uses on many 64bit architectures a 32bit time_t for compatibility with a 32bit userland, which means utmp will not survive the year 2038 (32bit time_t overflow). Use the data from logind instead of utmp.

  • configure.ac: Add option --enable-logind
  • modules/pam_issue/Makefile.am: Add CFLAGS/LIBS for logind support
  • modules/pam_issue/pam_issue.c: Use sd_get_sessions instead of utmp
  • modules/pam_timestamp/Makefile.am: Add CFLAGS/LIBS for logind support
  • modules/pam_timestamp/pam_timestamp.c: query logind for login time

@thkukuk
Copy link
Contributor Author

thkukuk commented Feb 22, 2023

The PR isn't ready yet as there is an open discussion: add two missing functions to systemd/sd-login.h or write a library which uses the DBUS interface to get the missing informations from logind. But it shows already how this could be done.

@ldv-alt @t8m what do you think about this idea to query logind instead of parsing utmp to solve Y2038 problem?

@ldv-alt
Copy link
Member

ldv-alt commented Feb 23, 2023

Makes sense. FWiW, I'm for adding these two functions to libsystemd.

@thkukuk thkukuk force-pushed the logind branch 2 times, most recently from 46e27f7 to 82fea58 Compare February 25, 2023 22:06
@thkukuk thkukuk marked this pull request as ready for review February 25, 2023 22:06
@thkukuk thkukuk requested a review from ldv-alt February 26, 2023 12:16
@thkukuk
Copy link
Contributor Author

thkukuk commented Feb 26, 2023

All necessary PRs for systemd are accepted, this PR builds and works with current systemd from git.

@ldv-alt
Copy link
Member

ldv-alt commented Feb 26, 2023

The systemd from git currently claims that it's version is 253, while the configure check expects libsystemd >= 254,
so in its current form the logind support won't be activated until systemd 254-rc1 is out.

@thkukuk
Copy link
Contributor Author

thkukuk commented Feb 26, 2023

The systemd from git currently claims that it's version is 253, while the configure check expects libsystemd >= 254, so in its current form the logind support won't be activated until systemd 254-rc1 is out.

I think that's acceptable. If we require only 253, we would need additional checks to find out if that is an official 253 without the functions or an "inofficial" build from git with the functions for about 3-5 month. If somebody wants to use that already today, he can backport the functions and change the Linux-PAM configure check or use current git and change that version to 254 already (I personally would go the first option).

@thkukuk thkukuk changed the title WIP: Y2038: use logind instead of utmp Y2038: use logind instead of utmp Feb 26, 2023
The struct utmp from glibc uses on many 64bit architectures a 32bit
time_t for compatibility with a 32bit userland, which means utmp will
not survive the year 2038 (32bit time_t overflow). Use the data from
logind instead of utmp.

* configure.ac: Add option --enable-logind
* modules/pam_issue/Makefile.am: Add CFLAGS/LIBS for logind support
* modules/pam_issue/pam_issue.c: Use sd_get_sessions instead of utmp
* modules/pam_timestamp/Makefile.am: Add CFLAGS/LIBS for logind support
* modules/pam_timestamp/pam_timestamp.c: query logind for login time
@thkukuk thkukuk merged commit 8a3f081 into linux-pam:master Feb 28, 2023
@thkukuk thkukuk deleted the logind branch February 28, 2023 06:03
@kilobyte
Copy link

kilobyte commented Mar 9, 2023

This breaks any scenarios where you have a mix of systemd and non-systemd: 1. distributions that support multiple init systems, 2. running code compiled against libsystemd in an init-less container.

@kilobyte
Copy link

kilobyte commented Mar 9, 2023

Instead of #ifdef .. #else, the code should try systemd if running, and if that fails, fall back to utmp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants