Skip to content

Conversation

@graham-m-dunn
Copy link

Writing to known locations in your filesystem can be a security problem

@tbridge
Copy link
Owner

tbridge commented Feb 23, 2017

Hi Graham,

Thanks for the PR!

Can you walk me through what the new isadmin function does? I just want to make sure I understand it before I merge it in.

@graham-m-dunn
Copy link
Author

graham-m-dunn commented Feb 24, 2017 via email

@graham-m-dunn
Copy link
Author

graham-m-dunn commented Feb 24, 2017

Test code for isadmin()

#!/bin/bash

LOGGER=$(which echo)

isadmin() {
    if [[ -e /usr/bin/id ]]; then
        echo "using id"
        id -G $1 | grep -q -w 80 ;
    else
        echo "using groups"
        groups $1 | grep -q -w admin ;
    fi
}

if isadmin $(whoami) ; then
         ${LOGGER} "Privilege Escalation Allowed, Please Continue."
else
         ${LOGGER} "Privilege Escalation Denied, User Cannot Sudo."
         exit 6
fi

echo "you're root"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants