Commit 212f7bdf authored by Bruce Momjian's avatar Bruce Momjian

Patch to allow createuser options from the command line.

parent 99a099d4
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/createuser/Attic/Makefile,v 1.8 1998/04/06 16:49:37 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/createuser/Attic/Makefile,v 1.9 1998/08/22 05:19:16 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,8 +15,8 @@ SRCDIR= ../.. ...@@ -15,8 +15,8 @@ SRCDIR= ../..
include ../../Makefile.global include ../../Makefile.global
SEDSCRIPT= \ SEDSCRIPT= \
-e "s^_fUnKy_DASH_N_sTuFf_^$(DASH_N)^g" \ -e "s^PG_OPT_DASH_N_PARAM^$(DASH_N)^g" \
-e "s^_fUnKy_BACKSLASH_C_sTuFf_^$(BACKSLASH_C)^g" -e "s^PG_OPT_BACKSLASH_C_PARAM^$(BACKSLASH_C)^g"
all: createuser all: createuser
......
...@@ -8,13 +8,16 @@ ...@@ -8,13 +8,16 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/createuser/Attic/createuser.sh,v 1.9 1998/02/25 13:08:37 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/createuser/Attic/createuser.sh,v 1.10 1998/08/22 05:19:17 momjian Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename $0` CMDNAME=`basename $0`
SYSID=
CANADDUSER=
CANCREATE=
if [ -z "$USER" ]; then if [ -z "$USER" ]; then
if [ -z "$LOGNAME" ]; then if [ -z "$LOGNAME" ]; then
...@@ -34,6 +37,11 @@ do ...@@ -34,6 +37,11 @@ do
-a) AUTHSYS=$2; shift;; -a) AUTHSYS=$2; shift;;
-h) PGHOST=$2; shift;; -h) PGHOST=$2; shift;;
-p) PGPORT=$2; shift;; -p) PGPORT=$2; shift;;
-d) CANCREATE=t;;
-D) CANCREATE=f;;
-u) CANADDUSER=t;;
-U) CANADDUSER=f;;
-i) SYSID=$2; shift;;
*) NEWUSER=$1;; *) NEWUSER=$1;;
esac esac
shift; shift;
...@@ -96,7 +104,7 @@ fi ...@@ -96,7 +104,7 @@ fi
if [ -z "$NEWUSER" ] if [ -z "$NEWUSER" ]
then then
echo _fUnKy_DASH_N_sTuFf_ "Enter name of user to add ---> _fUnKy_BACKSLASH_C_sTuFf_" echo PG_OPT_DASH_N_PARAM "Enter name of user to add ---> PG_OPT_BACKSLASH_C_PARAM"
read NEWUSER read NEWUSER
fi fi
...@@ -124,7 +132,6 @@ done=0 ...@@ -124,7 +132,6 @@ done=0
while [ $done -ne 1 ] while [ $done -ne 1 ]
do do
SYSID=
DEFSYSID=`pg_id $NEWUSER 2>/dev/null` DEFSYSID=`pg_id $NEWUSER 2>/dev/null`
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
DEFMSG=" or RETURN to use unix user ID: $DEFSYSID" DEFMSG=" or RETURN to use unix user ID: $DEFSYSID"
...@@ -134,31 +141,31 @@ do ...@@ -134,31 +141,31 @@ do
fi fi
while [ -z "$SYSID" ] while [ -z "$SYSID" ]
do do
echo _fUnKy_DASH_N_sTuFf_ "Enter user's postgres ID$DEFMSG -> _fUnKy_BACKSLASH_C_sTuFf_" echo PG_OPT_DASH_N_PARAM "Enter user's postgres ID$DEFMSG -> PG_OPT_BACKSLASH_C_PARAM"
read SYSID read SYSID
[ -z "$SYSID" ] && SYSID=$DEFSYSID; [ -z "$SYSID" ] && SYSID=$DEFSYSID;
SYSIDISNUM=`echo $SYSID | egrep '^[0-9]+$'` SYSIDISNUM=`echo $SYSID | egrep '^[0-9]+$'`
if [ -z "$SYSIDISNUM" ] if [ -z "$SYSIDISNUM" ]
then then
echo "$CMDNAME: the postgres ID must be a number" echo "$CMDNAME: the postgres ID must be a number"
exit 1 SYSID=
fi
QUERY="select usename from pg_user where usesysid = '$SYSID'::int4"
RES=`$PSQL -c "$QUERY" template1`
if [ $? -ne 0 ]
then
echo "$CMDNAME: database access failed."
exit 1
fi
if [ -n "$RES" ]
then
echo
echo "$CMDNAME: $SYSID already belongs to $RES, pick another"
DEFMSG= DEFSYSID= SYSID=
else
done=1
fi fi
done done
QUERY="select usename from pg_user where usesysid = '$SYSID'::int4"
RES=`$PSQL -c "$QUERY" template1`
if [ $? -ne 0 ]
then
echo "$CMDNAME: database access failed."
exit 1
fi
if [ -n "$RES" ]
then
echo
echo "$CMDNAME: $SYSID already belongs to $RES, pick another"
DEFMSG= DEFSYSID= SYSID=
else
done=1
fi
done done
# #
...@@ -168,39 +175,44 @@ done ...@@ -168,39 +175,44 @@ done
# #
# can the user create databases? # can the user create databases?
# #
if [ -z "$CANCREATE" ]
then
yn=f
yn=f while [ "$yn" != y -a "$yn" != n ]
do
while [ "$yn" != y -a "$yn" != n ] echo PG_OPT_DASH_N_PARAM "Is user \"$NEWUSER\" allowed to create databases (y/n) PG_OPT_BACKSLASH_C_PARAM"
do read yn
echo _fUnKy_DASH_N_sTuFf_ "Is user \"$NEWUSER\" allowed to create databases (y/n) _fUnKy_BACKSLASH_C_sTuFf_" done
read yn
done
if [ "$yn" = y ] if [ "$yn" = y ]
then then
CANCREATE=t CANCREATE=t
else else
CANCREATE=f CANCREATE=f
fi
fi fi
# #
# can the user add users? # can the user add users?
# #
yn=f if [ -z "$CANADDUSER" ]
then
yn=f
while [ "$yn" != y -a "$yn" != n ] while [ "$yn" != y -a "$yn" != n ]
do do
echo _fUnKy_DASH_N_sTuFf_ "Is user \"$NEWUSER\" allowed to add users? (y/n) _fUnKy_BACKSLASH_C_sTuFf_" echo PG_OPT_DASH_N_PARAM "Is user \"$NEWUSER\" allowed to add users? (y/n) PG_OPT_BACKSLASH_C_PARAM"
read yn read yn
done done
if (test "$yn" = y) if (test "$yn" = y)
then then
CANADDUSER=t CANADDUSER=t
else else
CANADDUSER=f CANADDUSER=f
fi
fi fi
QUERY="insert into pg_shadow \ QUERY="insert into pg_shadow \
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/Makefile,v 1.8 1998/04/06 16:50:05 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/Makefile,v 1.9 1998/08/22 05:19:19 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,8 +15,8 @@ SRCDIR= ../.. ...@@ -15,8 +15,8 @@ SRCDIR= ../..
include ../../Makefile.global include ../../Makefile.global
SEDSCRIPT= \ SEDSCRIPT= \
-e "s^_fUnKy_DASH_N_sTuFf_^$(DASH_N)^g" \ -e "s^PG_OPT_DASH_N_PARAM^$(DASH_N)^g" \
-e "s^_fUnKy_BACKSLASH_C_sTuFf_^$(BACKSLASH_C)^g" -e "s^PG_OPT_BACKSLASH_C_PARAM^$(BACKSLASH_C)^g"
all: destroyuser all: destroyuser
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/destroyuser.sh,v 1.8 1998/02/25 13:08:55 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/destroyuser.sh,v 1.9 1998/08/22 05:19:21 momjian Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
...@@ -90,7 +90,7 @@ fi ...@@ -90,7 +90,7 @@ fi
if [ -z "$DELUSER" ] if [ -z "$DELUSER" ]
then then
echo _fUnKy_DASH_N_sTuFf_ "Enter name of user to delete ---> _fUnKy_BACKSLASH_C_sTuFf_" echo OPT_DASH_N_PARAM "Enter name of user to delete ---> OPT_BACKSLASH_C_PARAM"
read DELUSER read DELUSER
fi fi
...@@ -154,7 +154,7 @@ then ...@@ -154,7 +154,7 @@ then
yn=f yn=f
while [ $yn != y -a $yn != n ] while [ $yn != y -a $yn != n ]
do do
echo _fUnKy_DASH_N_sTuFf_ "Deleting user $DELUSER will destroy them. Continue (y/n)? _fUnKy_BACKSLASH_C_sTuFf_" echo OPT_DASH_N_PARAM "Deleting user $DELUSER will destroy them. Continue (y/n)? OPT_BACKSLASH_C_PARAM"
read yn read yn
done done
......
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.51 1998/08/21 23:22:36 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.52 1998/08/22 05:19:23 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# ---------------- # ----------------
# The _fUnKy_..._sTuFf_ gets set when the script is built (with make) # The OPT_..._PARAM gets set when the script is built (with make)
# from parameters set in the make file. # from parameters set in the make file.
# #
# ---------------- # ----------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/Makefile,v 1.5 1998/04/06 16:50:30 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/Makefile,v 1.6 1998/08/22 05:19:25 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,8 +15,8 @@ SRCDIR= ../.. ...@@ -15,8 +15,8 @@ SRCDIR= ../..
include ../../Makefile.global include ../../Makefile.global
SEDSCRIPT= \ SEDSCRIPT= \
-e "s^_fUnKy_NAMEDATALEN_sTuFf_^$(NAMEDATALEN)^g" \ -e "s^PG_OPT_NAMEDATALEN_PARAM^$(NAMEDATALEN)^g" \
-e "s^_fUnKy_OIDNAMELEN_sTuFf_^$(OIDNAMELEN)^g" -e "s^PG_OPT_OIDNAMELEN_PARAM^$(OIDNAMELEN)^g"
all: initlocation all: initlocation
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.7 1998/04/06 16:50:36 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.8 1998/08/22 05:19:29 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,7 +15,7 @@ SRCDIR= ../.. ...@@ -15,7 +15,7 @@ SRCDIR= ../..
include ../../Makefile.global include ../../Makefile.global
SEDSCRIPT= \ SEDSCRIPT= \
-e "s^_fUnKy_IPCCLEANPATH_sTuFf_^$(IPCSDIR)^g" -e "s^PG_OPT_IPCCLEANPATH_PARAM^$(IPCSDIR)^g"
all: ipcclean all: ipcclean
......
#!/bin/sh #!/bin/sh
# #
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.1.1.1 1996/07/09 06:22:13 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.2 1998/08/22 05:19:31 momjian Exp $
# #
PATH=_fUnKy_IPCCLEANPATH_sTuFf_:$PATH PATH=PG_OPT_IPCCLEANPATH_PARAM:$PATH
export PATH export PATH
ipcs | egrep '^m .*|^s .*' | egrep "`whoami`|postgres" | \ ipcs | egrep '^m .*|^s .*' | egrep "`whoami`|postgres" | \
awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/createuser.1,v 1.11 1998/07/24 16:44:03 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/createuser.1,v 1.12 1998/08/22 05:19:35 momjian Exp $
.TH CREATEUSER UNIX 11/05/95 PostgreSQL PostgreSQL .TH CREATEUSER UNIX 11/05/95 PostgreSQL PostgreSQL
.SH NAME .SH NAME
createuser - create a Postgres user createuser - create a Postgres user
...@@ -10,11 +10,26 @@ createuser - create a Postgres user ...@@ -10,11 +10,26 @@ createuser - create a Postgres user
.BR -a .BR -a
system] system]
[\c [\c
.BR -d
]
[\c
.BR -D
]
[\c
.BR -h .BR -h
host] host]
[\c [\c
.BR -i
id]
[\c
.BR -p .BR -p
port] port]
[\c
.BR -u
]
[\c
.BR -U
]
[username] [username]
.SH DESCRIPTION .SH DESCRIPTION
.IR Createuser .IR Createuser
...@@ -57,11 +72,22 @@ to use in connecting to the ...@@ -57,11 +72,22 @@ to use in connecting to the
.IR postmaster .IR postmaster
process. This option no longer has any effect. process. This option no longer has any effect.
.TP .TP
.BR "-d"
Allows the user to create databases.
.TP
.BR "-D"
Does not allow the user to create databases.
.TP
.BR "-h" " host" .BR "-h" " host"
Specifies the hostname of the machine on which the Specifies the hostname of the machine on which the
.IR postmaster .IR postmaster
is running. Defaults to using local Unix domain sockets. is running. Defaults to using local Unix domain sockets.
.TP .TP
.BR "-i" " id"
Use
.IR id
as the user id.
.TP
.BR "-p" " port" .BR "-p" " port"
Specifies the TCP/IP port or local Unix domain socket file Specifies the TCP/IP port or local Unix domain socket file
extension on which the extension on which the
...@@ -69,6 +95,12 @@ extension on which the ...@@ -69,6 +95,12 @@ extension on which the
is listening for connections. Defaults to 5432, or the value of the is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT .SM PGPORT
environment variable (if set). environment variable (if set).
.TP
.BR "-u"
Allows the user to create other users.
.TP
.BR "-U"
Does not allow the user to create other users.
.SH "INTERACTIVE QUESTIONS" .SH "INTERACTIVE QUESTIONS"
Once invoked with the above options, Once invoked with the above options,
.IR createuser .IR createuser
...@@ -119,7 +151,3 @@ properly installed Postgres and initialized the site with ...@@ -119,7 +151,3 @@ properly installed Postgres and initialized the site with
.SH NOTE .SH NOTE
The command internally runs \fIcreate user\fP from \fIpsql\fP The command internally runs \fIcreate user\fP from \fIpsql\fP
connected to the \fItemplate1\fP database to perform the operation. connected to the \fItemplate1\fP database to perform the operation.
.SH BUGS
Postgres user-ids and user names should not have anything to do
with the constraints of Unix.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment