mirror of
https://gitlab.kit.edu/kit/scc/sys/mail/exim-encrypt-dlfunc.git
synced 2025-12-06 10:13:56 +01:00
Added more version workarounds for compilation, late binding and type casting.
This commit is contained in:
@ -6,8 +6,17 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Exim4 dlfunc API header */
|
/*
|
||||||
#include <local_scan.h>
|
* This is a set of workarounds for the different exim local_scan ABI versions, distribution patches and missing
|
||||||
|
* definitions which prevent late binding.
|
||||||
|
*
|
||||||
|
* List of local_scan ABI versions per distribution:
|
||||||
|
*
|
||||||
|
* 2.0 Debian 10 (Buster)
|
||||||
|
* 4.1 Debian 11 (Bullseye)
|
||||||
|
* 2.0 Ubuntu 18-04 (Bionic)
|
||||||
|
* 3.1 Ubuntu 20-04 (Focal)
|
||||||
|
*/
|
||||||
|
|
||||||
// local_scan ABI version < 3
|
// local_scan ABI version < 3
|
||||||
#if LOCAL_SCAN_ABI_VERSION_MAJOR < 3
|
#if LOCAL_SCAN_ABI_VERSION_MAJOR < 3
|
||||||
@ -21,7 +30,7 @@
|
|||||||
#define store_get_untainted(size) store_get(size, FALSE)
|
#define store_get_untainted(size) store_get(size, FALSE)
|
||||||
#define store_get_tainted(size) store_get(size, TRUE)
|
#define store_get_tainted(size) store_get(size, TRUE)
|
||||||
|
|
||||||
# define string_copy(s) string_copy_function(s)
|
#define string_copy(s) string_copy_function(s)
|
||||||
extern uschar * string_copy_function(const uschar *);
|
extern uschar * string_copy_function(const uschar *);
|
||||||
|
|
||||||
// local_scan ABI version > 3
|
// local_scan ABI version > 3
|
||||||
@ -29,8 +38,12 @@ extern uschar * string_copy_function(const uschar *);
|
|||||||
#define DLFUNC_IMPL
|
#define DLFUNC_IMPL
|
||||||
#define store_get_untainted(size) store_get(size, FALSE)
|
#define store_get_untainted(size) store_get(size, FALSE)
|
||||||
#define store_get_tainted(size) store_get(size, TRUE)
|
#define store_get_tainted(size) store_get(size, TRUE)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Exim4 dlfunc API header */
|
||||||
|
#include <local_scan.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encrypt message using crypto_secretbox_easy().
|
* Encrypt message using crypto_secretbox_easy().
|
||||||
*
|
*
|
||||||
@ -77,7 +90,8 @@ int sodium_crypto_secretbox_encrypt_password(uschar **yield, int argc, uschar *a
|
|||||||
unsigned char nonce[crypto_secretbox_NONCEBYTES];
|
unsigned char nonce[crypto_secretbox_NONCEBYTES];
|
||||||
randombytes_buf(nonce, sizeof nonce);
|
randombytes_buf(nonce, sizeof nonce);
|
||||||
if (crypto_secretbox_easy(ciphertext, message, messagelen, nonce, keybytes) != 0) {
|
if (crypto_secretbox_easy(ciphertext, message, messagelen, nonce, keybytes) != 0) {
|
||||||
*yield = string_copy((unsigned char *) "Encryption error after crypto_secretbox_easy()");
|
*yield = string_copy(US
|
||||||
|
"Encryption error after crypto_secretbox_easy()");
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +111,8 @@ int sodium_crypto_secretbox_encrypt_password(uschar **yield, int argc, uschar *a
|
|||||||
sodium_base64_VARIANT_ORIGINAL);
|
sodium_base64_VARIANT_ORIGINAL);
|
||||||
|
|
||||||
// return base64-encoded ciphertext
|
// return base64-encoded ciphertext
|
||||||
*yield = string_copy(outstring);
|
*yield = string_copy(US
|
||||||
|
outstring);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,9 +130,7 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a
|
|||||||
}
|
}
|
||||||
// check argument count
|
// check argument count
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
*yield =
|
*yield = string_sprintf("Wrong number of arguments (got %i, expected 2)", argc);
|
||||||
string_sprintf
|
|
||||||
("Wrong number of arguments (got %i, expected 2)", argc);
|
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
// get password
|
// get password
|
||||||
@ -144,7 +157,8 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a
|
|||||||
NULL, &combined_message_len, NULL,
|
NULL, &combined_message_len, NULL,
|
||||||
sodium_base64_VARIANT_ORIGINAL);
|
sodium_base64_VARIANT_ORIGINAL);
|
||||||
if (b64err != 0) {
|
if (b64err != 0) {
|
||||||
*yield = string_copy((unsigned char *) "Error decoding base64 encoded ciphertext");
|
*yield = string_copy(US
|
||||||
|
"Error decoding base64 encoded ciphertext");
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +174,14 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a
|
|||||||
// decrypt message
|
// decrypt message
|
||||||
if (crypto_secretbox_open_easy(cleartext, &combined_message[crypto_secretbox_NONCEBYTES],
|
if (crypto_secretbox_open_easy(cleartext, &combined_message[crypto_secretbox_NONCEBYTES],
|
||||||
combined_message_len - crypto_secretbox_NONCEBYTES, nonce, keybytes) != 0) {
|
combined_message_len - crypto_secretbox_NONCEBYTES, nonce, keybytes) != 0) {
|
||||||
*yield = string_copy((unsigned char *) "Decryption error after crypto_secretbox_open_easy()");
|
*yield = string_copy(US
|
||||||
|
"Decryption error after crypto_secretbox_open_easy()");
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return cleartext
|
// return cleartext
|
||||||
*yield = string_copy(cleartext);
|
*yield = string_copy(US
|
||||||
|
cleartext);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user