odyssey icon indicating copy to clipboard operation
odyssey copied to clipboard

Switch to older PgSQL versions

Open fragpit opened this issue 4 years ago • 3 comments

Hi guys,

are there any way to use older pg versions, e.g. pg-12? I'd changed version (13->12) in some files, but still got:

make process error
[ 37%] Building C object sources/CMakeFiles/odyssey.dir/scram.c.o
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_parse_verifier':
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:65:17: note: in expansion of macro 'od_b64_decode'
   65 |  int salt_len = od_b64_decode(salt_raw, salt_raw_len, salt, salt_dst_len);
      |                 ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:82:23: note: in expansion of macro 'od_b64_decode'
   82 |  int stored_key_len = od_b64_decode(
      |                       ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:95:23: note: in expansion of macro 'od_b64_decode'
   95 |  int server_key_len = od_b64_decode(
      |                       ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_init_from_plain_password':
/test_dir/sources/scram.h:6:3: error: too many arguments to function 'pg_b64_encode'
    6 |   pg_b64_encode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:145:4: note: in expansion of macro 'od_b64_encode'
  145 |    od_b64_encode(salt, sizeof(salt), scram_state->salt, salt_dst_len);
      |    ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:14:12: note: declared here
   14 | extern int pg_b64_encode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_create_client_first_message':
/test_dir/sources/scram.h:6:3: error: too many arguments to function 'pg_b64_encode'
    6 |   pg_b64_encode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:179:48: note: in expansion of macro 'od_b64_encode'
  179 |  int base64_nonce_len                        = od_b64_encode((char *)nonce,
      |                                                ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:14:12: note: declared here
   14 | extern int pg_b64_encode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'read_server_first_message':
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:253:4: note: in expansion of macro 'od_b64_decode'
  253 |    od_b64_decode(base64_salt, base64_salt_size, salt, salt_dst_len);
      |    ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'calculate_server_signature':
/test_dir/sources/scram.h:6:3: error: too many arguments to function 'pg_b64_encode'
    6 |   pg_b64_encode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:378:29: note: in expansion of macro 'od_b64_encode'
  378 |  int base64_signature_len = od_b64_encode((char *)server_signature,
      |                             ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:14:12: note: declared here
   14 | extern int pg_b64_encode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_create_client_final_message':
/test_dir/sources/scram.h:6:3: error: too many arguments to function 'pg_b64_encode'
    6 |   pg_b64_encode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:435:10: note: in expansion of macro 'od_b64_encode'
  435 |  size += od_b64_encode((char *)client_proof,
      |          ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:14:12: note: declared here
   14 | extern int pg_b64_encode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'read_server_final_message':
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:475:26: note: in expansion of macro 'od_b64_decode'
  475 |  decoded_signature_len = od_b64_decode(
      |                          ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_read_client_final_message':
/test_dir/sources/scram.h:8:3: error: too many arguments to function 'pg_b64_decode'
    8 |   pg_b64_decode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:678:4: note: in expansion of macro 'od_b64_decode'
  678 |    od_b64_decode(base64_proof, base64_proof_size, proof, proof_size);
      |    ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:15:12: note: declared here
   15 | extern int pg_b64_decode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
In file included from /test_dir/sources/odyssey.h:51,
                 from /test_dir/sources/scram.c:10:
/test_dir/sources/scram.c: In function 'od_scram_create_server_first_message':
/test_dir/sources/scram.h:6:3: error: too many arguments to function 'pg_b64_encode'
    6 |   pg_b64_encode(src, src_len, dst, dst_len);
      |   ^~~~~~~~~~~~~
/test_dir/sources/scram.c:723:48: note: in expansion of macro 'od_b64_encode'
  723 |  int base64_nonce_len                        = od_b64_encode((char *)nonce,
      |                                                ^~~~~~~~~~~~~
In file included from /test_dir/sources/postgres.h:26,
                 from /test_dir/sources/odyssey.h:46,
                 from /test_dir/sources/scram.c:10:
/usr/include/postgresql/12/server/common/base64.h:14:12: note: declared here
   14 | extern int pg_b64_encode(const char *src, int len, char *dst);
      |            ^~~~~~~~~~~~~
make[3]: *** [sources/CMakeFiles/odyssey.dir/build.make:531: sources/CMakeFiles/odyssey.dir/scram.c.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/test_dir/build'
make[2]: *** [CMakeFiles/Makefile2:223: sources/CMakeFiles/odyssey.dir/all] Error 2
make[2]: Leaving directory '/test_dir/build'
make[1]: *** [Makefile:84: all] Error 2
make[1]: Leaving directory '/test_dir/build'
make: *** [Makefile:16: local_build] Error 2

fragpit avatar Dec 02 '20 11:12 fragpit

Hi! Chances are this macro had a bug https://github.com/yandex/odyssey/blob/master/sources/scram.h#L4 Try to set 13000. Or plz find correct verision when dst_len argument was added

x4m avatar Dec 02 '20 13:12 x4m

Hi! seems like your PG_VERSION_NUM is less than 12000 for some reason. You can manuaaly add #define PG_VERSION_NUM 12000 in build.h or delete #define USE_SCRAM from macro.h

reshke avatar Dec 02 '20 13:12 reshke

after this change:

diff --git a/sources/scram.h b/sources/scram.h
index 8bbe4f5..3b59421 100644
--- a/sources/scram.h
+++ b/sources/scram.h
@@ -1,7 +1,7 @@
 #ifndef ODYSSEY_SCRAM_H
 #define ODYSSEY_SCRAM_H

-#if PG_VERSION_NUM >= 120000
+#if PG_VERSION_NUM >= 130000

it fails that way:

make process error

[ 37%] Building C object sources/CMakeFiles/odyssey.dir/scram.c.o [ 38%] Linking C executable odyssey /usr/bin/ld: /usr/lib/postgresql/12/lib/libpgcommon.a(saslprep.o): in function pg_saslprep': (.text+0xd4): undefined reference to pg_utf_mblen' /usr/bin/ld: (.text+0xe2): undefined reference to pg_utf8_islegal' /usr/bin/ld: (.text+0x180): undefined reference to utf8_to_unicode' /usr/bin/ld: (.text+0x18b): undefined reference to pg_utf_mblen' /usr/bin/ld: (.text+0x440): undefined reference to unicode_to_utf8' /usr/bin/ld: (.text+0x448): undefined reference to pg_utf_mblen' /usr/bin/ld: (.text+0x488): undefined reference to unicode_to_utf8' /usr/bin/ld: (.text+0x490): undefined reference to `pg_utf_mblen' collect2: error: ld returned 1 exit status make[3]: *** [sources/CMakeFiles/odyssey.dir/build.make:632: sources/odyssey] Error 1 make[3]: Leaving directory '/test_dir/build' make[2]: *** [CMakeFiles/Makefile2:223: sources/CMakeFiles/odyssey.dir/all] Error 2 make[2]: Leaving directory '/test_dir/build' make[1]: *** [Makefile:84: all] Error 2 make[1]: Leaving directory '/test_dir/build' make: *** [Makefile:16: local_build] Error 2

also I've tried this:

add #define PG_VERSION_NUM 12000 in build.h or delete #define USE_SCRAM from macro.h.

but it fails on pam.h immediately after scram.h (lost logs).

Switched to 1.1 tag, but there is a problem with postgres apt package, which I've fixed. But now there are problems with docker mounts.

fragpit avatar Dec 02 '20 14:12 fragpit