View previous topic :: View next topic |
Author |
Message |
trent n00b
Joined: 27 Jul 2007 Posts: 7
|
Posted: Mon Dec 26, 2011 8:09 pm Post subject: Problem with result from getlogin() after kdm login [solved] |
|
|
When doing a login with kdm or gdm, calling getlogin() (from unistd.h) in a simple c-program (see below) returns "nobody" (which is the username set by start-stop-daemon when starting kdm from init.d). I'd actually expect it to return my current username I used when logging in. On the other hand, when I use xdm as the login-manager for xorg, getlogin() will return the expected result (which is "trent").
Problem arise when running commands with "at" inside kde. at will use getlogin() to infer the username it uses to send the mail containing standard output and error. Hence currently it only sends mails to nobody instead of the actual user.
Does anybody have a solution how to tell kdm to adjust to the "current" user after a successful login or how to have at send to the actual user, not the one returned by getlogin()? I'm also interested in your opinion whether you think this is a bug in at or kdm/gdm?
Also, what exactly (besides what the man page tells me) is getlogin() supposed to return in contrast to e.g. getpwuid->pw_name?
Some more info:
Code: |
#include <stdio.h>
#include <unistd.h>
void main() {
char *str = getlogin();
printf("getlogin() -> %s\n", str);
}
|
Last edited by trent on Sun Oct 21, 2012 10:25 am; edited 1 time in total |
|
Back to top |
|
|
stratsci n00b
Joined: 11 Jan 2012 Posts: 2 Location: Earth
|
Posted: Wed Jan 11, 2012 1:06 am Post subject: |
|
|
I was having similar problems and found a workaround.
Assuming you have everything built with the pam USE flag turned on, try adding this line to /etc/pam.d/gdm and (I think) /etc/pam.d/kde:
session optional pam_loginuid.so
You will want to add the line to /etc/pam.d/atd as well, since otherwise getlogin() will return "nobody" from within an at-job.
/etc/pam.d/xdm already uses pam_loginuid via system-local-login, which is why getlogin() works properly with xdm.
I don't know exactly what recent software upgrade caused the problem, but a clue to what is going on can be found in the contents of /proc/self/loginuid. |
|
Back to top |
|
|
trent n00b
Joined: 27 Jul 2007 Posts: 7
|
Posted: Sun Oct 21, 2012 10:24 am Post subject: |
|
|
Oh, hey; I didn't see this answer, stumbled upon it by coincidence.
Thanks for the hint, it's working now. This is probably not only a workaround but the intended way how this is supposed to work.
Would be nice to have this setting as a default for kdm and atd pam-configuration. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|