| 1 |
#!/bin/bash |
| 2 |
function initnssdb() { |
| 3 |
dir=`echo "$1" | cut -f2- -d:` |
| 4 |
if ! test -d "$dir"/rosubdir ; then |
| 5 |
mkdir -m 500 "$dir"/rosubdir |
| 6 |
fi |
| 7 |
if test -d "$dir"/rwsubdir ; then |
| 8 |
chmod u+w "$dir"/rwsubdir/* || true |
| 9 |
rm -f "$dir"/rwsubdir/* |
| 10 |
else |
| 11 |
mkdir -m 700 "$dir"/rwsubdir |
| 12 |
fi |
| 13 |
echo "" > "$dir"/oldpin |
| 14 |
echo "" > "$dir"/oldpin2 |
| 15 |
echo "" >> "$dir"/oldpin2 |
| 16 |
echo "$2" > "$dir"/newpin |
| 17 |
echo "$2" > "$dir"/newpin2 |
| 18 |
echo "$2" >> "$dir"/newpin2 |
| 19 |
certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null |
| 20 |
certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null |
| 21 |
certutil -d "$1" -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null |
| 22 |
certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null |
| 23 |
certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null |
| 24 |
certutil -d "$1"/rwsubdir -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null |
| 25 |
chmod u-w "$dir"/rwsubdir/* |
| 26 |
} |
| 27 |
function run_certutil() { |
| 28 |
dd if=/dev/urandom of="$dir"/noise bs=1024 count=1 > /dev/null 2> /dev/null |
| 29 |
certutil "$@" -z "$dir"/noise |
| 30 |
} |
| 31 |
function run_dos2unix() { |
| 32 |
dos2unix "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g |
| 33 |
} |
| 34 |
function run_unix2dos() { |
| 35 |
unix2dos "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g |
| 36 |
} |