On 9 June 2015 at 16:07, Thijs Schreijer <th...@thijsschreijer.nl> wrote:
> The config files are being read/executed in a sandbox. Hence the failure to 
> access the `os` table.
>
> I do see the usecase for `os.getenv`, but I'm no sandbox expert, so I'm 
> hesitating because I don't know what malicious things one could do with this 
> function exposed.
>
> Anyone else maybe?

Well, it is a readonly function accessing things that come from the
user environment, so I suppose exposing it to the config loader
wouldn't cause surprises.

(This does not apply to the rockspec loader, because it would make
rockspecs too fragile — it's better to have them interact with the
"outside world" through external_dependencies only, which keeps
well-defined boundaries and produces proper error messages.)

We could add getenv support in the next release (as usual, patches are welcome).

In the meantime, Fabio, if you use your $HOME in several machines and
need config to change dynamically according which one you're logged
in, you can keep several config-*.lua files in parallel and set
$LUAROCKS_CONFIG to point to the appropriate config file. Example:

$ hostname
tennant
$ ls ~/.luarocks
config-tennant.lua
config-smith.lua
config-capaldi.lua
$ echo 'export LUAROCKS_CONFIG=$HOME/.luarocks/config-$(hostname).lua'
>> ~/.bashrc

If you have tons of boxes, you could even make your .bashrc generate
the appropriate config file based on a template during login if the
file doesn't already exist.

Hope this helps!

-- Hisham

>> -----Original Message-----
>> From: Fabio Porcedda [mailto:fabio.porce...@gmail.com]
>> Sent: dinsdag 9 juni 2015 6:30
>> To: luarocks-developers@lists.sourceforge.net
>> Subject: [Luarocks-developers] Use an environment variable inside the
>> config-5.1.lua
>>
>> Hi all,
>>
>> I need to use a linux environment variable inside the "config-5.1.lua"
>> to set the "external_deps_dirs", I've used this istruction:
>>
>> external_deps_dirs = { os.getenv("GCC_SYSROOT") }
>>
>> but i got this error:
>>
>> Error running file: [string
>> "/home/tetsuya/buildroot/br/output/host/usr/..."]:15: attempt to index
>> global 'os' (a nil value)
>>
>> If i understand correctly the os library cannot be used in the
>> "config-5.1.lua" file, there is some way to use it?
>>
>> Thanks and best regards
>> --
>> Fabio Porcedda
>>
>> ----------------------------------------------------------------------------
>> --
>> _______________________________________________
>> Luarocks-developers mailing list
>> Luarocks-developers@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/luarocks-developers
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Luarocks-developers mailing list
> Luarocks-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/luarocks-developers

------------------------------------------------------------------------------
_______________________________________________
Luarocks-developers mailing list
Luarocks-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/luarocks-developers

Reply via email to