giwrgos

Q: sudo: /etc/sudoers is world writable El Capitan

Today I found out that I can not use the sudo on my terminal. I tried to remove something using sudo and I i've got the following error message.

 

sudo: /etc/sudoers is world writable

sudo: no valid sudoers sources found, quitting


My terminal

Last login: Fri Oct 16 08:51:18 on console

Georges-MacBook-Pro:~ g3o$ sudo rm -rf /Library/Caches/com.apple.iconservices.store

sudo: /etc/sudoers is world writable

sudo: no valid sudoers sources found, quitting



Georges-MacBook-Pro:~ g3o$  ls -lsa /etc/sudoers

0 -rwxrwxrwx  1 root  wheel  2299 Aug 23 01:39 /etc/sudoers

Georges-MacBook-Pro:~ g3o$



On a research that I did they are saying to make a reinstall of the OSX, is there any alternative method to fix this issue without reinstalling the OSX?

MacBook Pro (Retina, 15-inch, Late 2013), OS X El Capitan (10.11), null

Posted on Oct 15, 2015 11:46 PM

Close

Q: sudo: /etc/sudoers is world writable El Capitan

  • All replies
  • Helpful answers

  • by giwrgos,

    giwrgos giwrgos Oct 16, 2015 12:10 AM in response to giwrgos
    Level 1 (12 points)
    Oct 16, 2015 12:10 AM in response to giwrgos

    I found the following article

    http://apple.stackexchange.com/a/98351

     

    I did what it says, is fixing the issue but I'm getting a warning

     

    Georges-MacBook-Pro:~ g3o$ sudo rm -rf /Library/Caches/com.apple.iconservices.store

    sudo: /var/db/sudo writable by non-owner (040777), should be mode 0700

     

    WARNING: Improper use of the sudo command could lead to data loss

    or the deletion of important system files. Please double-check your

    typing when using sudo. Type "man sudo" for more information.

     

    To proceed, enter your password, or type Ctrl-C to abort.


    How i can fix it?

  • by BobHarris,

    BobHarris BobHarris Oct 16, 2015 6:09 AM in response to giwrgos
    Level 6 (19,272 points)
    Mac OS X
    Oct 16, 2015 6:09 AM in response to giwrgos

    Start with trying

    diskutil verifyPermissions /

    See if that clears up the problem.

     

    If not, then here are the correct ownership and permissions for the path to that file

    drwxr-xr-x 37 root wheel 1326 Oct 14 09:50 /

    drwxr-xr-x  6 root wheel  204 Oct 31  2014 /private

    drwxr-xr-x 26 root wheel  884 Jun 13 15:42 /private/var

    drwxr-xr-x 80 root wheel 2720 Oct 14 11:28 /private/var/db

    drwx------  3 root wheel  102 Nov  5  2014 /private/var/db/sudo

    sudo chown root:wheel /private/var/db/sudo

    sudo chmod 700 /private/var/db/sudo

  • by giwrgos,

    giwrgos giwrgos Oct 16, 2015 7:32 AM in response to BobHarris
    Level 1 (12 points)
    Oct 16, 2015 7:32 AM in response to BobHarris

    the diskutil verifyPermissions / is not available

  • by VikingOSX,

    VikingOSX VikingOSX Oct 16, 2015 10:26 AM in response to BobHarris
    Level 7 (20,606 points)
    Mac OS X
    Oct 16, 2015 10:26 AM in response to BobHarris

    Bob,

     

    In El Capitan, the ability to verify and repair permissions has been removed from diskutil and from Disk Utility. One can only verify/repair volumes now.

  • by BobHarris,

    BobHarris BobHarris Oct 16, 2015 11:33 AM in response to VikingOSX
    Level 6 (19,272 points)
    Mac OS X
    Oct 16, 2015 11:33 AM in response to VikingOSX

    VikingOSX wrote:

     

    Bob,

     

    In El Capitan, the ability to verify and repair permissions has been removed from diskutil and from Disk Utility. One can only verify/repair volumes now.

    I was hoping that they just removed it from the Disk Utility GUI.

     

    At least I provided Terminal commands to set the correct permissions, and it did appear that was able to get sudo to work, it just issued some annoying messages.

  • by Linc Davis,

    Linc Davis Linc Davis Oct 16, 2015 1:30 PM in response to giwrgos
    Level 10 (207,926 points)
    Applications
    Oct 16, 2015 1:30 PM in response to giwrgos

    Unless you know what caused the permissions to be corrupted, the only safe course of action is to back up all data and then reinstall the OS. You won't need your backup unless something goes wrong.

  • by giwrgos,

    giwrgos giwrgos Oct 17, 2015 3:01 PM in response to Linc Davis
    Level 1 (12 points)
    Oct 17, 2015 3:01 PM in response to Linc Davis

    i did a reinstall but it disnt help

  • by Linc Davis,

    Linc Davis Linc Davis Oct 17, 2015 3:41 PM in response to giwrgos
    Level 10 (207,926 points)
    Applications
    Oct 17, 2015 3:41 PM in response to giwrgos

    You must have wrecked the permissions of every file on the startup volume. If possible, recover from a backup that predates the damage:

     

    OS X El Capitan: Recover your entire system

     

    Otherwise see below.

    Back up all data to at least two different storage devices, if you haven't already done so. One backup is not enough to be safe. The backups can be made with Time Machine or with Disk Utility. Preferably both.

    Erase and install OS X. This operation will destroy all data on the startup volume, so you had be better be sure of the backups. If you upgraded from an older version of OS X, you'll need the Apple ID and password that you used, so make a note of those before you begin.

    When you restart, you'll be prompted to go through the initial setup process. That’s when you transfer the data from a backup.

    Select only users in the Setup Assistant dialog—not Applications, Computer & Network Settings, or Other files and folders. Don't transfer the Guest account, if it was enabled.

    Then reinstall third-party software.

  • by AbsoluteComputers,

    AbsoluteComputers AbsoluteComputers Aug 22, 2016 3:26 AM in response to giwrgos
    Level 2 (219 points)
    Aug 22, 2016 3:26 AM in response to giwrgos

    You can safely chmod the /etc/sudoers file providing you duplicate it first.


    Because sudo won't work until you change the permissions on the file, you'll need to use su to enable root user. Take extreme care as you will be at the root of the drive and NOT your User folder, so check you're in the correct location by using the command pwd first. So, type su and after the prompt, your password where the ~username$ will change to a #

     

    Check the current permissions with ls -l /etc/sudoe* which should now list sudoers & sudoers copy with permissions of -rwxrwxrwx which we now need to change to -r--r----- by using the command chmod 440 /etc/sudoers

     

    Recheck the permissions with the ls -l /etc/sudoe* and you should see the two files with these perms

     

    -r--r-----  1 root  wheel  2299

    -rwxrwxrwx  1 user  wheel  2299

     

    type exit to get out of Super User (the prompt will change from a # to $)

     

    now confirm sudo is working by typing

    sudo  ls -l /etc/sudoe*

     

    Where you should be prompted for your SuperUser password and the same results as above should be listed.