-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utmp/wtmp support #2745
Add utmp/wtmp support #2745
Conversation
LGTM, thx for getting this back and synced |
I'm waiting on @Nexarian before I merge this - I don't want to disrupt some of the stuff he's looking at. In the meantime I'll fix the conflicts. |
62685b8
to
18c7124
Compare
- renamed the two files, including the header was conflicting with official headers - configure look for utmp/utmpx headers, wo we know which struct to use - reworked the usage for linux, works mostly (last still showing 'gone' for loggued users)
So /proc/<uid>/loginuid will be filled by the uid of the user. This will fix entries in 'last' with "gone - no logout" instead of 'still logged in'
use g_*
Follow coding standard
AC_GNU_SOURCE is replaced with AC_USE_SYSTEM_EXTENSIONS (available from autoconf 2.6.0)
A lot of time has passed, so I'm rebasing it. I'll retest soon and hopefully we can get this merged. |
Yeah, at this point I don't think anything I've worked on will affect this in light of the recent merges! |
This conflicts with struct exit_status in <utmp.h>
If we're not compiling with USE_UTMP, these defines will not be available
The utmp record is generally looked up by the ut_id field. Setting this field means we can use a blank username and host when the session exits
POSIX.1 doesn't define ut_host in struct utmpx. Also, Linux has support for an exit status value in ut_exit. This commit adds conditional code for both ut_host and ut_exit to maximise portability.
g_strncpy() is the wrong function for copying strings in struct utmp[x] as it always terminates strings. strncpy() itself would be a good choice, but is marked by many compilers as being unsafe to use. str2memcpy() is taken from util-linux, and is exactly right for this application.
@metalefty - I've retested this and it still works! Are you happy for me to merge it? |
Let me test. |
A couple of testing notes - these will be added to the release notes under the 'packagers and maintainers' section. Linux
FreeBSDFreeBSD has its UTX database which replaces all of the above files. It is supported via the FreeBSD pam_lastlog module which I think is called normally anyway. In other words, this should already work on FreeBSD without this PR. |
I did a quick test only on Linux. LGTM overall. BTW, the from entry is not updated after reconnecting another client from a different IP address. Isn't it implemented yet?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's merge.
That's a really good point. I've had a look at the pam_lastlog source code. The The PAM session lifetime is that of the user session - i.e. it starts when the user logs a session in and ends when that session finishes. For a reconnect we don't start a new session - we only go through the |
I've added your observation to the |
I thought it might be easiest to discuss this now by way of another PR.
For the history, see #38, #890, #1077 and more recently discussion #2744. There are probably others!
The points I took away from the discussion were:-
I've taken @moobyfr's wtmp branch, rebased it and added a few extra commits. The rebasing was a little challenging as all the code has now moved to sesexec rather than being in sesman. The commits do the following:-
struct exit_status
I added to os_calls and the one in (Linux) utmpx.h--enable-utmp
to configure.ac to allow this feature to be used only where required.On a Ubuntu 22.04 system with this branch, I now have the following when logging on:-
After logging out normally:-
A couple of other points:-
On another note, I'm going to be unavailable for a lot of July, but I've got a bit of time next Monday to work on this.