You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

launcher 1.2KB

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