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

Commitc6e7baa

Browse files
committed
pg_passwd cleanup
1 parentf8fda03 commitc6e7baa

File tree

5 files changed

+207
-71
lines changed

5 files changed

+207
-71
lines changed

‎README

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,3 @@
1-
The pathces and a prototype tool to manipulate the ``flat password file
2-
'' functionality of PostgreSQL6.1
3-
1. File
4-
Makefile
5-
pg_passwd.c the source file of the tool.
6-
2. How to specify pasword files and their format.
7-
Specify the password file in the same style of Ident authentication in
8-
$PGDATA/pg_hba.conf
9-
host unv 133.65.96.250 255.255.255.255 password passwd
10-
The above line allows access from 133.65.96.250 using the passwords listed
11-
in $PGDATA/passwd.
12-
The format of the password files follows those of /etc/passwd and
13-
/etc/shadow: the first field is the user name, and the second field
14-
is the encrypted password. The rest is completely ignored. Thus
15-
the following three sample lines specify the same user and password pair:.
16-
pg_guest:/nB7.w5Auq.BY:10031::::::
17-
pg_guest:/nB7.w5Auq.BY:93001:930::/home/guest:/bin/tcsh
18-
pg_guest:/nB7.w5Auq.BY:93001
19-
Note that the original src/backend/libpq/password.c has a bug, which
20-
disallows the first and the second format. If you want to use these
21-
formats, please make sure you've applied the patch accompanied with
22-
this tool.
23-
3. Usage of pg_passwd
24-
Supply the password file to the pg_passwd command. In the case described
25-
above, after ``cd'ing to $PGDATA, the following command execution specify
26-
the new password for pg_guest:
27-
% pg_passwd passwd
28-
Username: pg_guest
29-
Password:
30-
Re-enter password:
31-
where the Password: and Re-enter password: prompts require the same
32-
password input which are not displayed on the terminal.
33-
The original password file is renamed to ``passwd.bk''.
34-
4. How to specify pasasword authentication
35-
You can use the password authentication fro psq, perl, or pg{tcl,tk}sh.
36-
4.1 psql
37-
Use the -u option. Note that the original distribution includes a bug.
38-
Please make sure you've applied the patch distributed with this tool.
39-
The following lines show the sample usage of the option:
40-
% psql -h hyalos -u unv
41-
Username: pg_guest
42-
Password:
43-
Welcome to the POSTGRESQL interactive sql monitor:
44-
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
45-
type \? for help on slash commands
46-
type \q to quit
47-
type \g or terminate with semicolon to execute query
48-
You are currently connected to the database: unv
49-
unv=>
50-
4.2 perl5
51-
Use the new style of the Pg.pm like this
52-
$conn = Pg::connectdb("host=hyalos authtype=password dbname=unv
53-
user=pg_guest password=xxxxxxx");
54-
For more details, the users refer to to ``src/pgsql_perl5/Pg.pm''.
55-
4.3 pg{tcl,tk}sh
56-
Use the pg_connect comamnd with -conninfo option thus
57-
% set conn [pg_connect -conninfo \
58-
"host=hyalos authtype=password dbname=unv \
59-
user=pg_guest password=xxxxxxx "]
60-
Use can list all of the keys for the option by executing the following
61-
command:
62-
% puts [ pg_conndefaults]
63-
5. Acknowledgment
64-
Mr. Ishii, SRA, pointed out the original bugs in the tool. He also
65-
supplied the Makefile for this distribution.
66-
-------------------------------------------------------------------------
67-
July 2, 1997
68-
Yoshihiko Ichikawa, Dept of Info Sci, Fac of Sci, Ochanomizu University
69-
E-mail: ichikawa@is.ocha.ac.jp
701

712
PostgreSQL Data Base Management System (formerly known as Postgres, then
723
as Postgres95).

‎src/bin/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.8 1997/08/25 19:41:39 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.9 1997/08/25 19:59:52 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -21,7 +21,7 @@
2121
$(MAKE) -C pg_version $@
2222
$(MAKE) -C psql $@
2323
$(MAKE) -C pg_dump $@
24-
$(MAKE) -C pg_passwd $@
24+
$(MAKE) -C pg_passwd $@
2525
#
2626
# Shell scripts
2727
#

‎src/bin/pg_passwd/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile
4+
# Makefile for bin/pg_passwd
5+
#-------------------------------------------------------------------------
6+
SRCDIR= ../..
7+
include ../../Makefile.global
8+
OBJS= pg_passwd.o
9+
all: pg_passwd
10+
pg_passwd:$(OBJS)
11+
$(CC) -o pg_passwd $(OBJS) $(LDFLAGS)
12+
install: pg_passwd
13+
$(INSTALL) $(INSTL_EXE_OPTS) pg_passwd $(DESTDIR)$(BINDIR)/pg_passwd
14+
dependdep:
15+
$(CC) -MM $(INCLUDE_OPT) *.c >depend
16+
clean:
17+
rm -f pg_passwd $(OBJS)
18+
ifeq (depend,$(wildcard depend))
19+
include depend
20+
endif

‎src/bin/pg_passwd/README

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
The pathces and a prototype tool to manipulate the ``flat password file
2+
'' functionality of PostgreSQL6.1
3+
1. File
4+
Makefile
5+
pg_passwd.c the source file of the tool.
6+
2. How to specify pasword files and their format.
7+
Specify the password file in the same style of Ident authentication in
8+
$PGDATA/pg_hba.conf
9+
host unv 133.65.96.250 255.255.255.255 password passwd
10+
The above line allows access from 133.65.96.250 using the passwords listed
11+
in $PGDATA/passwd.
12+
The format of the password files follows those of /etc/passwd and
13+
/etc/shadow: the first field is the user name, and the second field
14+
is the encrypted password. The rest is completely ignored. Thus
15+
the following three sample lines specify the same user and password pair:.
16+
pg_guest:/nB7.w5Auq.BY:10031::::::
17+
pg_guest:/nB7.w5Auq.BY:93001:930::/home/guest:/bin/tcsh
18+
pg_guest:/nB7.w5Auq.BY:93001
19+
Note that the original src/backend/libpq/password.c has a bug, which
20+
disallows the first and the second format. If you want to use these
21+
formats, please make sure you've applied the patch accompanied with
22+
this tool.
23+
3. Usage of pg_passwd
24+
Supply the password file to the pg_passwd command. In the case described
25+
above, after ``cd'ing to $PGDATA, the following command execution specify
26+
the new password for pg_guest:
27+
% pg_passwd passwd
28+
Username: pg_guest
29+
Password:
30+
Re-enter password:
31+
where the Password: and Re-enter password: prompts require the same
32+
password input which are not displayed on the terminal.
33+
The original password file is renamed to ``passwd.bk''.
34+
4. How to specify pasasword authentication
35+
You can use the password authentication fro psq, perl, or pg{tcl,tk}sh.
36+
4.1 psql
37+
Use the -u option. Note that the original distribution includes a bug.
38+
Please make sure you've applied the patch distributed with this tool.
39+
The following lines show the sample usage of the option:
40+
% psql -h hyalos -u unv
41+
Username: pg_guest
42+
Password:
43+
Welcome to the POSTGRESQL interactive sql monitor:
44+
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
45+
type \? for help on slash commands
46+
type \q to quit
47+
type \g or terminate with semicolon to execute query
48+
You are currently connected to the database: unv
49+
unv=>
50+
4.2 perl5
51+
Use the new style of the Pg.pm like this
52+
$conn = Pg::connectdb("host=hyalos authtype=password dbname=unv
53+
user=pg_guest password=xxxxxxx");
54+
For more details, the users refer to to ``src/pgsql_perl5/Pg.pm''.
55+
4.3 pg{tcl,tk}sh
56+
Use the pg_connect comamnd with -conninfo option thus
57+
% set conn [pg_connect -conninfo \
58+
"host=hyalos authtype=password dbname=unv \
59+
user=pg_guest password=xxxxxxx "]
60+
Use can list all of the keys for the option by executing the following
61+
command:
62+
% puts [ pg_conndefaults]
63+
5. Acknowledgment
64+
Mr. Ishii, SRA, pointed out the original bugs in the tool. He also
65+
supplied the Makefile for this distribution.
66+
-------------------------------------------------------------------------
67+
July 2, 1997
68+
Yoshihiko Ichikawa, Dept of Info Sci, Fac of Sci, Ochanomizu University
69+
E-mail: ichikawa@is.ocha.ac.jp
70+
71+
PostgreSQL Data Base Management System (formerly known as Postgres, then
72+
as Postgres95).
73+
74+
This directory contains the version 6.1 release of the PostgreSQL
75+
database server. The server is not ANSI SQL compliant, but it gets
76+
closer with every release. After you unzip and untar the distribution
77+
file, look at file INSTALL for the installation notes and file HISTORY
78+
for the changes.
79+
80+
The latest version of this software may be obtained at
81+
ftp://ftp.postgresql.org/pub/. For more information look at our WWW
82+
home page located at http://www.postgreSQL.org/.
83+
84+
PostgreSQL is not public domain software. It is copyrighted by the
85+
University of California but may be used according to the licensing
86+
terms of the the copyright below:
87+
88+
------------------------------------------------------------------------
89+
90+
POSTGRES95 Data Base Management System (formerly known as Postgres, then
91+
as Postgres95).
92+
93+
Copyright (c) 1994-7 Regents of the University of California
94+
95+
Permission to use, copy, modify, and distribute this software and its
96+
documentation for any purpose, without fee, and without a written agreement
97+
is hereby granted, provided that the above copyright notice and this
98+
paragraph and the following two paragraphs appear in all copies.
99+
100+
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
101+
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
102+
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
103+
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
104+
POSSIBILITY OF SUCH DAMAGE.
105+
106+
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
107+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
108+
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
109+
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
110+
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
111+

‎src/bin/pg_passwd/pg_passwd.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* @(#) pg_passwd.c 1.8 09:13:16 97/07/02 Y. Ichikawa
3+
*/
4+
#include<stdio.h>
5+
#include<stdlib.h>
6+
#include<string.h>
7+
#include<strings.h>
8+
#include<unistd.h>
9+
#include<errno.h>
10+
#include<sys/time.h>
11+
#include<ctype.h>
12+
#defineissaltchar(c) (isalnum(c) || (c) == '.' || (c) == '/')
13+
#include"postgres.h"
14+
#ifdefHAVE_TERMIOS_H
15+
#include<termios.h>
16+
#endif
17+
#ifdefHAVE_CRYPT_H
18+
#include<crypt.h>
19+
#else
20+
externchar*crypt(constchar*,constchar*);
21+
#endif
22+
char*comname;
23+
voidusage(FILE*stream);
24+
voidread_pwd_file(char*filename);
25+
voidwrite_pwd_file(char*filename,char*bkname);
26+
voidencrypt_pwd(charkey[9],charsalt[3],charpasswd[14]);
27+
intcheck_pwd(charkey[9],charpasswd[14]);
28+
voidprompt_for_username(char*username);
29+
voidprompt_for_password(char*prompt,char*password);
30+
voidusage(FILE*stream)
31+
{
32+
fprintf(stream,"Usage: %s <password file>\n",comname);
33+
}
34+
typedefstruct {
35+
char*uname;
36+
char*pwd;
37+
char*rest;
38+
}pg_pwd;
39+
#defineMAXPWDS 1024
40+
pg_pwdpwds[MAXPWDS];
41+
intnpwds=0;
42+
voidread_pwd_file(char*filename)
43+
{
44+
FILE*fp;
45+
staticcharline[512];
46+
staticcharans[128];
47+
inti;
48+
try_again:
49+
fp=fopen(filename,"r");
50+
if (fp==NULL) {
51+
if (errno==ENOENT) {
52+
printf("File \"%s\" does not exist. Create? (y/n): ",filename);
53+
fflush(stdout);
54+
fgets(ans,128,stdin);
55+
switch (ans[0]) {
56+
case'y':case'Y':
57+
fp=fopen(filename,"w");
58+
if (fp==NULL) {
59+
perror(filename);
60+
exit(1);
61+
}
62+
fclose(fp);
63+
gototry_again;
64+
default:
65+
/* cannot continue */
66+
exit(1);
67+
}
68+
}else {
69+
perror(filename);
70+
exit(1);
71+
}
72+
}
73+
/* read all the entries */
74+
for (npwds=0;npwds<MAXPWDS&&fgets(line,512,fp)!=NULL;++npwds)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp