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.
|
- #!/bin/sh -
-
- . ./settings.conf
-
- makeauthkeys()
- {
- local inp out i
-
- inp="$1"
- out="$2"
-
- while read user keytype key; do
- echo 'restrict,command="'"$keygencmd $user"'"'" $keytype $key"
- done < "$inp" > "$out"
- }
-
- if [ x"$1" = x"test" ]; then
- set -e
-
- tmpdir=$(mktemp -d -t testfoobar)
- trap "rm -rf $tmpdir" EXIT
-
- labkeys="$tmpdir/lab_keys"
- echo 'someuser ssh-rsa auserkey' > "$labkeys"
-
- makeauthkeys "$labkeys" "$tmpdir/auth_out"
-
- cat "$tmpdir/auth_out"
-
- exit 0
- fi
-
- if ! id $labuser > /dev/null 2>&1; then
- echo "ERROR: The user \"$labuser\" does not exist."
- exit 1
- fi
-
- set -e
-
- mkdir "${labauthfile}.lock"
- trap "rmdir ${labauthfile}.lock" EXIT
-
- tmpfile="${labauthfile}.tmp"
- makeauthkeys "$labkeys" "$tmpfile"
- chown "$labuser:$labuser" "$tmpfile"
- mv "$tmpfile" "$labauthfile"
|