[Mono-bugs] [Bug 56144][Nor] New - Environment.UserName must represent the username (not the %USERNAME% variable)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 28 Mar 2004 23:06:13 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=56144

--- shadow/56144	2004-03-28 23:06:13.000000000 -0500
+++ shadow/56144.tmp.21063	2004-03-28 23:06:13.000000000 -0500
@@ -0,0 +1,91 @@
+Bug#: 56144
+Product: Mono: Runtime
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Environment.UserName must represent the username (not the %USERNAME% variable)
+
+Description of Problem:
+
+We are trusting the environment variables to get the username and userdomain.
+
+
+Steps to reproduce the problem:
+(1) Running on MS runtime
+
+> envun
+        GetEnvironmentVariable(%USERNAME%)      toto
+        Environment.UserName                    spouliot
+        GetEnvironmentVariable(%USERDOMAIN%)    FARSCAPE
+        Environment.UserDomainName              FARSCAPE
+
+
+(2) Running on Mono
+
+> mono envun.exe
+        GetEnvironmentVariable(%USERNAME%)      toto
+        Environment.UserName                    toto
+        GetEnvironmentVariable(%USERDOMAIN%)    FARSCAPE
+        Environment.UserDomainName              FARSCAPE
+
+
+(3) We change the environement variables
+
+> set USERNAME=mono
+> set USERDOMAIN=go
+
+
+(4) Running on MS runtime
+
+> envun
+        GetEnvironmentVariable(%USERNAME%)      toto
+        Environment.UserName                    spouliot
+        GetEnvironmentVariable(%USERDOMAIN%)    go
+        Environment.UserDomainName              FARSCAPE
+
+
+(2) Running on Mono
+
+> mono envun.exe
+        GetEnvironmentVariable(%USERNAME%)      toto
+        Environment.UserName                    toto
+        GetEnvironmentVariable(%USERDOMAIN%)    go
+        Environment.UserDomainName              FARSCAPE
+
+Actual Results:
+
+We can change the username by changing the USERNAME or USER variable.
+        Environment.UserName                    toto
+
+
+Expected Results:
+
+The UserName property should always return the current user name.
+        Environment.UserName                    spouliot
+
+
+How often does this happen? 
+
+Always
+
+
+Additional Information:
+
+- Actually the bug is in the class library (right now) but it's solution is
+to move the code into the runtime (like other properties) as it can be
+different for each OS.
+
+- Microsoft documentation states that Environment.UserName can be used to
+identify the user for security or access purpose. We cannot rely on
+environment variables for this.