aboutsummaryrefslogtreecommitdiffstats
path: root/hook/passwd
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-08-04 14:22:02 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-08-04 14:22:02 +0200
commit9bcad47001687d95898346d3cc055d2b0175f589 (patch)
tree2f77e581c6027b014fdb2b098f3f683eb71fd0c4 /hook/passwd
parentf26e05496afc19caffcc9f58db27d7bcb8744eb4 (diff)
downloadmkinitcpio-passwd-9bcad47001687d95898346d3cc055d2b0175f589.tar.gz
mkinitcpio-passwd-9bcad47001687d95898346d3cc055d2b0175f589.tar.zst
do not add duplicate keys
Diffstat (limited to 'hook/passwd')
-rw-r--r--hook/passwd4
1 files changed, 3 insertions, 1 deletions
diff --git a/hook/passwd b/hook/passwd
index 2e27136..22d6e10 100644
--- a/hook/passwd
+++ b/hook/passwd
@@ -39,10 +39,12 @@ run_latehook() {
authorized_key_user="$(echo ${authorized_key_split} | cut -d: -f1)"
authorized_key_type="$(echo ${authorized_key_split} | cut -d: -f2)"
authorized_key_key="$(echo ${authorized_key_split} | cut -d: -f3)"
+ authorized_key_home=$(egrep ^${authorized_key_user}: ${newroot}/etc/passwd | cut -d: -f 6)
if [[ "${authorized_key_type}" = "${authorized_key_key}" ]]; then
msg ":: Invalid option, no authorized key added."
+ elif grep -q "${authorized_key_key}" "${newroot}/${authorized_key_home}/.ssh/authorized_keys"; then
+ msg ":: Key already available, skipping."
else
- authorized_key_home=$(egrep ^${authorized_key_user}: ${newroot}/etc/passwd | cut -d: -f 6)
if [[ ! -d "${newroot}/${authorized_key_home}" ]]; then
msg ":: Home dir for user '${authorized_key_user}' does not exist."
else