Archive for June, 2009

Can not keep the environment parameters when use “sudo xxxx”

Posted on June 25, 2009. Filed under: Linux |

sudo problem: can not keep the environment parameters when use “sudo xxxx”

For example:
“sudo doesn’t set HOME”

Solutions:
1. set the related environment in the file /etc/environment or /etc/bashrc or /etc/profile , this maybe work, but I did not try.

2. the command “sudo” from version 1.6.8p7-1.3 to 1.7.0 have the problem of the environment parameters, so maybe you can update the “sudo” to 1.7.0 or later

3. setting in the /etc/sudoers to keep the environment parameters when use “sudo”
    if you do not want to keep the parameters, add following line to the /etc/sudoers:
         Defaults env_reset
    if you want to keep the parameters, add the following lines, pay attention to the environments, add what you want/delete what you do not want:
         Defaults    env_keep = “COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
                        LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
                        LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
                        LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
                        LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
                        _XKB_CHARSET XAUTHORITY”

4. How to check the environment parameters are kept or not:
    env >> currentenv
    sudo env >> sudoenv
    diff currentenv sudoenv
  
References:
http://linux.derkeiler.com/Mailing-Lists/Debian/2006-03/msg00537.html
http://linux.derkeiler.com/Mailing-Lists/Debian/2006-03/msg00498.html
http://ubuntuforums.org/archive/index.php/t-930500.html
http://blenderartists.org/forum/showthread?t=7412
http://lists.zenoss.org/pipermail/zenoss-users/2006/000439.html
http://www.gratisoft.us/pipermail/sudo-users/2005-August/002593.html
http://www.gratisoft.us/pipermail/sudo-users/2008-September/003734.html
http://mail.python.org/pipermail/python-list/2006-April/379061.html
http://www.unix.com/unix-advanced-expert-users/97743-sudo-environment-setting.html

https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/31690

http://ubuntuforums.org/showthread.php?t=956777
https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/192651

Read Full Post | Make a Comment ( 2 so far )

Python: ImportError: No module named _md5

Posted on June 21, 2009. Filed under: Python |

Python 2.5.1 (r251:54863, Sep 3 2007, 17:35:15)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import md5
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.5/md5.py”, line 6, in
from hashlib import md5
File “/usr/lib/python2.5/hashlib.py”, line 133, in
md5 = __get_builtin_constructor(‘md5’)
File “/usr/lib/python2.5/hashlib.py”, line 60, in __get_builtin_constructor
import _md5
ImportError: No module named _md5

Searching on the Internet, It is caused incompatible by Python 2.5.1 and openssl-0.9.8a, the python 2.5.1 need the openssl library (symbol link: libssl.so.4 and libcrypto.so.4, and also libc.so.6 which is supplied by libc), but the openssl-0.9.8a only supply the libssl.so.6 and libcrypto.so.6 at /lib/, solution as following:
1. login as user “root”
2. cd /lib/
3. ln –s libssl.so.0.9.8e libssl.so.4
4. ln -s libcrypto.so.0.9.8e libcrypto.so.4
5. check in the python: execute python, then input “import md5”, if there is no output, the bug is fixed.

Read Full Post | Make a Comment ( 4 so far )

Liked it here?
Why not try sites on the blogroll...