Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addr pool in rule #550

Merged
merged 153 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
773e068
add address reading
NikitaUnisikhin Dec 1, 2023
1a1b957
add new config for debug
NikitaUnisikhin Dec 4, 2023
6911827
chenge config for makefile
NikitaUnisikhin Dec 4, 2023
d388582
fixes
NikitaUnisikhin Dec 4, 2023
c01311d
fix
NikitaUnisikhin Dec 4, 2023
a704207
fix
NikitaUnisikhin Dec 4, 2023
367a0d0
fix
NikitaUnisikhin Dec 4, 2023
5718198
change config
NikitaUnisikhin Dec 4, 2023
940be0a
fix
NikitaUnisikhin Dec 4, 2023
0354740
fix
NikitaUnisikhin Dec 4, 2023
da5e235
fix
NikitaUnisikhin Dec 4, 2023
841ce12
fix
NikitaUnisikhin Dec 4, 2023
6b79ba2
fix
NikitaUnisikhin Dec 4, 2023
703b076
fix
NikitaUnisikhin Dec 4, 2023
0504b21
add addr in route forward
NikitaUnisikhin Dec 4, 2023
2e95cab
fix
NikitaUnisikhin Dec 4, 2023
46f2a25
fix
NikitaUnisikhin Dec 4, 2023
2e33c6b
change conf
NikitaUnisikhin Dec 5, 2023
05400c9
fix conf
NikitaUnisikhin Dec 5, 2023
f585306
start refactoring, add address.c
NikitaUnisikhin Dec 5, 2023
95db528
fix
NikitaUnisikhin Dec 5, 2023
47b4854
fix
NikitaUnisikhin Dec 5, 2023
a02472f
fix
NikitaUnisikhin Dec 5, 2023
1384a36
fix
NikitaUnisikhin Dec 5, 2023
bfb8f11
fix
NikitaUnisikhin Dec 5, 2023
db6c190
fix
NikitaUnisikhin Dec 5, 2023
50526f2
fix
NikitaUnisikhin Dec 5, 2023
5952663
fix
NikitaUnisikhin Dec 5, 2023
9cc70a0
fix
NikitaUnisikhin Dec 5, 2023
ff135bd
fix
NikitaUnisikhin Dec 5, 2023
900c35a
fix
NikitaUnisikhin Dec 5, 2023
5972473
fix
NikitaUnisikhin Dec 5, 2023
d79cddb
fi
NikitaUnisikhin Dec 5, 2023
4927567
fix
NikitaUnisikhin Dec 5, 2023
53b7585
fix
NikitaUnisikhin Dec 5, 2023
871ba37
fix
NikitaUnisikhin Dec 5, 2023
7cf8401
debug
NikitaUnisikhin Dec 5, 2023
aaee98a
add addr_mask for logs
NikitaUnisikhin Dec 5, 2023
762d20a
fix
NikitaUnisikhin Dec 5, 2023
2047ff9
fix
NikitaUnisikhin Dec 5, 2023
f08e800
fix
NikitaUnisikhin Dec 5, 2023
74c97e6
fix
NikitaUnisikhin Dec 5, 2023
49c6b60
fix
NikitaUnisikhin Dec 5, 2023
b831f34
fix name
NikitaUnisikhin Dec 5, 2023
552263c
start add addr_mask in log
NikitaUnisikhin Dec 5, 2023
e1876e4
fix
NikitaUnisikhin Dec 5, 2023
36fd85c
log added
NikitaUnisikhin Dec 5, 2023
f9f186d
fix
NikitaUnisikhin Dec 5, 2023
e8a9be8
fix
NikitaUnisikhin Dec 5, 2023
1d43de4
fix
NikitaUnisikhin Dec 5, 2023
003985f
fix
NikitaUnisikhin Dec 5, 2023
5dd9cad
fix
NikitaUnisikhin Dec 5, 2023
21efce3
you can not write anything so that the default address value is
NikitaUnisikhin Dec 6, 2023
1f21ee9
fix
NikitaUnisikhin Dec 6, 2023
09d2712
fix
NikitaUnisikhin Dec 6, 2023
8e316ad
fix
NikitaUnisikhin Dec 6, 2023
157da25
add tests for rules with addresses
NikitaUnisikhin Dec 6, 2023
a547f0e
add new conf for debug
NikitaUnisikhin Dec 6, 2023
01cffaa
change config
NikitaUnisikhin Dec 6, 2023
20abd74
fix config
NikitaUnisikhin Dec 7, 2023
0720dbe
fix
NikitaUnisikhin Dec 7, 2023
7c429b5
start fix
NikitaUnisikhin Dec 7, 2023
eec7ebc
fix
NikitaUnisikhin Dec 7, 2023
b896017
fix
NikitaUnisikhin Dec 7, 2023
9fe12b3
fix
NikitaUnisikhin Dec 8, 2023
b54e5b6
start debug
NikitaUnisikhin Dec 8, 2023
082695a
fix config
NikitaUnisikhin Dec 8, 2023
2f290a4
debug
NikitaUnisikhin Dec 8, 2023
8b75b16
fix - removed the address and mask from the route
NikitaUnisikhin Dec 8, 2023
87b210d
fix watchdog
NikitaUnisikhin Dec 8, 2023
2c63aff
change debug config
NikitaUnisikhin Dec 8, 2023
f722387
fix conf
NikitaUnisikhin Dec 8, 2023
266c5ea
fix
NikitaUnisikhin Dec 8, 2023
20564f7
fix
NikitaUnisikhin Dec 8, 2023
15a2efa
fix
NikitaUnisikhin Dec 8, 2023
c854c94
fic
NikitaUnisikhin Dec 8, 2023
47869c0
fix
NikitaUnisikhin Dec 8, 2023
4f64dd6
tests pass
NikitaUnisikhin Dec 8, 2023
84772fd
fixes
NikitaUnisikhin Dec 10, 2023
aab134f
fix
NikitaUnisikhin Dec 10, 2023
84cedc1
add debug conf
NikitaUnisikhin Dec 12, 2023
de2c896
create od_address_range_t
NikitaUnisikhin Dec 12, 2023
48a42e9
start adding address_range in config_reader
NikitaUnisikhin Dec 12, 2023
ee315ba
reading address_range in rule
NikitaUnisikhin Dec 12, 2023
5cd8ee6
fix logs
NikitaUnisikhin Dec 12, 2023
e4720c9
rm addr_mask
NikitaUnisikhin Dec 12, 2023
975d03d
fix
NikitaUnisikhin Dec 12, 2023
a2095a8
start replaced addr_mask_is_default to is_default
NikitaUnisikhin Dec 12, 2023
3ca15c2
fix
NikitaUnisikhin Dec 12, 2023
631e61e
change params in od_address_read_prefix
NikitaUnisikhin Dec 12, 2023
3d32957
fix
NikitaUnisikhin Dec 12, 2023
ad2c8f2
fixes
NikitaUnisikhin Dec 12, 2023
dffa724
fixes
NikitaUnisikhin Dec 12, 2023
02d91f2
fix
NikitaUnisikhin Dec 12, 2023
64d6f55
fix
NikitaUnisikhin Dec 12, 2023
a1c2ba7
refactoring od_rules_match
NikitaUnisikhin Dec 12, 2023
53ae645
rm addr_mask from reading
NikitaUnisikhin Dec 12, 2023
9899716
fix
NikitaUnisikhin Dec 12, 2023
03cdc03
change config
NikitaUnisikhin Dec 12, 2023
e7c3ce2
fix
NikitaUnisikhin Dec 12, 2023
2697c50
fix
NikitaUnisikhin Dec 12, 2023
c52288f
fix
NikitaUnisikhin Dec 12, 2023
10fc990
refactoring hba
NikitaUnisikhin Dec 13, 2023
3c1cc0a
debug
NikitaUnisikhin Dec 13, 2023
730991c
change conf
NikitaUnisikhin Dec 13, 2023
3ba139f
fix
NikitaUnisikhin Dec 13, 2023
7da9b3b
fix
NikitaUnisikhin Dec 14, 2023
52770ac
add new tests
NikitaUnisikhin Dec 14, 2023
a468211
create od_address_validate, refactoring code
NikitaUnisikhin Dec 15, 2023
0ae0f30
fix
NikitaUnisikhin Dec 15, 2023
6cc4375
fix watchdog
NikitaUnisikhin Dec 15, 2023
aba300f
fix
NikitaUnisikhin Dec 15, 2023
76ab883
fix
NikitaUnisikhin Dec 15, 2023
d6a9b75
fix
NikitaUnisikhin Dec 15, 2023
61532ec
fix od_drop_obsolete_rule_connections_cb and od_rules_match
NikitaUnisikhin Dec 15, 2023
854e43e
add AF_UNSPEC in address od_address_inet_equals
NikitaUnisikhin Dec 15, 2023
5df109f
create od_address_range_equals, refactoring
NikitaUnisikhin Dec 15, 2023
e05c34f
refactoring
NikitaUnisikhin Dec 15, 2023
c93313d
refactoring
NikitaUnisikhin Dec 15, 2023
2830e51
refactoring
NikitaUnisikhin Dec 15, 2023
c0ef212
fix address_range NULL
NikitaUnisikhin Dec 15, 2023
7be3493
debug
NikitaUnisikhin Dec 18, 2023
7875f8a
add od_address_hostname_validate
NikitaUnisikhin Dec 18, 2023
f49dbe6
debug
NikitaUnisikhin Dec 18, 2023
25c63cf
add reading hostname and validate
NikitaUnisikhin Dec 18, 2023
6d56fbf
fux
NikitaUnisikhin Dec 18, 2023
d74094c
fix
NikitaUnisikhin Dec 18, 2023
66b92c4
fix
NikitaUnisikhin Dec 18, 2023
1fb3014
fix
NikitaUnisikhin Dec 18, 2023
a5bcabf
fix
NikitaUnisikhin Dec 18, 2023
e1432af
add od_address_strcasecmp and od_address_hostname_match
NikitaUnisikhin Dec 19, 2023
7a0d00d
add od_address_check_hostname
NikitaUnisikhin Dec 19, 2023
33219cd
fix
NikitaUnisikhin Dec 19, 2023
a4442e2
fix
NikitaUnisikhin Dec 19, 2023
808dfca
fix
NikitaUnisikhin Dec 19, 2023
1058535
refactoring
NikitaUnisikhin Dec 19, 2023
bba1323
rm cast sockaddr to sockaddr_storage
NikitaUnisikhin Dec 19, 2023
8fc9e5c
fixes
NikitaUnisikhin Dec 19, 2023
2ad0319
add od_address_check_hostname in od_address_validate
NikitaUnisikhin Dec 20, 2023
48701ea
refactoring
NikitaUnisikhin Dec 20, 2023
d99bcba
fix
NikitaUnisikhin Dec 20, 2023
58b11f7
fix
NikitaUnisikhin Dec 20, 2023
fd2ee51
fix
NikitaUnisikhin Dec 20, 2023
e5b0661
refactoring
NikitaUnisikhin Dec 20, 2023
93efefa
fixes
NikitaUnisikhin Dec 20, 2023
6c70a29
fix hostname regular
NikitaUnisikhin Dec 20, 2023
d071192
add tests
NikitaUnisikhin Dec 20, 2023
bca8f46
fix rule-address tests
NikitaUnisikhin Dec 21, 2023
16ed94c
fixes
NikitaUnisikhin Jan 31, 2024
9c19743
apply fmt
NikitaUnisikhin Jan 31, 2024
8161ef2
fix od_address_check_hostname
NikitaUnisikhin Jan 31, 2024
3b45fd3
apply fmt
NikitaUnisikhin Jan 31, 2024
40ed6f5
Merge branch 'master' into add_addr_pool_in_rule
x4m Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config-examples/odyssey-dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ locks_dir "/tmp/odyssey"

graceful_die_on_errors yes
enable_online_restart no
bindwith_reuseport yes
bindwith_reuseport yes
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ COPY --from=base /prep_stmts/pkg/pstmts-test /pstmts-test
COPY --from=base /config-validation/pkg/config-validation /config-validation
COPY ./docker/scram /scram
COPY ./docker/hba /hba
COPY ./docker/rule-address /rule-address
COPY ./docker/auth_query /auth_query
COPY ./docker/ldap /ldap
COPY ./docker/lagpolling /lagpolling
Expand Down
1 change: 0 additions & 1 deletion docker/auth_query/test_auth_query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ PGPASSWORD=passwd psql -h localhost -p 6432 -U auth_query_user_md5 -c "SELECT 1"
exit 1
}


ody-stop
10 changes: 9 additions & 1 deletion docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sudo -u postgres /usr/bin/pg_basebackup -D /var/lib/postgresql/14/repl -R -h loc
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /var/lib/postgresql/14/repl/ -o '-p 5433' start

# Create databases
for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db; do
for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db; do
sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || {
echo "ERROR: 'createdb $database_name' failed, examine the log"
cat "$SETUP_LOG"
Expand Down Expand Up @@ -127,6 +127,14 @@ psql -h localhost -p 5432 -U postgres -c "create user user_allow password 'corr
exit 1
}

# Create users
psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct password 'correct_password'; create user user_addr_incorrect password 'correct_password'; create user user_addr_default password 'correct_password'; create user user_addr_empty password 'correct_password'; create user user_addr_hostname_localhost password 'correct_password';" >> $SETUP_LOG 2>&1 || {
echo "ERROR: users creation failed, examine the log"
cat "$SETUP_LOG"
cat "$PG_LOG"
exit 1
}

for i in `seq 0 9`
do
# Create tables
Expand Down
9 changes: 8 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ cd /test_dir/test && /usr/bin/odyssey_test

setup

# odyssey rule-address test
/rule-address/test.sh
if [ $? -eq 1 ]
then
exit 1
fi

# odyssey target session attrs test
/tsa/tsa.sh
if [ $? -eq 1 ]
Expand Down Expand Up @@ -74,4 +81,4 @@ ody-start
/ody-integration-test
ody-stop

teardown
teardown
64 changes: 64 additions & 0 deletions docker/rule-address/addr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
listen {
host "*"
port 6432
}

storage "postgres_server" {
type "remote"
host "127.0.0.1"
port 5432
}

database "addr_db" {
user "user_addr_correct" "127.0.0.0/24" {
authentication "clear_text"
password "correct_password"
storage "postgres_server"
pool "session"
}

user "user_addr_incorrect" "255.0.0.0/24" {
authentication "clear_text"
password "correct_password"
storage "postgres_server"
pool "session"
}

user "user_addr_default" default {
authentication "clear_text"
password "correct_password"
storage "postgres_server"
pool "session"
}

user "user_addr_empty" {
authentication "clear_text"
password "correct_password"
storage "postgres_server"
pool "session"
}

user "user_addr_hostname_localhost" "localhost" {
authentication "clear_text"
password "correct_password"
storage "postgres_server"
pool "session"
}
}

daemonize yes
pid_file "/var/run/odyssey.pid"

unix_socket_dir "/tmp"
unix_socket_mode "0644"

locks_dir "/tmp"

log_format "%p %t %l [%i %s] (%c) %m\n"
log_file "/var/log/odyssey.log"
log_to_stdout no
log_config yes
log_debug yes
log_session yes
log_stats no
log_query yes
79 changes: 79 additions & 0 deletions docker/rule-address/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash -x

set -ex

/usr/bin/odyssey /rule-address/addr.conf

PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_correct -c "SELECT 1" addr_db > /dev/null 2>&1 || {
echo "ERROR: failed auth with correct addr, correct password and plain password in config"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_correct -c "SELECT 1" addr_db > /dev/null 2>&1 && {
echo "ERROR: successfully auth with correct addr, but incorrect password"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_incorrect -c "SELECT 1" addr_db > /dev/null 2>&1 && {
echo "ERROR: successfully auth with incorrect addr"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_default -c "SELECT 1" addr_db > /dev/null 2>&1 || {
echo "ERROR: failed auth with correct addr, correct password and plain password in config"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_default -c "SELECT 1" addr_db > /dev/null 2>&1 && {
echo "ERROR: successfully auth with correct addr, but incorrect password"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_empty -c "SELECT 1" addr_db > /dev/null 2>&1 || {
echo "ERROR: failed auth with correct addr, correct password and plain password in config"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_empty -c "SELECT 1" addr_db > /dev/null 2>&1 && {
echo "ERROR: successfully auth with correct addr, but incorrect password"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_hostname_localhost -c "SELECT 1" addr_db > /dev/null 2>&1 || {
echo "ERROR: failed auth with correct addr, correct password and plain password in config"

cat /var/log/odyssey.log

exit 1
}

PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_hostname_localhost -c "SELECT 1" addr_db > /dev/null 2>&1 && {
echo "ERROR: successfully auth with correct addr, but incorrect password"

cat /var/log/odyssey.log

exit 1
}

ody-stop
1 change: 1 addition & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(od_src
storage.c
murmurhash.c
hashmap.c
address.c
hba.c
hba_reader.c
hba_rule.c
Expand Down
Loading
Loading