-
-
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
Wtmp #1077
Conversation
I'll rebase the wtmp branch to current devel head after March release. |
can you squash some commits? |
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.
- what about other pam files like archlinux pam file ?
@@ -5,6 +5,7 @@ AC_INIT([xrdp], [0.9.6], [[email protected]]) | |||
AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in) | |||
AM_INIT_AUTOMAKE([1.7.2 foreign]) | |||
AC_CONFIG_MACRO_DIR([m4]) | |||
AC_GNU_SOURCE |
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.
Why this is needed?
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.
Needed to get UTMPX_FILE
and other variables on linux, because of __USE_GNU
in utmpx.h
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.
ok
@@ -61,6 +61,8 @@ xrdp_sesman_SOURCES = \ | |||
sesman.h \ | |||
session.c \ | |||
session.h \ | |||
sessionrecord.c \ |
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.
I don't like the name sessionrecord.c
, its misleading.
one might think of graphical session recording.
can you think of a better name? maybe logontrack.c
or just utmp.c
?
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.
First work used utmp.c
and utmp.h
but the #include directive was not able to get utmp.h
from the sources and from /usr/include
(with <> or "")
sesman/sessionrecord.c
Outdated
* this can handle login and logout at once with the 'state' parameter | ||
*/ | ||
|
||
int |
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.
make it static
sesman/sessionrecord.h
Outdated
|
||
#define XRDP_LINE_FORMAT "xrdp:%d" | ||
|
||
int add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state); |
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.
why you export this function?
I dont see its used outside of sessionrecord.c
.
sesman/sessionrecord.h
Outdated
typedef struct utmp _utmp; | ||
#endif | ||
|
||
#define XRDP_LINE_FORMAT "xrdp:%d" |
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.
put it in the .c file, its used only there.
sesman/sessionrecord.c
Outdated
*/ | ||
|
||
int | ||
add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state) |
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.
you never pass state
argument when calling this function.
also, its unused here.
consider removing it.
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.
They are used in utmp_login
and utmp_logout
, state
is set to USER_PROCESS
or DEAD_PROCESS
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.
oh, right. my fault.
so just make it const short state
sesman/sessionrecord.c
Outdated
g_strncpy(ut.ut_host, hostname, sizeof(ut.ut_host)); | ||
|
||
/* utmp */ | ||
setutxent(); |
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.
can you add a comment explaining those calls ?
sesman/sessionrecord.c
Outdated
|
||
ut.ut_type=state; | ||
ut.ut_pid = pid; | ||
gettimeofday(&tv, NULL); |
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.
can we use g_time1
, g_time2
or g_time3
from os_calls.c
?
otherwise, consider adding another wrapper there (or add support to the current wrappers)
sesman/sessionrecord.c
Outdated
endutxent(); | ||
|
||
/* wtmp : update on linux, FreeBSD uses utx */ | ||
#ifdef HAVE_UTMPX_H |
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.
i prefer to avoid ifdef
s inside the function body.
lets add some wrapper to this call outside the function and call it here.
for example:
#if defined(__FreeBSD__)
static inline void
updwtmp(...)
{
...
}
#elif defined(HAVE_UTMP_H)
static inline void
updwtmp(...)
{
...
}
#endif
sesman/sessionrecord.c
Outdated
* this can handle login and logout at once with the 'state' parameter | ||
*/ | ||
|
||
int |
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.
either add error checks and return error in such cases or make this function return void
sesman/sessionrecord.c
Outdated
|
||
g_memset(&ut, 0, sizeof(ut)); | ||
|
||
ut.ut_type=state; |
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.
space between operators (=
)
sesman/sessionrecord.c
Outdated
* So the IP is the string up the two last colons | ||
*/ | ||
int i = g_strlen(rhostname) - 1; | ||
while ((i>0) && (rhostname[i] != ':')) |
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.
This logic is very specific to the way the given string is built right now.
The string might be changed at the future.
I'm not sure what is the best way to get the IP, but maybe we can fetch it from other, more reliable, source?
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.
Yes, this is very ad-hoc workaround right now and not the best.
I've made the changes requested (minus the gettimeofday and the pam file because he doesn't exist in this branch), but I'm unable to push it in the current branch. the change can be chery-picked on moobyfr@9b915fc |
I'll cherry-pick. |
and squash some commits. |
Regarding the arch pam file, system-login already contains pam_loginuid.so (system-remote-login includes system-login). But it is added as optional not as required, will this cause issues? |
- 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
This branch now looks to be good to go? I'm interested in when it is likely to be merged as my organisation needs the wtmp changes before we can onboard xrdp in to production. We have been using a patch from this branch for testing and the results have been good. |
What is the status of this Pull request? |
I see JonesB has copied this PR and added the missing reconnect functionality. The new PR can be found here: #1408. Is it possible to get this reviewed? |
Can we get this accepted please. |
This should be redone after #1961. There's very few chance to get merged with current authentication architecture. |
Anyone following this may find this comment useful, particularly on Red Hat and derivatives. |
Can anyone following this thread please comment on #2745? |
Add the utmp/wtmp support.