Skip Menu |

This queue is for tickets about the Config-IOD-Reader CPAN distribution.

Report information
The Basics
Id: 119861
Status: resolved
Priority: 0/
Queue: Config-IOD-Reader

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.31
Fixed in: (no value)



Subject: Don't trust $ENV{USERNAME}
On Unix systems there are situations where $ENV{USERNAME} has the wrong value. I can reproduce it on my Linux system like this: $ echo $USERNAME eserte $ env | grep USERNAME (nothing) $ sudo su cpansand $ echo $USERNAME cpansand $ env | grep USERNAME USERNAME=root Note that $USERNAME may be available as a shell local variable only. And also note that the values of a shell local variable and an environment variable may not be the same. I think it's better to use again getpwuid() where it's available (Unix systems) and fallback to $ENV{USERNAME} or $ENV{USER} only on other systems (i.e. Windows).
On Sun, 15 Jan 2017 10:33:24 GMT, SREZIC wrote: Show quoted text
> On Unix systems there are situations where $ENV{USERNAME} has the > wrong value. I can reproduce it on my Linux system like this: > > $ echo $USERNAME > eserte > $ env | grep USERNAME > (nothing) > $ sudo su cpansand > $ echo $USERNAME > cpansand > $ env | grep USERNAME > USERNAME=root > > Note that $USERNAME may be available as a shell local variable only. > And also note that the values of a shell local variable and an > environment variable may not be the same. > > I think it's better to use again getpwuid() where it's available (Unix > systems) and fallback to $ENV{USERNAME} or $ENV{USER} only on other > systems (i.e. Windows).
I do want the ability to use USER to override getpwuid(). But indeed the tests are failing because things get different. I'm fixing the tests to avoid the failures. Regards, perlancar