lib/tools.in(maketemp): really remove insecure fall-back if mktemp is missing, since...
[matthijs/upstream/backupninja.git] / lib / tools.in
1 #!@BASH@
2 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3
4 # This file contains functions shared between ninjahelper and backupninja.
5
6 #####################################################
7 ## MISC FUNCTIONS
8
9 #
10 # create a temporary file in a secure way.
11 #
12 function maketemp() {
13         local tempfile=`mktemp /tmp/$1.XXXXXXXX`
14         echo $tempfile
15 }
16
17 #####################################################
18 ## CONFIG-FILE RELATED FUNCTIONS
19
20 function setfile() {
21         CURRENT_CONF_FILE=$1
22 }
23
24 function setsection() {
25         CURRENT_SECTION=$1
26 }
27
28 #
29 # sets a global var with name equal to $1
30 # to the value of the configuration parameter $1
31 # $2 is the default.
32
33 function getconf() {
34         CURRENT_PARAM=$1
35         ret=`@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE`
36         # if nothing is returned, set the default
37         if [ "$ret" == "" -a "$2" != "" ]; then
38                 ret="$2"
39         fi
40
41         # replace * with %, so that it is not globbed.
42         ret="${ret//\\*/__star__}"
43
44         # this is weird, but single quotes are needed to 
45         # allow for returned values with spaces. $ret is still expanded
46         # because it is in an 'eval' statement.
47         eval $1='$ret'
48 }