File: functions

package info (click to toggle)
certmonger 0.75.14-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,540 kB
  • ctags: 2,176
  • sloc: ansic: 41,340; sh: 9,551; makefile: 528; python: 207; xml: 190; sed: 16
file content (36 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (4)
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
}