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

Commitf8fda03

Browse files
committed
pg_password utility. Cleanup for psql passwords. New datetime contrib stuff for new version. Fix for strutils needing config.h.
1 parent8d0e658 commitf8fda03

File tree

8 files changed

+183
-149
lines changed

8 files changed

+183
-149
lines changed

‎README

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
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
170

271
PostgreSQL Data Base Management System (formerly known as Postgres, then
372
as Postgres95).

‎contrib/datetime/datetime_functions.c

Lines changed: 47 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -9,139 +9,90 @@
99
#include<time.h>
1010

1111
#include"postgres.h"
12-
#include"pg_type.h"
1312
#include"utils/palloc.h"
13+
#include"utils/datetime.h"
1414

15-
typedefstructDateADT {
16-
charday;
17-
charmonth;
18-
shortyear;
19-
}DateADT;
2015

21-
typedefstructTimeADT {
22-
shorthr;
23-
shortmin;
24-
floatsec;
25-
}TimeADT;
26-
27-
TimeADT*
28-
time_difference(TimeADT*time1,TimeADT*time2)
16+
TimeADT*time_difference(TimeADT*time1,TimeADT*time2)
2917
{
30-
TimeADT*time= (TimeADT*)palloc(sizeof(TimeADT));
31-
32-
time->sec=time1->sec-time2->sec;
33-
time->min=time1->min-time2->min;
34-
time->hr=time1->hr-time2->hr;
35-
36-
if (time->sec<0) {
37-
time->sec+=60.0;
38-
time->min--;
39-
}elseif (time->sec >=60.0) {
40-
time->sec-=60.0;
41-
time->min++;
42-
}
43-
44-
if (time->min<0) {
45-
time->min+=60;
46-
time->hr--;
47-
}elseif (time->min >=60) {
48-
time->min-=60;
49-
time->hr++;
50-
}
51-
52-
if (time->hr<0) {
53-
time->hr+=24;
54-
}elseif (time->hr >=24) {
55-
time->hr-=24;
56-
}
57-
58-
return (time);
18+
TimeADT*result= (TimeADT*)palloc(sizeof(TimeADT));
19+
*result=*time1-*time2;
20+
return (result);
5921
}
6022

61-
TimeADT*
62-
currentTime()
23+
TimeADT*currenttime()
6324
{
6425
time_tcurrent_time;
6526
structtm*tm;
66-
TimeADT*result= (TimeADT*)palloc(sizeof(TimeADT));
27+
TimeADT*result= (TimeADT*)palloc(sizeof(TimeADT));
6728

6829
current_time=time(NULL);
6930
tm=localtime(&current_time);
70-
result->sec=tm->tm_sec;
71-
result->min=tm->tm_min;
72-
result->hr=tm->tm_hour;
73-
31+
*result= ((((tm->tm_hour*60)+tm->tm_min)*60)+tm->tm_sec);
7432
return (result);
7533
}
76-
77-
int4
78-
currentDate()
34+
DateADTcurrentdate()
7935
{
8036
time_tcurrent_time;
8137
structtm*tm;
82-
int4result;
83-
DateADT*date= (DateADT*)&result;
84-
38+
DateADTresult;
8539
current_time=time(NULL);
8640
tm=localtime(&current_time);
87-
date->day=tm->tm_mday;
88-
date->month=tm->tm_mon+1;
89-
date->year=tm->tm_year+1900;
9041

42+
result=date2j(tm->tm_year,tm->tm_mon+1,tm->tm_mday)-
43+
date2j(100,1,1);
9144
return (result);
9245
}
93-
94-
int4
95-
hours(TimeADT*time)
46+
int4hours(TimeADT*time)
9647
{
97-
return (time->hr);
48+
return(*time / (60*60));
9849
}
9950

100-
int4
101-
minutes(TimeADT*time)
51+
int4minutes(TimeADT*time)
10252
{
103-
return (time->min);
53+
return(((int) (*time /60)) %60);
10454
}
10555

106-
int4
107-
seconds(TimeADT*time)
56+
int4seconds(TimeADT*time)
10857
{
109-
intseconds= (int)time->sec;
110-
return (seconds);
58+
return(((int)*time) %60);
11159
}
112-
113-
int4
114-
day(int4val)
60+
int4day(DateADT*date)
11561
{
116-
DateADT*date= (DateADT*)&val;
117-
return (date->day);
118-
}
62+
structtmtm;
11963

120-
int4
121-
month(int4val)
122-
{
123-
DateADT*date= (DateADT*)&val;
124-
return (date->month);
125-
}
64+
j2date( (*date+date2j(2000,1,1)),
65+
&tm.tm_year,&tm.tm_mon,&tm.tm_mday);
12666

127-
int4
128-
year(int4val)
129-
{
130-
DateADT*date= (DateADT*)&val;
131-
return (date->year);
67+
return (tm.tm_mday);
13268
}
133-
134-
int4
135-
asMinutes(TimeADT*time)
69+
int4month(DateADT*date)
13670
{
137-
intseconds= (int)time->sec;
138-
return (time->min+60*time->hr);
71+
structtmtm;
72+
73+
j2date( (*date+date2j(2000,1,1)),
74+
&tm.tm_year,&tm.tm_mon,&tm.tm_mday);
75+
76+
return (tm.tm_mon);
13977
}
78+
int4year(DateADT*date)
79+
{
80+
structtmtm;
81+
82+
j2date( (*date+date2j(2000,1,1)),
83+
&tm.tm_year,&tm.tm_mon,&tm.tm_mday);
14084

141-
int4
142-
asSeconds(TimeADT*time)
85+
return (tm.tm_year);
86+
}
87+
int4asminutes(TimeADT*time)
14388
{
144-
intseconds= (int)time->sec;
145-
return (seconds+60*time->min+3600*time->hr);
89+
intseconds= (int)*time;
90+
91+
return (seconds /60);
14692
}
93+
int4asseconds(TimeADT*time)
94+
{
95+
intseconds= (int)*time;
14796

97+
return (seconds);
98+
}
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
From: Massimo Dal Zotto <dz@cs.unitn.it>
2-
Date: Tue, 14 May 1996 14:31:18 +0200 (MET DST)
3-
Subject: [PG95]: new postgres functions
4-
5-
- -----BEGIN PGP SIGNED MESSAGE-----
6-
7-
Some time ago I read in the mailing list requests of people looking
8-
for more time and date functions. I have now written some of them:
9-
10-
time_difference(time1, time2) ,also defined as operator '-'
11-
hour(time)
12-
minutes(time)
13-
seconds(time)
14-
asMinutes(time)
15-
asSeconds(time)
16-
currentTime()
17-
currentDate()
18-
19-
The file can be compiled as shared library and loaded as dynamic module
20-
without need to recompile the backend. This can also be taken as an example
21-
of the extensibility of postgres (user-defined functions, operators, etc).
22-
I would be nice to see more of these user contributed modules posted to this
23-
list and hopefully accessible from the Postgres home page.
1+
Date & time functions for use in Postgres version 6.1 & up
2+
3+
This functions replaces the original ones from the postgresql.org
4+
because the date & time structures has changed.
5+
6+
There is a Makefile that should be "ajusted"
7+
for directories where postgres home after install.
8+
9+
In this case: /usr/postgres.
10+
11+
Hope this can help,
12+
13+
14+
Sergio Lenzi (lenzi@bsi.com.br)
2415

2516

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,75 @@
1-
2-
-- SQL code to load and define 'datetime' functions
3-
4-
-- load the new functions
5-
6-
load'/home/dz/lib/postgres/datetime_functions.so';
7-
8-
-- define the new functions in postgres
1+
func=$1
2+
cat<<%>datetime_functions.sql
3+
dropfunction time_difference(time,time);
4+
dropfunction currentdate();
5+
dropfunction currenttime();
6+
dropfunction hours(time);
7+
dropfunction minutes(time);
8+
dropfunction seconds(time);
9+
dropfunction day(date);
10+
dropfunction month(date);
11+
dropfunction year(date);
12+
dropfunction asminutes(time);
13+
dropfunction asseconds(time);
14+
dropoperator- (time,time);
915

1016
createfunctiontime_difference(time,time)
1117
returnstime
12-
as'/home/dz/lib/postgres/datetime_functions.so'
18+
as'$func'
1319
language'c';
1420

15-
createfunctioncurrentDate()
21+
createfunctioncurrentdate()
1622
returnsdate
17-
as'/home/dz/lib/postgres/datetime_functions.so'
23+
as'$func'
1824
language'c';
1925

20-
createfunctioncurrentTime()
26+
createfunctioncurrenttime()
2127
returnstime
22-
as'/home/dz/lib/postgres/datetime_functions.so'
28+
as'$func'
2329
language'c';
2430

2531
createfunctionhours(time)
2632
returns int4
27-
as'/home/dz/lib/postgres/datetime_functions.so'
33+
as'$func'
2834
language'c';
2935

3036
createfunctionminutes(time)
3137
returns int4
32-
as'/home/dz/lib/postgres/datetime_functions.so'
38+
as'$func'
3339
language'c';
3440

3541
createfunctionseconds(time)
3642
returns int4
37-
as'/home/dz/lib/postgres/datetime_functions.so'
43+
as'$func'
3844
language'c';
3945

4046
createfunctionday(date)
4147
returns int4
42-
as'/home/dz/lib/postgres/datetime_functions.so'
48+
as'$func'
4349
language'c';
4450

4551
createfunctionmonth(date)
4652
returns int4
47-
as'/home/dz/lib/postgres/datetime_functions.so'
53+
as'$func'
4854
language'c';
4955

5056
createfunctionyear(date)
5157
returns int4
52-
as'/home/dz/lib/postgres/datetime_functions.so'
58+
as'$func'
5359
language'c';
5460

55-
createfunctionasMinutes(time)
61+
createfunctionasminutes(time)
5662
returns int4
57-
as'/home/dz/lib/postgres/datetime_functions.so'
63+
as'$func'
5864
language'c';
5965

60-
createfunctionasSeconds(time)
66+
createfunctionasseconds(time)
6167
returns int4
62-
as'/home/dz/lib/postgres/datetime_functions.so'
68+
as'$func'
6369
language'c';
6470

6571
create operator- (
6672
leftarg=time,
6773
rightarg=time,
6874
procedure=time_difference);
69-
75+
%

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp