Bug 376159 - Linux TCF agent get_user_name() implementation is not reliable
Summary: Linux TCF agent get_user_name() implementation is not reliable
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.0.0   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-05 05:52 EDT by Didier Brachet CLA
Modified: 2013-06-05 05:42 EDT (History)
0 users

See Also:


Attachments
Proposed Patch for get_user_name(). (595 bytes, patch)
2012-04-05 05:57 EDT, Didier Brachet CLA
eugene: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Didier Brachet CLA 2012-04-05 05:52:52 EDT
Build Identifier: 

The Linux TCF agent get_user_name() implementation (in agent/tcf/framework/mdep.c) is not reliable since it relies on getlogin() which requires a controlling terminal for the process. If you start the TCF agent from Eclipse to debug it (for example) then getlogin() will return NULL. 

It seems it would be better to use getpwuid(getuid()) to retrieve user name (this code is already used in get_user_home().

Reproducible: Always

Steps to Reproduce:
1.Launch TCF agent from a Eclipse CDT Debug Session
2.Look at the TCF agent peers properties
3.You will see that UserName is not correctly set
Comment 1 Didier Brachet CLA 2012-04-05 05:57:46 EDT
Created attachment 213623 [details]
Proposed Patch for get_user_name().

This is a suggested patch for get_user_name() implementation based on getpwuid().
Comment 2 Eugene Tarassov CLA 2012-04-05 13:54:14 EDT
I have re-arranged the code a little bit: since it now saves result of getlogin() in a static variable, it needs to be strdup()-ed too.

Committed.
Thanks!