Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
0889b174
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0889b174
编写于
3月 14, 1997
作者:
M
Marc G. Fournier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Missing bits from Dan's patches...sorry :(
上级
071484c5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
119 addition
and
0 deletion
+119
-0
src/backend/libpq/password.c
src/backend/libpq/password.c
+107
-0
src/include/libpq/password.h
src/include/libpq/password.h
+12
-0
未找到文件。
src/backend/libpq/password.c
0 → 100644
浏览文件 @
0889b174
#include <postgres.h>
#include <libpq/password.h>
#include <libpq/hba.h>
#include <libpq/libpq.h>
#include <string.h>
#include <unistd.h>
int
verify_password
(
char
*
user
,
char
*
password
,
Port
*
port
,
char
*
database
,
char
*
DataDir
)
{
bool
host_ok
;
enum
Userauth
userauth
;
char
pw_file_name
[
PWFILE_NAME_SIZE
+
1
];
char
*
pw_file_fullname
;
FILE
*
pw_file
;
char
pw_file_line
[
255
];
char
*
p
,
*
test_user
,
*
test_pw
;
char
salt
[
3
];
find_hba_entry
(
DataDir
,
port
->
raddr
.
sin_addr
,
database
,
&
host_ok
,
&
userauth
,
pw_file_name
,
true
);
if
(
!
host_ok
)
{
sprintf
(
PQerrormsg
,
"verify_password: couldn't find entry for connecting host
\n
"
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
if
(
userauth
!=
Password
)
{
sprintf
(
PQerrormsg
,
"verify_password: couldn't find entry of type 'password' "
"for this host
\n
"
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
if
(
!
pw_file_name
||
pw_file_name
[
0
]
==
'\0'
)
{
sprintf
(
PQerrormsg
,
"verify_password: no password file specified
\n
"
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
pw_file_fullname
=
(
char
*
)
malloc
(
strlen
(
DataDir
)
+
strlen
(
pw_file_name
)
+
2
);
strcpy
(
pw_file_fullname
,
DataDir
);
strcat
(
pw_file_fullname
,
"/"
);
strcat
(
pw_file_fullname
,
pw_file_name
);
pw_file
=
fopen
(
pw_file_fullname
,
"r"
);
if
(
!
pw_file
)
{
sprintf
(
PQerrormsg
,
"verify_password: couldn't open password file '%s'
\n
"
,
pw_file_fullname
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
while
(
!
feof
(
pw_file
))
{
fgets
(
pw_file_line
,
255
,
pw_file
);
p
=
pw_file_line
;
test_user
=
strsep
(
&
p
,
":"
);
test_pw
=
p
;
if
(
!
test_user
||
!
test_pw
||
test_user
[
0
]
==
'\0'
||
test_pw
[
0
]
==
'\0'
)
{
continue
;
}
/* kill the newline */
test_pw
[
strlen
(
test_pw
)
-
1
]
=
'\0'
;
strncpy
(
salt
,
test_pw
,
2
);
salt
[
2
]
=
'\0'
;
if
(
strcmp
(
user
,
test_user
)
==
0
)
{
/* we're outta here one way or the other. */
fclose
(
pw_file
);
if
(
strcmp
(
crypt
(
password
,
salt
),
test_pw
)
==
0
)
{
/* it matched. */
return
STATUS_OK
;
}
sprintf
(
PQerrormsg
,
"verify_password: password mismatch for '%s'.
\n
"
,
user
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
}
sprintf
(
PQerrormsg
,
"verify_password: user '%s' not found in password file.
\n
"
,
user
);
fputs
(
PQerrormsg
,
stderr
);
pqdebug
(
"%s"
,
PQerrormsg
);
return
STATUS_ERROR
;
}
src/include/libpq/password.h
0 → 100644
浏览文件 @
0889b174
#ifndef PASSWORD_H
#define PASSWORD_H
#include <libpq/hba.h>
#include <libpq/pqcomm.h>
#define PWFILE_NAME_SIZE USERMAP_NAME_SIZE
int
verify_password
(
char
*
user
,
char
*
password
,
Port
*
port
,
char
*
database
,
char
*
DataDir
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录