Skip to content

Instantly share code, notes, and snippets.

@pal
Last active August 29, 2015 14:18
Show Gist options
  • Save pal/1c4db9bd2b116ad880df to your computer and use it in GitHub Desktop.
Save pal/1c4db9bd2b116ad880df to your computer and use it in GitHub Desktop.
Edit /etc/sudoers from script to add increased timeout (for running kitchen plan provision, tip from https://github.com/pliljenberg/kitchenplan-config)
#!/bin/sh
# Code from http://stackoverflow.com/a/3706774/697243
if [ -z "$1" ]; then
export EDITOR=$0 && sudo -E visudo
else
cat $1 | sed 's/env_reset.*$/env_reset,timestamp_timeout=30/' >> $1
echo "Changed sudoers to increase timeout"
fi
# This file is managed by Chef.
# Do NOT modify this file directly.
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# 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_TEXT_ENCODING"
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_AUTH_SOCK"
Defaults env_keep += "TZ"
Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
Defaults env_keep += "EDITOR VISUAL"
Defaults env_keep += "HOME MAIL"
# 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
#includedir /etc/sudoers.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment