In ChangePassword task check if the users exist
[snf-image] / snf-image-helper / tasks / 50ChangePassword.in
index cbc5a84..867dcac 100644 (file)
@@ -75,6 +75,9 @@ linux_password() {
         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"