Skip to content

Commit 4d6a8ba

Browse files
committed
Add Skift kodeord for superbruger
1 parent 50228b2 commit 4d6a8ba

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

change_superuser_password.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Skift kodeord for superuser"
3+
parent: "System"
4+
source: scripts/change_superuser_password.sh
5+
parameters:
6+
- name: "Kodeord"
7+
type: "password"
8+
default: null
9+
mandatory: true
10+
- name: "Gentag kodeord"
11+
type: "password"
12+
default: null
13+
mandatory: true
14+
compatibility:
15+
- "22.04"
16+
- "BorgerPC"
17+
- "Kiosk"
18+
---
19+
20+
## Beskrivelse
21+
Skift til det angivne superuser-kodeord.
22+
23+
Det er MEGET VIGTIGT at skifte fra standard-kodeordet til et andet, så snart en OS2borgerPC-maskine er færdiginstalleret.
24+
25+
Inputparametre:
26+
- Det nye kodeord
27+
- Gentag det nye kodeord
28+
29+
Regler for kodeordet:
30+
- Skal indeholde mindst 8 tegn
31+
- Kan ikke indeholde navnet på brugeren
32+
- Kan ikke være et enkelt ord fra ordbogen som fx. "bibliotek"
33+
34+
Dette script er blevet testet og virker på Ubuntu 22.04.

change_superuser_password.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env sh
2+
#
3+
# This script will change the superuser password on a OS2borgerPC machine.
4+
#
5+
# Expects exactly two input parameters
6+
7+
set -e
8+
9+
if [ $# -ne 2 ]
10+
then
11+
printf '%s\n' "usage: $(basename "$0") <password> <confirmation>"
12+
exit 1
13+
fi
14+
15+
if [ "$1" = "$2" ]
16+
then
17+
# change password
18+
TARGET_USER=superuser
19+
PASSWORD="$1"
20+
21+
# The chpasswd always return exit code 0, even when it fails.
22+
# We therefore need to check if there is a text, only failure to change the password generates text.
23+
output=$(echo "$TARGET_USER:$PASSWORD" | /usr/sbin/chpasswd 2>&1)
24+
25+
if [ -n "$output" ]; then
26+
echo "Failed to change password. Error message: $output"
27+
exit 1
28+
fi
29+
else
30+
printf '%s\n' "Passwords didn't match!"
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)