Benches macOS

5

sudoers Error

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Wanting to install the Go programming language. Got everything from Mercurial and tried to build but it told me that it couldn't. Using the Google Groups I discover that I need to edit /etc/sudoers to make sure that the GOHOME, GOBIN, GOOS, and GOARCH environment variables are available to sudo. I fire up TextMate and edit like I thought was necessary and then I get syntax errors.

So I delete all of my changes and then my user can no longer perform a sudo getting "wobbet is not in the sudoers file." as an error message.

After doing a lot of digging I find a hit on this discussion board that says I really, really need to use visudo to edit the sudoers file and since it is corrupt I need to do so from the root login.

So I enable root login and restart and get into root mode and edit with no errors reported and come back with the same error message.

Then I go back into root mode, rm /etc/sudoers, and then visudo to create the file. I confirm it is now a 0 byte file. Restart and still get the same error that I am not allowed to sudo.

What is wrong and how do I correct it?

Many thanks!

5 replies

Sign in or join Beachball Help to reply.

  1. 0

    Camelot

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I confirm it is now a 0 byte file.

    Well clearly that's not going to work.

    Since /etc/sudoers contains a list of who's able to use
    sudo to run which commands with elevated privileges, it's clear that an empty file says no one can do anything.

    I suggest resetting your
    sudoers file to default, then try adding back in the necessary Go changes. As a guide, the default
    sudoers file looks like:

    # sudoers file.

    #

    # This file MUST be edited with the 'visudo' command as root.

    #

    # See the sudoers man page for the details on how to write a sudoers file.

    #

    # Host alias specification

    # User alias specification

    # Cmnd alias specification

    # Defaults specification

    Defaults env_reset

    Defaults env_keep += "BLOCKSIZE"

    Defaults env_keep += "COLORFGBG COLORTERM"

    Defaults env_keep += "
    _CF_USER_TEXTENCODING"

    Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"

    Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"

    Defaults env_keep += "LINES COLUMNS"

    Defaults env_keep += "LSCOLORS"

    Defaults env_keep += "SSH
    AUTHSOCK"

    Defaults env_keep += "TZ"

    Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"

    Defaults env_keep += "EDITOR VISUAL"

    # Runas alias specification

    # User privilege specification

    root ALL=(ALL) ALL

    %admin ALL=(ALL) ALL

    # Uncomment to allow people in group wheel to run all commands

    # %wheel ALL=(ALL) ALL

    # Same thing without a password

    # %wheel ALL=(ALL) NOPASSWD: ALL

    # Samples

    # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom

    # %users localhost=/sbin/shutdown -h now

    Use
    visudo to edit your sudoers file and put the above content into it, then add the Go configs.

  2. 0

    Camelot

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I confirm it is now a 0 byte file.

    Well clearly that's not going to work.

    Since /etc/sudoers contains a list of who's able to use
    sudo to run which commands with elevated privileges, it's clear that an empty file says no one can do anything.

    I suggest resetting your
    sudoers file to default, then try adding back in the necessary Go changes. As a guide, the default
    sudoers file looks like:

    # sudoers file.

    #

    # This file MUST be edited with the 'visudo' command as root.

    #

    # See the sudoers man page for the details on how to write a sudoers file.

    #

    # Host alias specification

    # User alias specification

    # Cmnd alias specification

    # Defaults specification

    Defaults env_reset

    Defaults env_keep += "BLOCKSIZE"

    Defaults env_keep += "COLORFGBG COLORTERM"

    Defaults env_keep += "
    _CF_USER_TEXTENCODING"

    Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"

    Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"

    Defaults env_keep += "LINES COLUMNS"

    Defaults env_keep += "LSCOLORS"

    Defaults env_keep += "SSH
    AUTHSOCK"

    Defaults env_keep += "TZ"

    Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"

    Defaults env_keep += "EDITOR VISUAL"

    # Runas alias specification

    # User privilege specification

    root ALL=(ALL) ALL

    %admin ALL=(ALL) ALL

    # Uncomment to allow people in group wheel to run all commands

    # %wheel ALL=(ALL) ALL

    # Same thing without a password

    # %wheel ALL=(ALL) NOPASSWD: ALL

    # Samples

    # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom

    # %users localhost=/sbin/shutdown -h now

    Use
    visudo to edit your sudoers file and put the above content into it, then add the Go configs.

  3. 0

    etresoft

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Mr. Wobbet wrote:

    Got everything from Mercurial and tried to build but it told me that it couldn't.

    Why not?

    Using the Google Groups I discover that I need to edit /etc/sudoers to make sure that the GOHOME, GOBIN, GOOS, and GOARCH environment variables are available to sudo.

    That is highly unlikely and unusual. If a programming language needs root in order to run, you don't want it. I'm pretty sure that is not the case, however.

    Fix your sudoers file and we'll look at your first problem.

  4. 0

    Mr. Wobbet

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    First - THANK YOU! The default sudoers file contents listed above in the discussion allowed me to perform sudo again.

    I attempted to build Go once again and got the error that $GOROOT was undefined. I used visudo (now I know!) to add in the required environment variables per the (incredibly long) Google Groups link below and ran the build using sudo and it worked.

    Note - the environment variables weren't required to
    run, they are required to
    build the language.

    Many thanks again!

    rjsjr

    Titus 2:11-12

    http://groups.google.com/group/golang-nuts/browse_thread/thread/6db568d839310301 /648abb84e4688acc?lnk=gst&q=%24GOROOTis+not+correctly+set+orexported#648abb84e4688acc

  5. 0

    etresoft

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Mr. Wobbet wrote:

    Note - the environment variables weren't required to
    run, they are required to
    build the language.

    The only thing you would ever need sudo for is to install into /usr/local. You should never need to hack up sudoers.

    It sure doesn't give me confidence in Google's Go language. Any two-bit open-source programmer in the world can put together a configure-based package that can be installed with "./configure; make; sudo make install". Why can't Google?