1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Added new pg_id to fix initdb problems

New INSTALL file
Fixed a copyright notice
This commit is contained in:
Peter Eisentraut
2000-01-20 21:51:09 +00:00
parent a959e3f7c0
commit 13f8875017
11 changed files with 838 additions and 2722 deletions

View File

@ -7,7 +7,7 @@
#
#
# 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:
echo All of PostgreSQL is successfully made. Ready to install. ;\
fi
install:
install: installdirs
$(MAKE) -C utils install
$(MAKE) -C backend install
$(MAKE) -C interfaces install
@ -41,6 +41,9 @@ install:
$(MAKE) -C pl install
cat ../register.txt
installdirs: mkinstalldirs
$(SRCDIR)/mkinstalldirs $(BINDIR) $(LIBDIR) $(INCLUDEDIR)
clean:
$(MAKE) -C utils clean
$(MAKE) -C backend clean

View File

@ -4,11 +4,11 @@
* Support routines for external and compressed storage of
* variable size attributes.
*
* Copyright (c) 2000, PostgreSQL Development Team
* Copyright (c) 2000, PostgreSQL Global Development Group
*
*
* 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

View File

@ -7,14 +7,14 @@
#
#
# 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= ..
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 \
pg_ctl

View File

@ -26,7 +26,7 @@
#
#
# 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(){
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
TEMPFILE="$TMPDIR/initdb.$$"
else
@ -95,7 +88,7 @@ else
fi
# Check if needed programs actually exist in path
for prog in postgres pg_version
for prog in postgres pg_version pg_id
do
if [ ! -x "$PGPATH/$prog" ]
then
@ -109,6 +102,22 @@ do
fi
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
MULTIBYTEID=0
# This is placed here by configure --enable-multibyte[=XXX].
@ -124,12 +133,9 @@ template_only=0
# superuser be the same as the Unix user owning the server process:
# The single user postgres backend will only connect as the database
# 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
# 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.
# a security measure.
POSTGRES_SUPERUSERNAME="$EffectiveUser"
POSTGRES_SUPERUSERID="`id -u 2>/dev/null || echo 0`"
POSTGRES_SUPERUSERID=`$PGPATH/pg_id -u`
while [ "$#" -gt 0 ]
do
@ -150,17 +156,7 @@ do
template_only=1
echo "Updating template1 database only."
;;
# The database superuser. See comments above.
--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.
# The sysid of the database superuser. Can be freely changed.
--sysid|-i)
POSTGRES_SUPERUSERID="$2"
shift;;
@ -284,21 +280,6 @@ then
exit 1
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
@ -355,6 +336,10 @@ fi
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

33
src/bin/pg_id/Makefile Normal file
View File

@ -0,0 +1,33 @@
#-------------------------------------------------------------------------
#
# 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

91
src/bin/pg_id/pg_id.c Normal file
View File

@ -0,0 +1,91 @@
/*
* 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;
}

View File

@ -3,7 +3,7 @@
*
* 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 "copy.h"
@ -423,7 +423,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
if (firstload)
{
if (!strcmp(copybuf, "\\."))
{
copydone = true;
break;
}
firstload = false;
}
}

36
src/mkinstalldirs Executable file
View File

@ -0,0 +1,36 @@
#! /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