LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-20-2016, 10:24 AM   #1
amjones
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Rep: Reputation: Disabled
Perl getlogin returns "root"


I've been using the standard Perl code below for literally 20 years and it has always return the expected value:

my $login = getlogin || (getpwuid($<))[0] || "Intruder!!"; # from "getlogin" in Camel book

Here at my work we have recently moved to RHEL 6.5 and the code above is now returning "root". (getpwuid($<))[0] returns my actual login ID.

In addition, this seems to only happen on LSF jobs:

% bsub -R ws60 -I -q gui perl -w -e 'print getlogin . "\n"'
Job <990152> is submitted to queue <gui>.
<<Waiting for dispatch ...>>
<<Starting on ......>>
root
% perl -w -e 'print getlogin . "\n"'
ajones

Any suggestions?
 
Old 09-20-2016, 11:04 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
What do you expect for the returned value?
Quote:
Here at my work we have recently moved to RHEL 6.5 and the code above is now returning "root". (getpwuid($<))[0] returns my actual login ID.
It's unclear if the returning value is root or your login ID
 
Old 09-20-2016, 11:25 AM   #3
amjones
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
I expect getlogin to return "ajones". It always has in the past, and still does on most machines.
 
Old 09-20-2016, 12:03 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
I don't know LSF, from quick googlin I see that LSF_ROOT_REX=local parameter might be set on /etc/lsf.conf
http://www-01.ibm.com/support/docvie...d=isg3T1013604
 
Old 09-20-2016, 12:35 PM   #5
amjones
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks, I checked that setting and it is not set.
 
Old 09-22-2016, 06:52 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Is it a local login, or based on LDAP?
 
Old 09-23-2016, 10:33 AM   #7
amjones
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
local
 
Old 09-23-2016, 10:58 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Is it possible you went to the user via "su - username"?

I say this as getlogin is the wrapper around the C runime getlogin function that returns the user name attached to the controlling terminal via the utmp record... which does not have to be the username of the current process, which you would get by using the getpwent using the current uid.

It is also possible, the utmp record is corrupted...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gigabyte U7300 "edit Makefile" command returns "error" drobin Linux - Newbie 8 09-04-2013 04:20 AM
[SOLVED] "Insert" & "Delete" key returns "~" in a terminal. sharky Linux - General 15 04-26-2011 08:36 AM
"nc -v somehost.example.com 22" returns "nc: getaddrinfo: Name or service not known" kenneho Linux - Newbie 2 11-25-2010 01:58 AM
Command "mail" returns "panic: temporary file seek" kenneho Linux - Software 5 12-23-2008 03:27 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration