Content-Length: 407958 | pFad | http://github.com/tonybelloni/postgres/commit/af7211e92dc2bba66f90de9e5bea6ae5fa914c61

3A passwordcheck: Add test suite · tonybelloni/postgres@af7211e · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit af7211e

Browse files
committedSep 15, 2017
passwordcheck: Add test suite
Also improve one error message. Reviewed-by: David Steele <david@pgmasters.net>
1 parent 8423bf4 commit af7211e

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed
 

‎contrib/passwordcheck/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated subdirectories
2+
/log/
3+
/results/
4+
/tmp_check/

‎contrib/passwordcheck/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ PGFILEDESC = "passwordcheck - strengthen user password checks"
88
# PG_CPPFLAGS = -DUSE_CRACKLIB '-DCRACKLIB_DICTPATH="/usr/lib/cracklib_dict"'
99
# SHLIB_LINK = -lcrack
1010

11+
REGRESS_OPTS = --temp-config $(srcdir)/passwordcheck.conf
12+
REGRESS = passwordcheck
13+
# disabled because these tests require setting shared_preload_libraries
14+
NO_INSTALLCHECK = 1
15+
1116
ifdef USE_PGXS
1217
PG_CONFIG = pg_config
1318
PGXS := $(shell $(PG_CONFIG) --pgxs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE USER regress_user1;
2+
-- ok
3+
ALTER USER regress_user1 PASSWORD 'a_nice_long_password';
4+
-- error: too short
5+
ALTER USER regress_user1 PASSWORD 'tooshrt';
6+
ERROR: password is too short
7+
-- error: contains user name
8+
ALTER USER regress_user1 PASSWORD 'xyzregress_user1';
9+
ERROR: password must not contain user name
10+
-- error: contains only letters
11+
ALTER USER regress_user1 PASSWORD 'alessnicelongpassword';
12+
ERROR: password must contain both letters and nonletters
13+
-- encrypted ok (password is "secret")
14+
ALTER USER regress_user1 PASSWORD 'md51a44d829a20a23eac686d9f0d258af13';
15+
-- error: password is user name
16+
ALTER USER regress_user1 PASSWORD 'md5e589150ae7d28f93333afae92b36ef48';
17+
ERROR: password must not equal user name
18+
DROP USER regress_user1;

‎contrib/passwordcheck/passwordcheck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ check_password(const char *username,
7070
if (plain_crypt_verify(username, shadow_pass, username, &logdetail) == STATUS_OK)
7171
ereport(ERROR,
7272
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
73-
errmsg("password must not contain user name")));
73+
errmsg("password must not equal user name")));
7474
}
7575
else
7676
{
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shared_preload_libraries = 'passwordcheck'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATE USER regress_user1;
2+
3+
-- ok
4+
ALTER USER regress_user1 PASSWORD 'a_nice_long_password';
5+
6+
-- error: too short
7+
ALTER USER regress_user1 PASSWORD 'tooshrt';
8+
9+
-- error: contains user name
10+
ALTER USER regress_user1 PASSWORD 'xyzregress_user1';
11+
12+
-- error: contains only letters
13+
ALTER USER regress_user1 PASSWORD 'alessnicelongpassword';
14+
15+
-- encrypted ok (password is "secret")
16+
ALTER USER regress_user1 PASSWORD 'md51a44d829a20a23eac686d9f0d258af13';
17+
18+
-- error: password is user name
19+
ALTER USER regress_user1 PASSWORD 'md5e589150ae7d28f93333afae92b36ef48';
20+
21+
DROP USER regress_user1;

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/af7211e92dc2bba66f90de9e5bea6ae5fa914c61

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy