File: launcher

package info (click to toggle)
postgresql-9.1 9.1.15-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 109,092 kB
  • sloc: ansic: 575,877; sql: 43,887; yacc: 26,399; perl: 6,352; lex: 6,171; sh: 5,282; makefile: 3,772; asm: 65; sed: 15; python: 12
file content (52 lines) | stat: -rwxr-xr-x 1,119 bytes parent folder | download | duplicates (3)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
#
# A wrapper script to launch psql command in regression test
#
# Copyright (c) 2010-2011, PostgreSQL Global Development Group
#
# -------------------------------------------------------------------------

if [ $# -lt 1 ]; then
    echo "usage: `basename $0` <command> [options...]"
    exit 1
fi

RUNCON=`which runcon`
if [ ! -e "$RUNCON" ]; then
    echo "runcon command is not found"
    exit 1
fi

#
# Read SQL from stdin
#
TEMP=`mktemp`
CONTEXT=""

while IFS='\\n' read LINE
do
    if echo "$LINE" | grep -q "^-- @SECURITY-CONTEXT="; then
        if [ -s "$TEMP" ]; then
            if [ -n "$CONTEXT" ]; then
                "$RUNCON" "$CONTEXT" $* < "$TEMP"
            else
                $* < $TEMP
            fi
            truncate -s0 $TEMP
        fi
        CONTEXT=`echo "$LINE" | sed 's/^-- @SECURITY-CONTEXT=//g'`
        LINE="SELECT sepgsql_getcon();	-- confirm client privilege"
    fi
    echo "$LINE" >> $TEMP
done

if [ -s "$TEMP" ]; then
    if [ -n "$CONTEXT" ]; then
        "$RUNCON" "$CONTEXT" $* < "$TEMP"
    else
        $* < $TEMP
    fi
fi

# cleanup temp file
rm -f $TEMP