~ubuntu-branches/debian/sid/postgresql-9.3/sid

« back to all changes in this revision

Viewing changes to contrib/sepgsql/launcher

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 05:39:52 UTC
  • Revision ID: package-import@ubuntu.com-20130508053952-1j7uilp7mjtrvq8q
Tags: upstream-9.3~beta1
ImportĀ upstreamĀ versionĀ 9.3~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# A wrapper script to launch psql command in regression test
 
4
#
 
5
# Copyright (c) 2010-2013, PostgreSQL Global Development Group
 
6
#
 
7
# -------------------------------------------------------------------------
 
8
 
 
9
if [ $# -lt 1 ]; then
 
10
    echo "usage: `basename $0` <command> [options...]"
 
11
    exit 1
 
12
fi
 
13
 
 
14
RUNCON=`which runcon`
 
15
if [ ! -e "$RUNCON" ]; then
 
16
    echo "runcon command is not found"
 
17
    exit 1
 
18
fi
 
19
 
 
20
#
 
21
# Read SQL from stdin
 
22
#
 
23
TEMP=`mktemp`
 
24
CONTEXT=""
 
25
 
 
26
while IFS='\\n' read LINE
 
27
do
 
28
    if echo "$LINE" | grep -q "^-- @SECURITY-CONTEXT="; then
 
29
        if [ -s "$TEMP" ]; then
 
30
            if [ -n "$CONTEXT" ]; then
 
31
                "$RUNCON" "$CONTEXT" $* < "$TEMP"
 
32
            else
 
33
                $* < $TEMP
 
34
            fi
 
35
            truncate -s0 $TEMP
 
36
        fi
 
37
        CONTEXT=`echo "$LINE" | sed 's/^-- @SECURITY-CONTEXT=//g'`
 
38
        LINE="SELECT sepgsql_getcon();  -- confirm client privilege"
 
39
    fi
 
40
    echo "$LINE" >> $TEMP
 
41
done
 
42
 
 
43
if [ -s "$TEMP" ]; then
 
44
    if [ -n "$CONTEXT" ]; then
 
45
        "$RUNCON" "$CONTEXT" $* < "$TEMP"
 
46
    else
 
47
        $* < $TEMP
 
48
    fi
 
49
fi
 
50
 
 
51
# cleanup temp file
 
52
rm -f $TEMP