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

Remove hardcodes password for sudoer postscript #6166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions xCAT/postscripts/sudoer
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@
#
#------------------------------------------------------------------------------

function usage() {
echo ""
echo "Usage: $0 -u username -p password"
echo -e "\t-u sudoer user name"
echo -e "\t-p sudoer password"
exit 1
}

while getopts "u:p:" opt;
do
case $opt in
u) SUDOER="$OPTARG";;
p) SUDOERPW="$OPTARG";;
esac
done

if [ -z "$SUDOER" ] || [ -z $SUDOERPW ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest $SUDOER and $SUDOERPW be set to default value if not specified to keep backward compatibility

then
usage;
fi


if [ -n "$LOGLABEL" ]; then
log_label=$LOGLABEL
else
Expand All @@ -19,14 +41,12 @@ if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
fi

# Configuration for the sudoer
SUDOER="xcat"
SUDOERPW="rootpw"
PRIV="$SUDOER ALL=(ALL) NOPASSWD: ALL"
SEED=`date "+%s"`
ENCRYPT=`perl -e "print crypt($SUDOERPW, $SEED)"`

# Create sudoer
/usr/sbin/userdel $SUDOER
/usr/sbin/userdel $SUDOER &> /dev/null
/usr/sbin/useradd -p $ENCRYPT -m $SUDOER
echo "$PRIV" >> /etc/sudoers
if [ -e "/etc/redhat-release" ]; then
Expand Down