summaryrefslogtreecommitdiff
path: root/src/bin/scripts
diff options
context:
space:
mode:
authorBruce Momjian2000-11-13 15:18:15 +0000
committerBruce Momjian2000-11-13 15:18:15 +0000
commit2150c2edf184f4e1a136b235e36b96c1e7fdfd60 (patch)
tree5f043f8b1f668e74c92e9095adb62f287fe46094 /src/bin/scripts
parent7633cada54aad935b16410c6ebc3a1ee8e606033 (diff)
UUNET is looking into offering PostgreSQL as a part of a managed web
hosting product, on both shared and dedicated machines. We currently offer Oracle and MySQL, and it would be a nice middle-ground. However, as shipped, PostgreSQL lacks the following features we need that MySQL has: 1. The ability to listen only on a particular IP address. Each hosting customer has their own IP address, on which all of their servers (http, ftp, real media, etc.) run. 2. The ability to place the Unix-domain socket in a mode 700 directory. This allows us to automatically create an empty database, with an empty DBA password, for new or upgrading customers without having to interactively set a DBA password and communicate it to (or from) the customer. This in turn cuts down our install and upgrade times. 3. The ability to connect to the Unix-domain socket from within a change-rooted environment. We run CGI programs chrooted to the user's home directory, which is another reason why we need to be able to specify where the Unix-domain socket is, instead of /tmp. 4. The ability to, if run as root, open a pid file in /var/run as root, and then setuid to the desired user. (mysqld -u can almost do this; I had to patch it, too). The patch below fixes problem 1-3. I plan to address #4, also, but haven't done so yet. These diffs are big enough that they should give the PG development team something to think about in the meantime :-) Also, I'm about to leave for 2 weeks' vacation, so I thought I'd get out what I have, which works (for the problems it tackles), now. With these changes, we can set up and run PostgreSQL with scripts the same way we can with apache or proftpd or mysql. In summary, this patch makes the following enhancements: 1. Adds an environment variable PGUNIXSOCKET, analogous to MYSQL_UNIX_PORT, and command line options -k --unix-socket to the relevant programs. 2. Adds a -h option to postmaster to set the hostname or IP address to listen on instead of the default INADDR_ANY. 3. Extends some library interfaces to support the above. 4. Fixes a few memory leaks in PQconnectdb(). The default behavior is unchanged from stock 7.0.2; if you don't use any of these new features, they don't change the operation. David J. MacKenzie
Diffstat (limited to 'src/bin/scripts')
-rw-r--r--src/bin/scripts/createdb12
-rw-r--r--src/bin/scripts/createlang.sh12
-rw-r--r--src/bin/scripts/createuser12
-rw-r--r--src/bin/scripts/dropdb12
-rw-r--r--src/bin/scripts/droplang12
-rw-r--r--src/bin/scripts/dropuser12
-rw-r--r--src/bin/scripts/vacuumdb12
7 files changed, 77 insertions, 7 deletions
diff --git a/src/bin/scripts/createdb b/src/bin/scripts/createdb
index 3601811b249..213913ba890 100644
--- a/src/bin/scripts/createdb
+++ b/src/bin/scripts/createdb
@@ -11,7 +11,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.9 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.10 2000/11/13 15:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -50,6 +50,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
shift;;
@@ -114,6 +123,7 @@ if [ "$usage" ]; then
echo " -E, --encoding=ENCODING Multibyte encoding for the database"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as"
echo " -W, --password Prompt for password"
echo " -e, --echo Show the query being sent to the backend"
diff --git a/src/bin/scripts/createlang.sh b/src/bin/scripts/createlang.sh
index 4275dc6e93f..c22dcba652f 100644
--- a/src/bin/scripts/createlang.sh
+++ b/src/bin/scripts/createlang.sh
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.17 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.18 2000/11/13 15:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -65,6 +65,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
shift;;
@@ -126,6 +135,7 @@ if [ "$usage" ]; then
echo "Options:"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as"
echo " -W, --password Prompt for password"
echo " -d, --dbname=DBNAME Database to install language in"
diff --git a/src/bin/scripts/createuser b/src/bin/scripts/createuser
index 62c674d99e6..198e4b81cfa 100644
--- a/src/bin/scripts/createuser
+++ b/src/bin/scripts/createuser
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.12 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.13 2000/11/13 15:18:14 momjian Exp $
#
# Note - this should NOT be setuid.
#
@@ -63,6 +63,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
# Note: These two specify the user to connect as (like in psql),
# not the user you're creating.
--username|-U)
@@ -135,6 +144,7 @@ if [ "$usage" ]; then
echo " -P, --pwprompt Assign a password to new user"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as (not the one to create)"
echo " -W, --password Prompt for password to connect"
echo " -e, --echo Show the query being sent to the backend"
diff --git a/src/bin/scripts/dropdb b/src/bin/scripts/dropdb
index 1bb6f10f253..586b62ac7f7 100644
--- a/src/bin/scripts/dropdb
+++ b/src/bin/scripts/dropdb
@@ -10,7 +10,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.7 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.8 2000/11/13 15:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -59,6 +59,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
shift;;
@@ -103,6 +112,7 @@ if [ "$usage" ]; then
echo "Options:"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as"
echo " -W, --password Prompt for password"
echo " -i, --interactive Prompt before deleting anything"
diff --git a/src/bin/scripts/droplang b/src/bin/scripts/droplang
index 3205ad35772..46856e4241d 100644
--- a/src/bin/scripts/droplang
+++ b/src/bin/scripts/droplang
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.8 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.9 2000/11/13 15:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -65,6 +65,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
shift;;
@@ -113,6 +122,7 @@ if [ "$usage" ]; then
echo "Options:"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as"
echo " -W, --password Prompt for password"
echo " -d, --dbname=DBNAME Database to remove language from"
diff --git a/src/bin/scripts/dropuser b/src/bin/scripts/dropuser
index 81a00f9c1c8..4aa858124b2 100644
--- a/src/bin/scripts/dropuser
+++ b/src/bin/scripts/dropuser
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.7 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.8 2000/11/13 15:18:14 momjian Exp $
#
# Note - this should NOT be setuid.
#
@@ -59,6 +59,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
# Note: These two specify the user to connect as (like in psql),
# not the user you're dropping.
--username|-U)
@@ -105,6 +114,7 @@ if [ "$usage" ]; then
echo "Options:"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as (not the one to drop)"
echo " -W, --password Prompt for password to connect"
echo " -i, --interactive Prompt before deleting anything"
diff --git a/src/bin/scripts/vacuumdb b/src/bin/scripts/vacuumdb
index af038add8a7..fb1db8bfe67 100644
--- a/src/bin/scripts/vacuumdb
+++ b/src/bin/scripts/vacuumdb
@@ -11,7 +11,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.10 2000/11/11 22:59:48 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.11 2000/11/13 15:18:14 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -52,6 +52,15 @@ do
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
+ --unixsocket|-k)
+ PSQLOPT="$PSQLOPT -k $2"
+ shift;;
+ -k*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --unixsocket=*)
+ PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
+ ;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
shift;;
@@ -121,6 +130,7 @@ if [ "$usage" ]; then
echo "Options:"
echo " -h, --host=HOSTNAME Database server host"
echo " -p, --port=PORT Database server port"
+ echo " -k, --unixsocket=PATH Database server Unix-domain socket name"
echo " -U, --username=USERNAME Username to connect as"
echo " -W, --password Prompt for password"
echo " -d, --dbname=DBNAME Database to vacuum"