Set of files and scripts for Embedded Lab 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
783 B

  1. #!/bin/sh -
  2. . ./settings.conf
  3. makeauthkeys()
  4. {
  5. local inp out i
  6. inp="$1"
  7. out="$2"
  8. while read user keytype key; do
  9. echo 'restrict,command="'"$keygencmd $user"'"'" $keytype $key"
  10. done < "$inp" > "$out"
  11. }
  12. if [ x"$1" = x"test" ]; then
  13. set -e
  14. tmpdir=$(mktemp -d -t testfoobar)
  15. trap "rm -rf $tmpdir" EXIT
  16. labkeys="$tmpdir/lab_keys"
  17. echo 'someuser ssh-rsa auserkey' > "$labkeys"
  18. makeauthkeys "$labkeys" "$tmpdir/auth_out"
  19. cat "$tmpdir/auth_out"
  20. exit 0
  21. fi
  22. if ! id $labuser > /dev/null 2>&1; then
  23. echo "ERROR: The user \"$labuser\" does not exist."
  24. exit 1
  25. fi
  26. set -e
  27. mkdir "${labauthfile}.lock"
  28. trap "rmdir ${labauthfile}.lock" EXIT
  29. tmpfile="${labauthfile}.tmp"
  30. makeauthkeys "$labkeys" "$tmpfile"
  31. chown "$labuser:$labuser" "$tmpfile"
  32. mv "$tmpfile" "$labauthfile"