Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13f8875

Browse files
committed
Added new pg_id to fix initdb problems
New INSTALL fileFixed a copyright notice
1 parenta959e3f commit13f8875

File tree

11 files changed

+835
-2719
lines changed

11 files changed

+835
-2719
lines changed

‎INSTALL

Lines changed: 338 additions & 1641 deletions
Large diffs are not rendered by default.

‎doc/src/sgml/install.sgml

Lines changed: 298 additions & 1015 deletions
Large diffs are not rendered by default.

‎doc/src/sgml/ref/initdb.sgml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.8 2000/01/18 00:03:34 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.9 2000/01/20 21:50:54 petere Exp $
33
Postgres documentation
44
-->
55

@@ -28,7 +28,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
2828
[ --pwprompt|-W ]
2929
[ --encoding|-E <replaceable class="parameter">encoding</replaceable> ]
3030
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
31-
[ --username|-u <replaceable class="parameter">name</replaceable> ]
3231
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
3332
</synopsis>
3433

@@ -121,20 +120,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
121120
</listitem>
122121
</varlistentry>
123122

124-
<varlistentry>
125-
<term>--username=<replaceable class="parameter">name</replaceable></term>
126-
<term>-u <replaceable class="parameter">name</replaceable></term>
127-
<listitem>
128-
<para>
129-
The database system will be initialized with the username that is
130-
running initdb. That is a requirement. If for some unimaginable
131-
reason initdb cannot find out what the current user's name is,
132-
you have to use this option. Normally, this will not be necessary
133-
and initdb will tell you when it is.
134-
</para>
135-
</listitem>
136-
</varlistentry>
137-
138123
<varlistentry>
139124
<term>--template</term>
140125
<term>-t</term>

‎src/GNUmakefile.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.48 2000/01/16 20:04:51 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.49 2000/01/20 21:50:56 petere Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -33,14 +33,17 @@ all:
3333
echo All of PostgreSQL is successfully made. Ready to install. ;\
3434
fi
3535

36-
install:
36+
install: installdirs
3737
$(MAKE) -C utils install
3838
$(MAKE) -C backend install
3939
$(MAKE) -C interfaces install
4040
$(MAKE) -C bin install
4141
$(MAKE) -C pl install
4242
cat ../register.txt
4343

44+
installdirs: mkinstalldirs
45+
$(SRCDIR)/mkinstalldirs $(BINDIR) $(LIBDIR) $(INCLUDEDIR)
46+
4447
clean:
4548
$(MAKE) -C utils clean
4649
$(MAKE) -C backend clean

‎src/backend/access/heap/tuptoaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* Support routines for external and compressed storage of
55
* variable size attributes.
66
*
7-
* Copyright (c) 2000, PostgreSQL DevelopmentTeam
7+
* Copyright (c) 2000, PostgreSQLGlobalDevelopmentGroup
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.1 1999/12/21 00:06:40 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.2 2000/01/20 21:50:59 petere Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES

‎src/bin/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.24 2000/01/19 20:08:23 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.25 2000/01/20 21:51:02 petere Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

1414
SRCDIR= ..
1515
include ../Makefile.global
1616

17-
DIRS = pg_version psql pg_dump pg_passwd\
17+
DIRS =pg_idpg_version psql pg_dump pg_passwd\
1818
scripts initdb initlocation ipcclean\
1919
pg_ctl
2020

‎src/bin/initdb/initdb.sh

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.81 2000/01/19 20:08:24 petere Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.82 2000/01/20 21:51:05 petere Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

@@ -47,14 +47,7 @@ exit_nicely(){
4747

4848

4949
CMDNAME=`basename$0`
50-
if ["$USER"='root'-o"$LOGNAME"='root' ]
51-
then
52-
echo"You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"
53-
echo"as the (unprivileged) user that will own the server process."
54-
exit 1
55-
fi
5650

57-
EffectiveUser=`id -n -u2>/dev/null|| whoami2>/dev/null`
5851
if ["$TMPDIR" ];then
5952
TEMPFILE="$TMPDIR/initdb.$$"
6053
else
@@ -95,7 +88,7 @@ else
9588
fi
9689

9790
# Check if needed programs actually exist in path
98-
forprogin postgres pg_version
91+
forprogin postgres pg_version pg_id
9992
do
10093
if [!-x"$PGPATH/$prog" ]
10194
then
@@ -109,6 +102,22 @@ do
109102
fi
110103
done
111104

105+
106+
# Gotta wait for pg_id existence check above
107+
EffectiveUser=`$PGPATH/pg_id -n -u`
108+
if [-z"$EffectiveUser" ];then
109+
echo"Could not determine current user name. You are really hosed."
110+
exit 1
111+
fi
112+
113+
if [`$PGPATH/pg_id -u`-eq 0 ]
114+
then
115+
echo"You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"
116+
echo"as the (unprivileged) user that will own the server process."
117+
exit 1
118+
fi
119+
120+
112121
# 0 is the default (non-)encoding
113122
MULTIBYTEID=0
114123
# This is placed here by configure --enable-multibyte[=XXX].
@@ -124,12 +133,9 @@ template_only=0
124133
# superuser be the same as the Unix user owning the server process:
125134
# The single user postgres backend will only connect as the database
126135
# user with the same name as the Unix user running it. That's
127-
# a security measure. It might change in the future (why?), but for
128-
# now the --username option is only a fallback if both id and whoami
129-
# fail, and in that case the argument _must_ be the name of the effective
130-
# user.
136+
# a security measure.
131137
POSTGRES_SUPERUSERNAME="$EffectiveUser"
132-
POSTGRES_SUPERUSERID="`id -u2>/dev/null||echo 0`"
138+
POSTGRES_SUPERUSERID=`$PGPATH/pg_id -u`
133139

134140
while ["$#"-gt 0 ]
135141
do
@@ -150,17 +156,7 @@ do
150156
template_only=1
151157
echo"Updating template1 database only."
152158
;;
153-
# The database superuser. See comments above.
154-
--username|-u)
155-
POSTGRES_SUPERUSERNAME="$2"
156-
shift;;
157-
--username=*)
158-
POSTGRES_SUPERUSERNAME=`echo$1| sed's/^--username=//'`
159-
;;
160-
-u*)
161-
POSTGRES_SUPERUSERNAME=`echo$1| sed's/^-u//'`
162-
;;
163-
# The sysid of the database superuser. See comments above.
159+
# The sysid of the database superuser. Can be freely changed.
164160
--sysid|-i)
165161
POSTGRES_SUPERUSERID="$2"
166162
shift;;
@@ -284,21 +280,6 @@ then
284280
exit 1
285281
fi
286282

287-
#---------------------------------------------------------------------------
288-
# Figure out who the Postgres superuser for the new database system will be.
289-
#---------------------------------------------------------------------------
290-
291-
# This means they have neither 'id' nor 'whoami'!
292-
if [-z"$POSTGRES_SUPERUSERNAME" ]
293-
then
294-
echo"$CMDNAME: Could not the determine current username. Please use the -u option."
295-
exit 1
296-
fi
297-
298-
echo"This database system will be initialized with username\"$POSTGRES_SUPERUSERNAME\"."
299-
echo"This user will own all the data files and must also own the server process."
300-
echo
301-
302283

303284
#-------------------------------------------------------------------------
304285
# Find the input files
@@ -355,6 +336,10 @@ fi
355336

356337
trap'echo "Caught signal." ; exit_nicely' 1 2 3 15
357338

339+
# Let's go
340+
echo"This database system will be initialized with username\"$POSTGRES_SUPERUSERNAME\"."
341+
echo"This user will own all the data files and must also own the server process."
342+
echo
358343

359344
# -----------------------------------------------------------------------
360345
# Create the data directory if necessary

‎src/bin/pg_id/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile
4+
# Makefile for bin/pg_id
5+
#
6+
# Copyright (C) 2000 by PostgreSQL Global Development Team
7+
#
8+
# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.14 2000/01/20 21:51:07 petere Exp $
9+
#
10+
#-------------------------------------------------------------------------
11+
12+
SRCDIR= ../..
13+
include ../../Makefile.global
14+
15+
OBJS= pg_id.o
16+
17+
all: pg_id
18+
19+
pg_id:$(OBJS)
20+
$(CC) -o pg_id$(OBJS)$(LDFLAGS)
21+
22+
install: pg_id
23+
$(INSTALL)$(INSTL_EXE_OPTS) pg_id$(X)$(BINDIR)/pg_id
24+
25+
dependdep:
26+
$(CC) -MM$(CFLAGS)*.c>depend
27+
28+
clean:
29+
rm -f pg_id$(OBJS)
30+
31+
ifeq (depend,$(wildcard depend))
32+
include depend
33+
endif

‎src/bin/pg_id/pg_id.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* pg_id.c
3+
*
4+
* A crippled id utility for use in various shell scripts in use by PostgreSQL
5+
* (in particular initdb)
6+
*
7+
* Copyright (C) 2000 by PostgreSQL Global Development Group
8+
*
9+
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.11 2000/01/20 21:51:07 petere Exp $
10+
*/
11+
#include<c.h>
12+
13+
#include<pwd.h>
14+
#include<stdio.h>
15+
#include<stdlib.h>
16+
#include<unistd.h>
17+
#include<sys/types.h>
18+
19+
intmain(intargc,char*argv[])
20+
{
21+
intc;
22+
intnameflag=0,
23+
realflag=0,
24+
userflag=0;
25+
constchar*username=NULL;
26+
27+
structpasswd*pw;
28+
29+
while ((c=getopt(argc,argv,"nru"))!=-1)
30+
{
31+
switch(c)
32+
{
33+
case'n':
34+
nameflag=1;
35+
break;
36+
case'r':
37+
realflag=1;
38+
break;
39+
case'u':
40+
userflag=1;
41+
break;
42+
default:
43+
fprintf(stderr,"Usage: %s [-n] [-r] [-u] [username]\n",argv[0]);
44+
exit(1);
45+
}
46+
}
47+
48+
if (argc-optind >=1)
49+
username=argv[optind];
50+
51+
if (nameflag&& !userflag)
52+
{
53+
fprintf(stderr,"%s: -n must be used together with -u\n",argv[0]);
54+
exit(1);
55+
}
56+
if (username&&realflag)
57+
{
58+
fprintf(stderr,"%s: -r cannot be used when a user name is given\n",argv[0]);
59+
exit(1);
60+
}
61+
62+
63+
if (username)
64+
{
65+
pw=getpwnam(username);
66+
if (!pw)
67+
{
68+
fprintf(stderr,"%s: %s: no such user\n",argv[0],username);
69+
exit(1);
70+
}
71+
}
72+
elseif (realflag)
73+
pw=getpwuid(getuid());
74+
else
75+
pw=getpwuid(geteuid());
76+
77+
if (!pw)
78+
{
79+
perror(argv[0]);
80+
exit(1);
81+
}
82+
83+
if (!userflag)
84+
printf("uid=%d(%s)\n", (int)pw->pw_uid,pw->pw_name);
85+
elseif (nameflag)
86+
puts(pw->pw_name);
87+
else
88+
printf("%d\n", (int)pw->pw_uid);
89+
90+
return0;
91+
}

‎src/bin/psql/copy.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Team
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.6 2000/01/18 23:30:23 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.7 2000/01/20 21:51:09 petere Exp $
77
*/
88
#include<c.h>
99
#include"copy.h"
@@ -423,7 +423,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
423423
if (firstload)
424424
{
425425
if (!strcmp(copybuf,"\\."))
426+
{
426427
copydone= true;
428+
break;
429+
}
427430
firstload= false;
428431
}
429432
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp