Skip to content

Commit

Permalink
Add Skift kodeord for superbruger
Browse files Browse the repository at this point in the history
  • Loading branch information
agnetemoos committed Dec 10, 2024
1 parent 50228b2 commit 4d6a8ba
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
34 changes: 34 additions & 0 deletions change_superuser_password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Skift kodeord for superuser"
parent: "System"
source: scripts/change_superuser_password.sh
parameters:
- name: "Kodeord"
type: "password"
default: null
mandatory: true
- name: "Gentag kodeord"
type: "password"
default: null
mandatory: true
compatibility:
- "22.04"
- "BorgerPC"
- "Kiosk"
---

## Beskrivelse
Skift til det angivne superuser-kodeord.

Det er MEGET VIGTIGT at skifte fra standard-kodeordet til et andet, så snart en OS2borgerPC-maskine er færdiginstalleret.

Inputparametre:
- Det nye kodeord
- Gentag det nye kodeord

Regler for kodeordet:
- Skal indeholde mindst 8 tegn
- Kan ikke indeholde navnet på brugeren
- Kan ikke være et enkelt ord fra ordbogen som fx. "bibliotek"

Dette script er blevet testet og virker på Ubuntu 22.04.
32 changes: 32 additions & 0 deletions change_superuser_password.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env sh
#
# This script will change the superuser password on a OS2borgerPC machine.
#
# Expects exactly two input parameters

set -e

if [ $# -ne 2 ]
then
printf '%s\n' "usage: $(basename "$0") <password> <confirmation>"
exit 1
fi

if [ "$1" = "$2" ]
then
# change password
TARGET_USER=superuser
PASSWORD="$1"

# The chpasswd always return exit code 0, even when it fails.
# We therefore need to check if there is a text, only failure to change the password generates text.
output=$(echo "$TARGET_USER:$PASSWORD" | /usr/sbin/chpasswd 2>&1)

if [ -n "$output" ]; then
echo "Failed to change password. Error message: $output"
exit 1
fi
else
printf '%s\n' "Passwords didn't match!"
exit 1
fi

0 comments on commit 4d6a8ba

Please sign in to comment.