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.

Submitted by:  None
Submitted on:  Tue 30 May 2006 10:21:02 PM UTC  
 
Category: DatumPriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Release: NoneFixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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 File(s):
   
   
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

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follows 1 latest change.

Date Changed By Updated Field Previous Value => Replaced By
Tue 30 May 2006 10:21:02 PM UTCNoneAttached File-=>Added bug_getlogin.pl, #10086

Back to the top


Powered by Savane 3.1-cleanup1