Default unprivileged sudo conf., password set fallback to passwd

Closes #88
pull/100/head
Vlastimil Holer 7 years ago
parent 08dcb2d463
commit 3a44763638
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -24,11 +24,14 @@ if ! getent passwd "${USERNAME}" > /dev/null 2>&1; then
useradd -m "${USERNAME}"
fi
if [ "${GRANT_SUDO}" == "YES" -a "${USERNAME}" != "root" ]; then
if [ ! -f /etc/sudoers.d/${USERNAME} ]; then
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME}
chmod 644 /etc/sudoers.d/${USERNAME}
fi
GRANT_SUDO=${GRANT_SUDO:-YES}
GRANT_SUDO=$(echo "${GRANT_SUDO}" | tr '[:lower:]' '[:upper:]')
if [ "${GRANT_SUDO}" == "YES" ] && [ "${USERNAME}" != "root" ]; then
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/one-context
chmod 0440 /etc/sudoers.d/one-context
elif [ -f /etc/sudoers.d/one-context ]; then
unlink /etc/sudoers.d/one-context
fi
if [ -n "${CRYPTED_PASSWORD_BASE64}" ]; then
@ -37,8 +40,24 @@ if [ -n "${CRYPTED_PASSWORD_BASE64}" ]; then
elif [ -n "${PASSWORD_BASE64}" ]; then
PASSWORD=$(echo $PASSWORD_BASE64 | base64 -d)
chpasswd <<< "${USERNAME}:${PASSWORD}"
if [ $? -ne 0 ]; then
passwd "${USERNAME}" <<EOF
${PASSWORD}
${PASSWORD}
EOF
fi
elif [ -n "${CRYPTED_PASSWORD}" ]; then
usermod -p "${CRYPTED_PASSWORD}" "${USERNAME}"
elif [ -n "${PASSWORD}" ]; then
chpasswd <<< "${USERNAME}:${PASSWORD}"
if [ $? -ne 0 ]; then
passwd "${USERNAME}" <<EOF
${PASSWORD}
${PASSWORD}
EOF
fi
else
usermod -p '*' "${USERNAME}"
fi

Loading…
Cancel
Save