Commit 13f88750 authored by Peter Eisentraut's avatar Peter Eisentraut

Added new pg_id to fix initdb problems

New INSTALL file
Fixed a copyright notice
parent a959e3f7
This diff is collapsed.
This diff is collapsed.
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.8 2000/01/18 00:03:34 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.9 2000/01/20 21:50:54 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -28,7 +28,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ] ...@@ -28,7 +28,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
[ --pwprompt|-W ] [ --pwprompt|-W ]
[ --encoding|-E <replaceable class="parameter">encoding</replaceable> ] [ --encoding|-E <replaceable class="parameter">encoding</replaceable> ]
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ] [ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
[ --username|-u <replaceable class="parameter">name</replaceable> ]
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ] [ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
</synopsis> </synopsis>
...@@ -121,20 +120,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ] ...@@ -121,20 +120,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>--username=<replaceable class="parameter">name</replaceable></term>
<term>-u <replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The database system will be initialized with the username that is
running initdb. That is a requirement. If for some unimaginable
reason initdb cannot find out what the current user's name is,
you have to use this option. Normally, this will not be necessary
and initdb will tell you when it is.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>--template</term> <term>--template</term>
<term>-t</term> <term>-t</term>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.48 2000/01/16 20:04:51 petere Exp $ # $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.49 2000/01/20 21:50:56 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -33,7 +33,7 @@ all: ...@@ -33,7 +33,7 @@ all:
echo All of PostgreSQL is successfully made. Ready to install. ;\ echo All of PostgreSQL is successfully made. Ready to install. ;\
fi fi
install: install: installdirs
$(MAKE) -C utils install $(MAKE) -C utils install
$(MAKE) -C backend install $(MAKE) -C backend install
$(MAKE) -C interfaces install $(MAKE) -C interfaces install
...@@ -41,6 +41,9 @@ install: ...@@ -41,6 +41,9 @@ install:
$(MAKE) -C pl install $(MAKE) -C pl install
cat ../register.txt cat ../register.txt
installdirs: mkinstalldirs
$(SRCDIR)/mkinstalldirs $(BINDIR) $(LIBDIR) $(INCLUDEDIR)
clean: clean:
$(MAKE) -C utils clean $(MAKE) -C utils clean
$(MAKE) -C backend clean $(MAKE) -C backend clean
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
* Support routines for external and compressed storage of * Support routines for external and compressed storage of
* variable size attributes. * variable size attributes.
* *
* Copyright (c) 2000, PostgreSQL Development Team * Copyright (c) 2000, PostgreSQL Global Development Group
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.1 1999/12/21 00:06:40 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.2 2000/01/20 21:50:59 petere Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.24 2000/01/19 20:08:23 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.25 2000/01/20 21:51:02 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
SRCDIR= .. SRCDIR= ..
include ../Makefile.global include ../Makefile.global
DIRS = pg_version psql pg_dump pg_passwd \ DIRS = pg_id pg_version psql pg_dump pg_passwd \
scripts initdb initlocation ipcclean \ scripts initdb initlocation ipcclean \
pg_ctl pg_ctl
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.81 2000/01/19 20:08:24 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.82 2000/01/20 21:51:05 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -47,14 +47,7 @@ exit_nicely(){ ...@@ -47,14 +47,7 @@ exit_nicely(){
CMDNAME=`basename $0` CMDNAME=`basename $0`
if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ]
then
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
echo "as the (unprivileged) user that will own the server process."
exit 1
fi
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
if [ "$TMPDIR" ]; then if [ "$TMPDIR" ]; then
TEMPFILE="$TMPDIR/initdb.$$" TEMPFILE="$TMPDIR/initdb.$$"
else else
...@@ -95,7 +88,7 @@ else ...@@ -95,7 +88,7 @@ else
fi fi
# Check if needed programs actually exist in path # Check if needed programs actually exist in path
for prog in postgres pg_version for prog in postgres pg_version pg_id
do do
if [ ! -x "$PGPATH/$prog" ] if [ ! -x "$PGPATH/$prog" ]
then then
...@@ -109,6 +102,22 @@ do ...@@ -109,6 +102,22 @@ do
fi fi
done done
# Gotta wait for pg_id existence check above
EffectiveUser=`$PGPATH/pg_id -n -u`
if [ -z "$EffectiveUser" ]; then
echo "Could not determine current user name. You are really hosed."
exit 1
fi
if [ `$PGPATH/pg_id -u` -eq 0 ]
then
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
echo "as the (unprivileged) user that will own the server process."
exit 1
fi
# 0 is the default (non-)encoding # 0 is the default (non-)encoding
MULTIBYTEID=0 MULTIBYTEID=0
# This is placed here by configure --enable-multibyte[=XXX]. # This is placed here by configure --enable-multibyte[=XXX].
...@@ -124,12 +133,9 @@ template_only=0 ...@@ -124,12 +133,9 @@ template_only=0
# superuser be the same as the Unix user owning the server process: # superuser be the same as the Unix user owning the server process:
# The single user postgres backend will only connect as the database # The single user postgres backend will only connect as the database
# user with the same name as the Unix user running it. That's # user with the same name as the Unix user running it. That's
# a security measure. It might change in the future (why?), but for # a security measure.
# now the --username option is only a fallback if both id and whoami
# fail, and in that case the argument _must_ be the name of the effective
# user.
POSTGRES_SUPERUSERNAME="$EffectiveUser" POSTGRES_SUPERUSERNAME="$EffectiveUser"
POSTGRES_SUPERUSERID="`id -u 2>/dev/null || echo 0`" POSTGRES_SUPERUSERID=`$PGPATH/pg_id -u`
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
...@@ -150,17 +156,7 @@ do ...@@ -150,17 +156,7 @@ do
template_only=1 template_only=1
echo "Updating template1 database only." echo "Updating template1 database only."
;; ;;
# The database superuser. See comments above. # The sysid of the database superuser. Can be freely changed.
--username|-u)
POSTGRES_SUPERUSERNAME="$2"
shift;;
--username=*)
POSTGRES_SUPERUSERNAME=`echo $1 | sed 's/^--username=//'`
;;
-u*)
POSTGRES_SUPERUSERNAME=`echo $1 | sed 's/^-u//'`
;;
# The sysid of the database superuser. See comments above.
--sysid|-i) --sysid|-i)
POSTGRES_SUPERUSERID="$2" POSTGRES_SUPERUSERID="$2"
shift;; shift;;
...@@ -284,21 +280,6 @@ then ...@@ -284,21 +280,6 @@ then
exit 1 exit 1
fi fi
#---------------------------------------------------------------------------
# Figure out who the Postgres superuser for the new database system will be.
#---------------------------------------------------------------------------
# This means they have neither 'id' nor 'whoami'!
if [ -z "$POSTGRES_SUPERUSERNAME" ]
then
echo "$CMDNAME: Could not the determine current username. Please use the -u option."
exit 1
fi
echo "This database system will be initialized with username \"$POSTGRES_SUPERUSERNAME\"."
echo "This user will own all the data files and must also own the server process."
echo
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# Find the input files # Find the input files
...@@ -355,6 +336,10 @@ fi ...@@ -355,6 +336,10 @@ fi
trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15 trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15
# Let's go
echo "This database system will be initialized with username \"$POSTGRES_SUPERUSERNAME\"."
echo "This user will own all the data files and must also own the server process."
echo
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Create the data directory if necessary # Create the data directory if necessary
......
#-------------------------------------------------------------------------
#
# Makefile
# Makefile for bin/pg_id
#
# Copyright (C) 2000 by PostgreSQL Global Development Team
#
# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.14 2000/01/20 21:51:07 petere Exp $
#
#-------------------------------------------------------------------------
SRCDIR= ../..
include ../../Makefile.global
OBJS= pg_id.o
all: pg_id
pg_id: $(OBJS)
$(CC) -o pg_id $(OBJS) $(LDFLAGS)
install: pg_id
$(INSTALL) $(INSTL_EXE_OPTS) pg_id$(X) $(BINDIR)/pg_id
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f pg_id $(OBJS)
ifeq (depend,$(wildcard depend))
include depend
endif
/*
* pg_id.c
*
* A crippled id utility for use in various shell scripts in use by PostgreSQL
* (in particular initdb)
*
* Copyright (C) 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.11 2000/01/20 21:51:07 petere Exp $
*/
#include <c.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char * argv[])
{
int c;
int nameflag = 0,
realflag = 0,
userflag = 0;
const char * username = NULL;
struct passwd * pw;
while ((c = getopt(argc, argv, "nru")) != -1)
{
switch(c)
{
case 'n':
nameflag = 1;
break;
case 'r':
realflag = 1;
break;
case 'u':
userflag = 1;
break;
default:
fprintf(stderr, "Usage: %s [-n] [-r] [-u] [username]\n", argv[0]);
exit(1);
}
}
if (argc - optind >= 1)
username = argv[optind];
if (nameflag && !userflag)
{
fprintf(stderr, "%s: -n must be used together with -u\n", argv[0]);
exit(1);
}
if (username && realflag)
{
fprintf(stderr, "%s: -r cannot be used when a user name is given\n", argv[0]);
exit(1);
}
if (username)
{
pw = getpwnam(username);
if (!pw)
{
fprintf(stderr, "%s: %s: no such user\n", argv[0], username);
exit(1);
}
}
else if (realflag)
pw = getpwuid(getuid());
else
pw = getpwuid(geteuid());
if (!pw)
{
perror(argv[0]);
exit(1);
}
if (!userflag)
printf("uid=%d(%s)\n", (int)pw->pw_uid, pw->pw_name);
else if (nameflag)
puts(pw->pw_name);
else
printf("%d\n", (int)pw->pw_uid);
return 0;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Team * Copyright 2000 by PostgreSQL Global Development Team
* *
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.6 2000/01/18 23:30:23 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.7 2000/01/20 21:51:09 petere Exp $
*/ */
#include <c.h> #include <c.h>
#include "copy.h" #include "copy.h"
...@@ -423,7 +423,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt) ...@@ -423,7 +423,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
if (firstload) if (firstload)
{ {
if (!strcmp(copybuf, "\\.")) if (!strcmp(copybuf, "\\."))
{
copydone = true; copydone = true;
break;
}
firstload = false; firstload = false;
} }
} }
......
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1994-03-25
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
fi
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
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