Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

With 11.10 when any of my users with the bash shell login upon success they are asked to provide their sudo password e.g.

Last login: Fri Jan 20 19:13:36 2012 from x.x.x.x
[sudo] password for *user*:

However, using a different shell (viz. zsh) they aren't asked for their sudo password.

What's up?

[edit: more info]

So, of course it was obvious, but strange still.

/etc/bash.bashrc

#!/bin/sh -e
#execute firstlogin.sh only once
if [ ! -e /root/firstlogin_done ]; then
    if [ -e /root/firstlogin.sh ]; then
        /root/firstlogin.sh
    fi
    # This part should not be necessary any more
    # sudo dpkg-reconfigure -p critical console-setup &> /dev/null
    sudo touch /root/firstlogin_done
fi

The file is created just fine e.g.

$sudo ls -al /root/firstlogin_done
-rw-r--r-- 1 root root 0 2012-02-29 16:04 /root/firstlogin_done

[edit: is it a bug]

So, I get why this happens. But, I don't get why this is happening. Is this a bug that I haven't updated?

share|improve this question
    
Sounds like .profile is running something with sudo. Could you provide the content of ~/.profile in your question? –  geirha Feb 29 '12 at 15:25
1  
But .profile is supposed to be run by all the shells. If this only happens in bash, it's likely something in ~/.bashrc or more likely /etc/bash.bashrc, as this late file will affect every user. –  Javier Rivera Feb 29 '12 at 16:04
    
Not thinking of /etc/bash.bashrc palmface, nonetheless this is weird. –  bias Feb 29 '12 at 16:13
1  
@JavierRivera, I don't know about viz (never heard of it), but zsh does not read .profile (unless it's invoked as sh). Bash, ksh and dash, to name a few, does use .profile though. –  geirha Feb 29 '12 at 16:14
1  
Seems to be related to this bug: bugs.launchpad.net/ubuntu/+bug/409335. I can't fathom why anyone would think that was a good idea to use sudo in /etc/bash.bashrc. Not to mention the hashbang being completely wrong for a bash script. –  geirha Feb 29 '12 at 18:36

2 Answers 2

The test fails since permission on /root is 700. Hence, it uses sudo to clobber the file on every login.

share|improve this answer

Ok, turning comment into answer.

This seems to be related to bug https://bugs.launchpad.net/ubuntu/+bug/409335. I can't fathom why anyone would think that was a good idea to use sudo in /etc/bash.bashrc. Not to mention the hashbang being completely wrong for a bash script.

However, /etc/bash.bashrc isn't really needed. Vanilla bash doesn't even read /etc/bash.bashrc; it's mainly a Debian/Ubuntu thing to have bash patched to specifically look for, and source, /etc/bash.bashrc when starting bash interactively.

Anyway, if you want the /etc/bash.bashrc that a fresh install will have, grab the sources and copy the etc.bash.bashrc file to /etc/bash.bashrc

sudo apt-get install dpkg-dev
apt-get source bash
sudo cp bash-4.2/debian/etc.bash.bashrc /etc/bash.bashrc
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.