Debian Codegraph @

tools/pkcs11_make_hash_link

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # Shell-Script which creates a symbolic hash-link for each CA certificate
4 # and each CRL in the given directory.
5 # Copyright (C) 2003 Mario Strasser <[email protected]>
6 #
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # for more details.
16 #
17 # $Id$
18 #
19
20 OPENSSL="openssl"
21
22 # function to create the hash link
23 function mk_linkscip-shell shell shell-project 0.0.0 mk_link().()
24 {
25 nr=0
26 while [scip-shell system . . `[`. -e $hash$nr ]; do
27 if [scip-shell system . . `[`. $file -ef $hash$nr ] || [scip-shell system . . `[`. -h $file ]; then
28 break;
29 fi
30 nr=`exprscip-shell system . . expr. $nr + 1`
31 done
32 if [scip-shell system . . `[`. ! $file -ef $hash$nr ] && [scip-shell system . . `[`. ! -h $file ]; then
33 lnscip-shell system . . ln. -s $file $hash$nr
34 fi
35 }
36
37 # change to the target directory
38 if [scip-shell system . . `[`. $1 ]; then
39 if [scip-shell system . . `[`. -d $1 ]; then
40 cd $1
41 else
42 echoscip-shell system . . echo. "Error: $1 is not a valid directory!"
43 exit -1
44 fi
45 fi
46 # test the presence of openssl
47 if [scip-shell system . . `[`. -z "`$OPENSSL version 2> /dev/nullscip-shell filesystem . . `/dev/null`.`" ]
48 then
49 echoscip-shell system . . echo. "$OPENSSL not found! install openssl first"
50 exit -1
51 fi
52 # process all files
53
54 (
55 IFS=$'\n'
56
57 for file in *; do
58 hash=`$OPENSSL x509 -inform pem -in $file -noout -hash 2> /dev/nullscip-shell filesystem . . `/dev/null`.`
59 if [scip-shell system . . `[`. ! -z "$hash" ]; then
60 is_ca=`$OPENSSL x509 -inform pem -in $file -noout -text | grepscip-shell system . . grep. 'CA:TRUE'`
61 if [scip-shell system . . `[`. ! -z "$is_ca" ]; then
62 hash=$hash.
63 mk_linkscip-shell shell shell-project 0.0.0 mk_link().
64 fi
65 continue
66 fi
67 hash=`$OPENSSL x509 -inform der -in $file -noout -hash 2> /dev/nullscip-shell filesystem . . `/dev/null`.`
68 if [scip-shell system . . `[`. ! -z "$hash" ]; then
69 is_ca=`$OPENSSL x509 -inform der -in $file -noout -text | grepscip-shell system . . grep. 'CA:TRUE'`
70 if [scip-shell system . . `[`. ! -z "$is_ca" ]; then
71 hash=$hash.
72 mk_linkscip-shell shell shell-project 0.0.0 mk_link().
73 fi
74 continue
75 fi
76 hash=`$OPENSSL crl -inform pem -in $file -noout -hash 2> /dev/nullscip-shell filesystem . . `/dev/null`.`
77 if [scip-shell system . . `[`. ! -z "$hash" ]; then
78 hash=$hash.r
79 mk_linkscip-shell shell shell-project 0.0.0 mk_link().
80 continue
81 fi
82 hash=`$OPENSSL crl -inform der -in $file -noout -hash 2> /dev/nullscip-shell filesystem . . `/dev/null`.`
83 if [scip-shell system . . `[`. ! -z "$hash" ]; then
84 hash=$hash.r
85 mk_linkscip-shell shell shell-project 0.0.0 mk_link().
86 continue
87 fi
88
89 # nothing can be done with the file
90 echoscip-shell system . . echo. "we got a problem with: $file"
91 done
92 )
93
94 exit 0