From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petter Subject: Re: modprobe on guix Date: Sun, 20 Sep 2015 20:55:42 +0200 Message-ID: <87mvwg539t.fsf@x200.i-did-not-set--mail-host-address--so-tickle-me> Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdjmB-000819-EA for guix-devel@gnu.org; Sun, 20 Sep 2015 14:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zdjm6-0000mp-EJ for guix-devel@gnu.org; Sun, 20 Sep 2015 14:55:51 -0400 Received: from mx01.mykolab.com ([95.128.36.1]:35157 helo=mx-out03.mykolab.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdjm6-0000lR-7i for guix-devel@gnu.org; Sun, 20 Sep 2015 14:55:46 -0400 Received: from mx04.mykolab.com (mx04.mykolab.com [10.20.7.102]) by mx-out03.mykolab.com (Postfix) with ESMTPS id 0583821506 for ; Sun, 20 Sep 2015 20:55:43 +0200 (CEST) In-Reply-To: 87lhijykkm.fsf%40gmail.com List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org 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)