Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.3 Reduce the sudo timeout period #2

Open
krispayne opened this issue Dec 23, 2014 · 2 comments
Open

5.3 Reduce the sudo timeout period #2

krispayne opened this issue Dec 23, 2014 · 2 comments

Comments

@krispayne
Copy link
Owner

sudo /usr/bin/grep -q '^Defaults timestamp_timeout\=' /etc/sudoers && /usr/bin/sed -i.bak '' 's/^Defaults timestamp_timeout\=.*/timestamp_timeout\=0' visudo || sed "$ a\Defaults timestamp_timeout=0" -i visudo

I wish this line would work. Can anyone help me with my sed?

@krispayne krispayne added this to the Level 1 Scored milestone Aug 2, 2016
@krispayne
Copy link
Owner Author

if [[ "$(< /etc/sudoers | grep timestamp)" -eq 0 ]]; then
    echo "No sudo timeout modification present. Default is 5 minutes."
else
    echo "sudo timeout modification present."
fi

@krispayne krispayne changed the title edit sudoers via one line 5.3 Reduce the sudo timeout period Aug 2, 2016
@krispayne
Copy link
Owner Author

krispayne commented Dec 1, 2016

I'm thinking something like this but I'm really afraid of fucking with sudoers.

# 5.3 Reduce the sudo timeout period
    # Level 1 Scored

    if [[ $(/usr/bin/grep -ic "timestamp" /etc/sudoers) -eq 0 ]]; then

        ScriptLogging "  No sudo timeout modification present. Reducing to 1 minute..."

        echo "sed goes in and sets Defaults, but probably just in the top of the file which is ugly as sin."

        # sed -i "/Defaults timestamp_timeout=1/d" /etc/sudoers

    elif [[ $(/usr/bin/grep -ic "timestamp" /etc/sudoers) -ge 1 ]]; then

        ScriptLogging "  sudo timeout modification present."

        # get the timeout line

        local SudoTimeOut

        SudoTimeOut=$(grep -i "timestamp" /etc/sudoers)

        # sed through to find the timeout line and modify it to be 1 minute?

        echo "this seems more complicated than I want it to be. I might be overthinking it again."

    else

        ScriptLogging "  Something unexpected happened. Blame Microsoft."

    fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant