Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credentials with "-" break unuseable with FromEnvironment #8

Open
thekid opened this issue Aug 13, 2018 · 2 comments
Open

Credentials with "-" break unuseable with FromEnvironment #8

thekid opened this issue Aug 13, 2018 · 2 comments

Comments

@thekid
Copy link
Member

thekid commented Aug 13, 2018

Works fine on Windows:

C:\Users\friebe>set LDAP-PASS=foo
C:\Users\friebe>echo %LDAP-PASS%
foo

...but not on Un*x sytems:

$ export LDAP-PASS=foo
-bash: export: `LDAP-PASS=foo': not a valid identifier
@thekid
Copy link
Member Author

thekid commented Aug 13, 2018

@thekid
Copy link
Member Author

thekid commented Aug 13, 2018

On Cygwin, using env will work:

$ env LDAP-PASS=wurst xp -d '$_ENV["LDAP-PASS"]'
string(5) "wurst"

Unfortunately, on Linux, it won't:

# It works until here
root@ba274f210d69:/app# env LDAP-PASS=wurst php -r 'var_dump($_ENV["LDAP-PASS"]);'
string(5) "wurst"

# ...but stops here:
root@ba274f210d69:/app# env LDAP-PASS=wurst xp -d '$_ENV["LDAP-PASS"]'
Uncaught exception: Exception lang.IndexOutOfBoundsException (Undefined index: LDAP-PASS)

Seems like a bug in Mono at first, but this works like a charm:

root@ba274f210d69:/app# cat > getenv.cs
using System;

public class getenv
{
    public static int Main(string[] args)
    {
        Console.WriteLine("$ENV[{0}]= {1}", args[0], Environment.GetEnvironmentVariable(args[0]));
        return 0;
    }
}
root@ba274f210d69:/app# mcs getenv.cs
root@ba274f210d69:/app# env LDAP-PASS=wurst mono getenv.exe LDAP-PASS
$ENV[LDAP-PASS]= wurst

Actually is a bug in the shell wrapper!

root@ba274f210d69:/app# sh /usr/bin/xp -d 'ksort($_ENV); return $_ENV' > sh
root@ba274f210d69:/app# mono /usr/bin/xp.exe -d 'ksort($_ENV); return $_ENV' > mono
root@ba274f210d69:/app# diff -u mono sh
--- mono        2018-08-13 23:18:18.809871136 +0000
+++ sh  2018-08-13 23:18:07.245675225 +0000
@@ -1,12 +1,10 @@
-array(23) {
+array(22) {
   ["GPG_KEYS"]=>
   string(81) "1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F"
   ["HOME"]=>
   string(5) "/root"
   ["HOSTNAME"]=>
   string(12) "ba274f210d69"
-  ["LDAP-PASS"]=>
-  string(5) "wurst"
   ["PATH"]=>
   string(60) "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   ["PHPIZE_DEPS"]=>
@@ -44,5 +42,5 @@
   ["XP_VERSION"]=>
   string(9) "8.1.3.420"
   ["_"]=>
-  string(13) "/usr/bin/mono"
+  string(7) "/bin/sh"
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant