-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: create userpass service to change the first password
- Loading branch information
Jonathan Dahan
committed
Sep 17, 2024
1 parent
ff89511
commit 16f8c2c
Showing
11 changed files
with
156 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
utilities/build/stage-solar/00-install-solar-protocol/files/10-hello.template
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
utilities/build/stage-solar/00-install-solar-protocol/files/20-warning.template
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
utilities/build/stage-solar/00-install-solar-protocol/files/etc/issue.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
☀️ solar protocol ${VERSION} \l |
15 changes: 15 additions & 0 deletions
15
...ies/build/stage-solar/00-install-solar-protocol/files/etc/systemd/system/userpass.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=User password dialog | ||
After=systemd-user-sessions.service | ||
Before=lightdm.service | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/lib/userpass-pi/userpass-service | ||
StandardInput=tty | ||
Restart=on-failure | ||
TTYPath=/dev/tty8 | ||
TTYReset=yes | ||
TTYVHangup=yes | ||
TTYVTDisallocate=yes | ||
[Install] | ||
WantedBy=multi-user.target |
52 changes: 52 additions & 0 deletions
52
utilities/build/stage-solar/00-install-solar-protocol/files/etc/ufw/user.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
*filter | ||
:ufw-user-input - [0:0] | ||
:ufw-user-output - [0:0] | ||
:ufw-user-forward - [0:0] | ||
:ufw-before-logging-input - [0:0] | ||
:ufw-before-logging-output - [0:0] | ||
:ufw-before-logging-forward - [0:0] | ||
:ufw-user-logging-input - [0:0] | ||
:ufw-user-logging-output - [0:0] | ||
:ufw-user-logging-forward - [0:0] | ||
:ufw-after-logging-input - [0:0] | ||
:ufw-after-logging-output - [0:0] | ||
:ufw-after-logging-forward - [0:0] | ||
:ufw-logging-deny - [0:0] | ||
:ufw-logging-allow - [0:0] | ||
:ufw-user-limit - [0:0] | ||
:ufw-user-limit-accept - [0:0] | ||
### RULES ### | ||
|
||
### tuple ### allow tcp 22 0.0.0.0/0 any 0.0.0.0/0 in | ||
-A ufw-user-input -p tcp --dport 22 -j ACCEPT | ||
|
||
### tuple ### allow tcp 80 0.0.0.0/0 any 0.0.0.0/0 in comment=536f6c61722050726f746f636f6c | ||
-A ufw-user-input -p tcp --dport 80 -j ACCEPT | ||
|
||
### tuple ### allow any 8443 0.0.0.0/0 any 0.0.0.0/0 in comment=536f6c61722050726f746f636f6c2028736563757265292028616c7429 | ||
-A ufw-user-input -p tcp --dport 8443 -j ACCEPT | ||
-A ufw-user-input -p udp --dport 8443 -j ACCEPT | ||
|
||
### tuple ### allow tcp 8080 0.0.0.0/0 any 0.0.0.0/0 in comment=536f6c61722050726f746f636f6c2028616c7429 | ||
-A ufw-user-input -p tcp --dport 8080 -j ACCEPT | ||
|
||
### tuple ### allow any 443 0.0.0.0/0 any 0.0.0.0/0 in comment=536f6c61722050726f746f636f6c202873656375726529 | ||
-A ufw-user-input -p tcp --dport 443 -j ACCEPT | ||
-A ufw-user-input -p udp --dport 443 -j ACCEPT | ||
|
||
### END RULES ### | ||
|
||
### LOGGING ### | ||
-A ufw-after-logging-input -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10 | ||
-A ufw-after-logging-forward -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10 | ||
-I ufw-logging-deny -m conntrack --ctstate INVALID -j RETURN -m limit --limit 3/min --limit-burst 10 | ||
-A ufw-logging-deny -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10 | ||
-A ufw-logging-allow -j LOG --log-prefix "[UFW ALLOW] " -m limit --limit 3/min --limit-burst 10 | ||
### END LOGGING ### | ||
|
||
### RATE LIMITING ### | ||
-A ufw-user-limit -m limit --limit 3/minute -j LOG --log-prefix "[UFW LIMIT BLOCK] " | ||
-A ufw-user-limit -j REJECT | ||
-A ufw-user-limit-accept -j ACCEPT | ||
### END RATE LIMITING ### | ||
COMMIT |
3 changes: 3 additions & 0 deletions
3
...ies/build/stage-solar/00-install-solar-protocol/files/etc/update-motd.d/10-hello.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo ☀️ solar protocol ${VERSION} |
4 changes: 4 additions & 0 deletions
4
...ities/build/stage-solar/00-install-solar-protocol/files/home/pi/disable-ssh-password-auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
sed -i -Ee 's/^#?[[:blank:]]*PubkeyAuthentication[[:blank:]]*no[[:blank:]]*$/PubkeyAuthentication yes/ | ||
s/^#?[[:blank:]]*PasswordAuthentication[[:blank:]]*yes[[:blank:]]*$/PasswordAuthentication no/' "${ROOTFS_DIR}"/etc/ssh/sshd_config |
32 changes: 32 additions & 0 deletions
32
...es/build/stage-solar/00-install-solar-protocol/files/usr/lib/userpass-pi/userpass-service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh -e | ||
|
||
validate_password() { | ||
if [ -z "$NEW_PASS" ]; then | ||
echo "Password cannot be empty." | ||
return 1 | ||
fi | ||
} | ||
|
||
if [ ! "$(raspi-config nonint get_boot_cli)" -eq 0 ]; then | ||
return | ||
fi | ||
|
||
VT="$(tty | sed 's|/dev/tty||')" | ||
ORIG_VT="1" | ||
if [ -t 0 ]; then | ||
chvt "$VT" | ||
fi | ||
FIRST_USER="$(getent passwd 1000 | cut -d: -f1)" | ||
|
||
while true; do | ||
NEW_PASS="$(whiptail --passwordbox "Please set a password for $FIRST_USER:" 20 60 3>&1 1>&2 2>&3)" | ||
if [ "$(whiptail --passwordbox "Please confirm the password:" 20 60 3>&1 1>&2 2>&3)" != "$NEW_PASS" ]; then | ||
MSG="Passwords did not match" | ||
elif MSG=$(validate_password); then | ||
break | ||
fi | ||
whiptail --msgbox "$MSG" 20 60 | ||
done | ||
|
||
echo "$FIRST_USER:$NEW_PASS" | chpasswd | ||
chvt "$ORIG_VT" |