### BEGIN TASK INFO
# Provides: ChangePassword
-# RunBefore: UmountImage
+# RunBefore: EnforcePersonality
# RunAfter: InstallUnattend
# Short-Description: Changes Password for specified users
### END TASK INFO
set -e
. "@commondir@/common.sh"
+trap task_cleanup EXIT
+report_task_start
+
+# Check if the task should be prevented from running.
+check_if_excluded
+
windows_password() {
local target="$1"
local password="$2"
echo "@echo off" > "$target/Windows/SnfScripts/ChangeAdminPassword.cmd"
if [ -z "$SNF_IMAGE_PROPERTY_USERS" ]; then
+ warn "Image property \`USERS' is missing or empty. " \
+ "Changing the password for default user: \`Administrator'."
+
SNF_IMAGE_PROPERTY_USERS="Administrator"
fi
users+=("$usr")
done
else
+ warn "Image property \`USERS' is missing or empty. " \
+ "Changing the password for default user: \`root'."
users+=("root")
-
- local distro=$(get_distro $target)
-
- if [ "x$distro" = "xubuntu" -o \
- "x$distro" = "xfedora" ] ; then
- users+=("user")
- fi
fi
for i in $(seq 0 1 $((${#users[@]}-1))); do
add_cleanup rm "$tmp_shadow"
echo -n "Setting ${users[$i]} password..."
+ if ! grep "^${users[$i]}:" "$target/etc/shadow" > /dev/null; then
+ log_error "User: \`${users[$i]}' does not exist."
+ fi
echo "${users[$i]}:$hash:15103:0:99999:7:::" > "$tmp_shadow"
grep -v "${users[$i]}" "$target/etc/shadow" >> "$tmp_shadow"
linux_password "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
fi
-echo "done"
-
exit 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :