File: functions

package info (click to toggle)
certmonger 0.79.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,428 kB
  • sloc: ansic: 59,314; sh: 6,767; xml: 2,486; makefile: 919; python: 564
file content (36 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (7)
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
#!/bin/bash
function initnssdb() {
	dir=`echo "$1" | cut -f2- -d:`
	if ! test -d "$dir"/rosubdir ; then
		mkdir -m 500 "$dir"/rosubdir
	fi
	if test -d "$dir"/rwsubdir ; then
		chmod u+w "$dir"/rwsubdir/* || true
		rm -f "$dir"/rwsubdir/*
	else
		mkdir -m 700 "$dir"/rwsubdir
	fi
	echo ""   >  "$dir"/oldpin
	echo ""   >  "$dir"/oldpin2
	echo ""   >> "$dir"/oldpin2
	echo "$2" >  "$dir"/newpin
	echo "$2" >  "$dir"/newpin2
	echo "$2" >> "$dir"/newpin2
	certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null
	certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null
	certutil -d "$1" -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null
	certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null
	certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null
	certutil -d "$1"/rwsubdir -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null
	chmod u-w "$dir"/rwsubdir/*
}
function run_certutil() {
	dd if=/dev/urandom of="$dir"/noise bs=1024 count=1 > /dev/null 2> /dev/null
	certutil "$@" -z "$dir"/noise
}
function run_dos2unix() {
	dos2unix "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g
}
function run_unix2dos() {
	unix2dos "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g
}