Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with result from getlogin() after kdm login [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
trent
n00b
n00b


Joined: 27 Jul 2007
Posts: 7

PostPosted: Mon Dec 26, 2011 8:09 pm    Post subject: Problem with result from getlogin() after kdm login [solved] Reply with quote

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:


Last edited by trent on Sun Oct 21, 2012 10:25 am; edited 1 time in total
Back to top
View user's profile Send private message
stratsci
n00b
n00b


Joined: 11 Jan 2012
Posts: 2
Location: Earth

PostPosted: Wed Jan 11, 2012 1:06 am    Post subject: Reply with quote

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
View user's profile Send private message
trent
n00b
n00b


Joined: 27 Jul 2007
Posts: 7

PostPosted: Sun Oct 21, 2012 10:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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