guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: modprobe on guix


From: Petter
Subject: Re: modprobe on guix
Date: Sun, 20 Sep 2015 20:55:42 +0200

I've investigated a bit and have some light to shed on this issue.

First, I've tested printing the value of LINUX_MODULE_DIRECTORY as
suggested previously in this thread, and found it not to be a good test.

$ sudo bash -c "echo $LINUX_MODULE_DIRECTORY"
> /run/booted-system/kernel/lib/modules,
which shows indeed the expected output, but for the wrong reason.

This would be the shell doing the variable expansion while still in the
user's environment. Which makes it in effect similar to:
$ sudo bash -c "echo /run/booted-system/kernel/lib/modules"

Overwriting the variable in the user environment demonstrates this.
$ LINUX_MODULE_DIRECTORY=hello
$ sudo bash -c "echo $LINUX_MODULE_DIRECTORY"
> hello

Testing single quotes instead, which should leave the variable
unexpanded by the first shell.
$ sudo bash -c "echo $USER"
> petter
$ sudo bash -c 'echo $USER'
> root

And so this would be a better test.
$ sudo bash -c 'echo $LINUX_MODULE_DIRECTORY'
>
(empty value.)

As best i can find out  sudo  doesn't source any of the relevant shell
files, like /etc/profile; and so the root environment isn't set up like
if you logged in as root. And variables from the user environment isn't
passed on to it either. Besides using  sudo -E  , which passes on all
the user's environment variables (not recommended), the easiest fix
seems to be to use  sudo -i  . With  -i, --login  shell files will be
sourced, and we get an environment equal to being root user as far as i
can tell.

$ sudo -i bash -c 'echo $LINUX_MODULE_DIRECTORY'
> /run/booted-system/kernel/lib/modules

I don't know what the proper way of handling this is. But i'm using an
alias at the moment  alias sudo='sudo -i'  . With this  sudo modprobe
works fine.

(I've looked at whitelisting environment variables in /etc/sudoers, but
i believe this is for passing on user defined variables, not system
variables.)

Petter
(karhunguixi)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]