PostgreSQL Source Code
git master
ldap_password_func.c
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* Copyright (c) 2022, PostgreSQL Global Development Group
4
*
5
* ldap_password_func.c
6
*
7
* Loadable PostgreSQL module to mutate the ldapbindpasswd. This
8
* implementation just hands back the configured password rot13'd.
9
*
10
*-------------------------------------------------------------------------
11
*/
12
13
#include "
postgres.h
"
14
15
#include <
float.h
>
16
#include <stdio.h>
17
18
#include "
libpq/libpq.h
"
19
#include "
libpq/libpq-be.h
"
20
#include "
libpq/auth.h
"
21
#include "
utils/guc.h
"
22
23
PG_MODULE_MAGIC
;
24
25
void
_PG_init
(
void
);
26
void
_PG_fini
(
void
);
27
28
/* hook function */
29
static
char
*
rot13_passphrase
(
char
*
password
);
30
31
/*
32
* Module load callback
33
*/
34
void
35
_PG_init
(
void
)
36
{
37
ldap_password_hook
=
rot13_passphrase
;
38
}
39
40
void
41
_PG_fini
(
void
)
42
{
43
/* do nothing yet */
44
}
45
46
static
char
*
47
rot13_passphrase
(
char
*pw)
48
{
49
size_t
size = strlen(pw) + 1;
50
51
char
*new_pw = (
char
*)
palloc
(size);
52
53
strlcpy
(new_pw, pw, size);
54
for
(
char
*p = new_pw; *p; p++)
55
{
56
char
c
= *p;
57
58
if
((
c
>=
'a'
&&
c
<=
'm'
) || (
c
>=
'A'
&&
c
<=
'M'
))
59
*p =
c
+ 13;
60
else
if
((
c
>=
'n'
&&
c
<=
'z'
) || (
c
>=
'N'
&&
c
<=
'Z'
))
61
*p =
c
- 13;
62
}
63
64
return
new_pw;
65
}
auth.h
ldap_password_hook
PGDLLIMPORT auth_password_hook_typ ldap_password_hook
float.h
guc.h
rot13_passphrase
static char * rot13_passphrase(char *password)
Definition:
ldap_password_func.c:47
_PG_init
void _PG_init(void)
Definition:
ldap_password_func.c:35
PG_MODULE_MAGIC
PG_MODULE_MAGIC
Definition:
ldap_password_func.c:23
_PG_fini
void _PG_fini(void)
Definition:
ldap_password_func.c:41
libpq-be.h
libpq.h
palloc
void * palloc(Size size)
Definition:
mcxt.c:1226
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition:
strlcpy.c:45
postgres.h
c
char * c
Definition:
preproc-cursor.c:31
password
static char * password
Definition:
streamutil.c:53
src
test
modules
ldap_password_func
ldap_password_func.c
Generated on Thu Jun 8 2023 00:13:25 for PostgreSQL Source Code by
1.9.1