bugLibCVS Perl Implementation - Bugs: bug #16702, VCS/LibCVS/Datum/Root.pm should...

 
 

bug #16702: VCS/LibCVS/Datum/Root.pm should use getpwuid($<) instead of getlogin() for the cases where CVSROOT states no username.

Submitter:  None
Submitted:  Tue 30 May 2006 10:21:02 PM UTC
   
 
Category:  Datum Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Release:  None Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 30 May 2006 10:21:02 PM UTC, original submission:  

The attached perl script uses VCS::LibCVS::Datum::Root, and
demonstrates an issue with handling a CVSROOT of the form
"hostname:/repository" without a username, but it is only
an issue if the script is run through an ssh connection.



The issue is mainly a perl issue where getlogin() does not
work through an ssh connection:

> perl -w -e print\ getlogin\(\)\.\"\\\n\"

kurtg

> ssh `hostname` 'perl -w -e print\ getlogin\(\)\.\"\\\n\"'

Use of uninitialized value in concatenation (.) or string at -e line 1.


However, getpwuid($<) does work:

> perl -w -e print\ getpwuid\(\$\<\)\.\"\\\n\"

kurtg

> ssh `hostname` 'perl -w -e print\ getpwuid\(\$\<\)\.\"\\\n\"'

kurtg



Likewise, since Root.pm uses getlogin(), the attached script
works properly when run by itself on the commandline.
"Working properly" means the hostname and username of the
CVSROOT are printed, even if the username is not stated,
i.e. only implied due to the form "hostname:/repository".

% bug_getlogin.pl

However, when run through an ssh connection, the username
is left undefined due to the getlogin() call, and the
script complains about uninitialized items.

% ssh `hostname` bug_getlogin.pl



A release note states:

> 2004-09-21  dissent
>
>   * libcvs-perl/VCS/LibCVS/Client/Connection/CvsPass.pm [1.3]
>   * libcvs-perl/VCS/LibCVS/Datum/Root.pm [1.16]
>
>   Handle a pserver CVSROOT where the username isn't specified.
>   Use the result of getlogin() instead.
>
>   I'm not sure this is the best way to fix this bug.  See
>   issue 65 for further discussion.


It seems that getpwuid($<) should be used instead of getlogin().

According to http://perldoc.perl.org/functions/getlogin.html,
which states that getlogin() can be null, line 77 in the
file "VCS/LibCVS/Datum/Root.pm":

    $that->{UserName} = $3 || getlogin();

should probably be:

    $that->{UserName} = $3 || getlogin() || getpwuid($<);

or perhaps just:

    $that->{UserName} = $3 || getpwuid($<);


This happens again at line 88 with:

    $that->{UserName} = $2 || getlogin();


The 'connect' method of VCS/LibCVS/Client/Connection/Ext.pm
contains some code for dealing with the situation where
the username is not defined, but the IPC::Open2::open2 call
ultimately fails anyway for such a case.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #10086:  bug_getlogin.pl added by None (308B - application/octet-stream - Script for demonstating the getlogin issue in Datum/Root.pm)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follows 1 latest change.

Date Changed by Updated Field Previous Value => Replaced by
2006-05-30 None Attached File- Added bug_getlogin.pl, #10086

Back to the top

Powered by Savane 3.13-cf05.
Corresponding source code