My sudo is broken :(

Discussion in 'Mac Basics and Help' started by RedTomato, Mar 16, 2011.

  1. RedTomato macrumors 68040

    RedTomato

    Joined:
    Mar 4, 2005
    Location:
    .. London ..
    #1
    Code:
    tomatomacbook:~ tomato$ sudo ls
    sudo: unable to initialize PAM: No such file or directory
    Any idea why? I'm relatively comfortable in Terminal, but I'm not a programmer and I haven't been messing with sudo or the PAM files. All I wanted to do was to run a couple of commands as root.

    If it's any help, last time I ran sudo successfully was a couple of months ago, to remove a plist file.

    Thanks
     
  2. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #2
    What were you doing before this happened? Did you overwrite anything in /usr/lib/?
     
  3. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #3
    Please run the following commands (in bold) and report the output :

    Code:
    #[B] ls -al /etc/pam.d/sudo[/B]
    -r--r--r--  1 root  wheel  203 Sep 25 00:28 /etc/pam.d/sudo
    # [B]grep -v -e ^# -e ^$ /etc/pam.d/sudo | awk '{ print $3 }' | xargs -t -n 1 -I{} ls -al /usr/lib/pam/{}*[/B]
    ls -al /usr/lib/pam/pam_opendirectory.so.2
    -r--r--r--  1 root  wheel  64272 Sep 25 00:27 /usr/lib/pam/pam_opendirectory.so.2
    ls -al /usr/lib/pam/pam_permit.so.2
    -rwxr-xr-x  1 root  wheel  42432 Sep 25 00:26 /usr/lib/pam/pam_permit.so.2
    ls -al /usr/lib/pam/pam_deny.so.2
    -rwxr-xr-x  1 root  wheel  42432 Sep 25 00:26 /usr/lib/pam/pam_deny.so.2
    ls -al /usr/lib/pam/pam_permit.so.2
    -rwxr-xr-x  1 root  wheel  42432 Sep 25 00:26 /usr/lib/pam/pam_permit.so.2
    
    BTW, this is not a programming question, I have asked the mods to move it to an OS X help forum.
     
  4. RedTomato, Mar 17, 2011
    Last edited: Mar 17, 2011

    RedTomato thread starter macrumors 68040

    RedTomato

    Joined:
    Mar 4, 2005
    Location:
    .. London ..
    #4
    Many thanks for your help. Sorry this is a long post, but I hope I've made it easy to follow.

    I haven't touched /usr/lib. The only thing I did that needed some digging around was to remove a broken install of Little Snitch from Obdev. I've since reinstalled it and it's working fine now.

    Thanks for the move. My results:

    Code:
    tomatomacbook:pam tomato$ ls -al /etc/pam.d/sudo
    -r--r--r--  1 root  wheel  280 22 Jan  2010 /etc/pam.d/sudo
    tomatomacbook:~ tomato$ grep -v -e ^# -e ^$ /etc/pam.d/sudo | awk '{ print $3 }' | xargs -t -n 1 -I{} ls -al /usr/lib/pam/{}*
    ls -al /usr/lib/pam/pam_securityserver.so*
    ls: /usr/lib/pam/pam_securityserver.so*: No such file or directory
    ls -al /usr/lib/pam/pam_unix.so*
    ls: /usr/lib/pam/pam_unix.so*: No such file or directory
    ls -al /usr/lib/pam/pam_deny.so*
    ls: /usr/lib/pam/pam_deny.so*: No such file or directory
    ls -al /usr/lib/pam/pam_permit.so*
    ls: /usr/lib/pam/pam_permit.so*: No such file or directory
    ls -al /usr/lib/pam/pam_deny.so*
    ls: /usr/lib/pam/pam_deny.so*: No such file or directory
    ls -al /usr/lib/pam/pam_permit.so*
    ls: /usr/lib/pam/pam_permit.so*: No such file or directory
    Hmm. Let's have a look in the folder.

    Code:
    tomatomacbook:pam tomato$ cd /usr/lib/pam
    tomatomacbook:pam tomato$ ls -la
    total 488
    drwxr-xr-x   17 root  wheel     578 27 Nov 11:57 .
    drwxr-xr-x  389 root  wheel   13226 12 Jan 17:03 ..
    -rwxr-xr-x    1 root  wheel   42432 11 Feb  2010 pam_deny.so.2
    -r--r--r--    1 root  wheel   76640 31 Jul  2009 pam_env.so.2
    -r--r--r--    1 root  wheel   51024 31 Jul  2009 pam_group.so.2
    -r--r--r--    1 root  wheel   99776 31 Jul  2009 pam_krb5.so.2
    -r--r--r--    1 root  wheel   51552 31 Jul  2009 pam_launchd.so.2
    -r--r--r--    1 root  wheel   68800 31 Jul  2009 pam_mount.so.2
    -r--r--r--    1 root  wheel   50896 31 Jul  2009 pam_nologin.so.2
    -r--r--r--    1 root  wheel   64272 31 Jul  2009 pam_opendirectory.so.2
    -rwxr-xr-x    1 root  wheel   42432 11 Feb  2010 pam_permit.so.2
    -r--r--r--    1 root  wheel   50720 31 Jul  2009 pam_rootok.so.2
    -r--r--r--    1 root  wheel   51008 31 Jul  2009 pam_sacl.so.2
    -r--r--r--    1 root  wheel   50608 31 Jul  2009 pam_self.so.2
    -r--r--r--    1 root  wheel   60448 31 Jul  2009 pam_serialnumber.so.2
    -r--r--r--    1 root  wheel   50880 31 Jul  2009 pam_uwtmp.so.2
    -rwxr-xr-x    1 root  wheel  191104  4 Aug  2010 pam_winbind.so
    tomatomacbook:pam tomato$ 
    Comparing my listing with your listing, I find:

    • /etc/pam.d/sudo - is present
    • /usr/lib/pam/pam_securityserver.so* - missing
    • /usr/lib/pam/pam_unix.so* - missing
    • /usr/lib/pam/pam_deny.so* - present in pam folder, but not found by your grep.
    • /usr/lib/pam/pam_permit.so* - present in folder but not found by your grep.

    What now?
     
  5. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #5
    Restore the missing files by copying them from another OS X machine running the same OS version or your Time Machine backup.
     
  6. Gfive macrumors newbie

    Gfive

    Joined:
    Mar 20, 2007
    Location:
    Amsterdam
    #6
    pam_unix.so is not available on any Mac OS X 10.7 installation.

    Apple used OpenPam and didn't include pam_unix.so.
    (if you download the latest openpam from the opensource.apple.com you will see that pam_unix is available, yet not compiled and installed by apple)

    Only I don't know how to install 1 module.
    (I need pam_unix.so also badly)
     
  7. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #7
    Compile and build then instead of install just copy the built module?
     
  8. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #8
    Try Applescript

    I have used Applescript to do sudo things and it has worked for me. In spotlight type apples and Applescript Editor should show up near the top of the list.

    A way to get around broken sudo on Lion is to make an applescript that does the same thing. In Applecript, issue a shell command and append "with administrator priveleges" to the command. You should get prompted for your password (you are an admin aren't you?), and the command should run.

    When you have a script working the way you like, you can save it as a script or as an app.
     
  9. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #9
    Don't think this has anything to do with the problem at hand for either the OP or the thread reviver ;)
     
  10. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #10
    Oops. I gotta look more closely at dates when I answer a thread. :eek: Still, I don't understand the problem the OP was having as sudo works fine on my Lion box.
     

Share This Page