aboutsummaryrefslogtreecommitdiffstats
path: root/security/lsh/files/patch-lsh-authorize
blob: fd367474558e70693c4e6eea5a8aadc9fc14dcf1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--- src/lsh-authorize.orig  Tue Jul 11 13:56:07 2000
+++ src/lsh-authorize   Tue Jul 11 14:00:58 2000
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 
 usage () {
     echo Usage: $0 key-file
@@ -29,7 +29,7 @@
     exit 0
 fi
 
-create_dir () {
+create-dir () {
     if mkdir $1 2>/dev/null; then
    echo Created $1
    chmod $2 $1 || exit 1
@@ -37,26 +37,27 @@
 }
 
 # Create directories
-create_dir ~/.lsh 0700
-create_dir ~/.lsh/authorized_keys_sha1 0700
+create-dir ~/.lsh 0700
+create-dir ~/.lsh/authorized_keys_sha1 0700
 
-if type sexp-conv ; then
-    SEXP_CONV=sexp_conv
-else
-    SEXP_CONV=./sexp_conv
-fi
+PATH=$PATH:`dirname $0`
 
-if ! type $SEXP_CONV ; then
-    echo "Can't find the sexp_conv program"
-    exit 1
-fi
+SEXP_CONV="sexp_conv"
 
 while [ $# != 0 ]; do
-    hash=`$SEXP_CONV < $1 --once --hash sha1 --raw-hash`
-    if [ -z $hash ] ; then
-   echo $0: File $1 not found.
-    else
+    if [ -f $1 ]; then
+      hash=`$SEXP_CONV < $1 --once --hash sha1 --raw-hash`
+      if [ $? = 127 ]; then
+   echo "Can't find the sexp_conv program"
+       exit 1
+      fi
+      if [ -z "$hash" ] ; then
+   echo $0: File $1 not readable
+      else
         $SEXP_CONV < $1 -f canonical --once > ~/.lsh/authorized_keys_sha1/$hash
+      fi
+    else
+      echo $0: File $1 not found.
     fi
     shift
 done