ci-buster-pg-virtualenv.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From aa4829c899a3cf7ea6c90990d989dd57d2a63857 Mon Sep 17 00:00:00 2001
  2. From: Christoph Berg <christoph.berg@credativ.de>
  3. Date: Thu, 8 Aug 2019 11:57:34 +0200
  4. Subject: [PATCH] pg_virtualenv: Write temporary password file before chowning
  5. the file.
  6. Bug-Debian: https://bugs.debian.org/933569
  7. ---
  8. debian/changelog | 1 +
  9. pg_virtualenv | 16 +++++++++-------
  10. 2 files changed, 10 insertions(+), 7 deletions(-)
  11. diff --git a/pg_virtualenv b/pg_virtualenv
  12. index a5f4c5a..a6de9db 100755
  13. --- a/pg_virtualenv
  14. +++ b/pg_virtualenv
  15. @@ -98,6 +98,13 @@ shift $(($OPTIND - 1))
  16. # if no command is given, open a shell
  17. [ "${1:-}" ] || set -- ${SHELL:-/bin/sh}
  18. +# generate a password
  19. +if [ -x /usr/bin/pwgen ]; then
  20. + export PGPASSWORD=$(pwgen 20 1)
  21. +else
  22. + export PGPASSWORD=$(dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum - | awk '{ print $1 }')
  23. +fi
  24. +
  25. # we are not root
  26. if [ "$(id -u)" != 0 ]; then
  27. NONROOT=1
  28. @@ -121,6 +128,7 @@ if [ "${NONROOT:-}" ]; then
  29. mkdir "$PGSYSCONFDIR" "$WORKDIR/log"
  30. PWFILE="$PGSYSCONFDIR/pwfile"
  31. LOGDIR="$WORKDIR/log"
  32. + echo "$PGPASSWORD" > "$PWFILE"
  33. cleanup () {
  34. set +e
  35. @@ -150,6 +158,7 @@ else
  36. export PGUSER="postgres"
  37. PWFILE=$(mktemp -t pgpassword.XXXXXX)
  38. + echo "$PGPASSWORD" > "$PWFILE" # write password before chowning the file
  39. chown postgres:postgres "$PWFILE"
  40. cleanup () {
  41. @@ -175,13 +184,6 @@ else
  42. fi
  43. # create postgres environments
  44. -if [ -x /usr/bin/pwgen ]; then
  45. - export PGPASSWORD=$(pwgen 20 1)
  46. -else
  47. - export PGPASSWORD=$(dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum - | awk '{ print $1 }')
  48. -fi
  49. -echo "$PGPASSWORD" > "$PWFILE"
  50. -
  51. for v in $PG_VERSIONS; do
  52. # create temporary cluster
  53. # we chdir to / so programs don't throw "could not change directory to ..."
  54. --
  55. 2.35.1