diff options
| author | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
|---|---|---|
| committer | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
| commit | bd4611555e18fca7c66afaef0f094e15038b0459 (patch) | |
| tree | 1b1a9109567b61ac259ead146f4bef21a0f886df /src/postmulti/fake_strcmp.c | |
| parent | 2324a9e97a727bf95690c9fb8fdca0f52301940e (diff) | |
| download | postfix-master.tar.gz postfix-master.zip | |
Release tarball postfix-3.11.7.tar.gz (dist-generated files / local differences from tag)HEADlocal/postfixmaster
Diffstat (limited to 'src/postmulti/fake_strcmp.c')
| -rw-r--r-- | src/postmulti/fake_strcmp.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/postmulti/fake_strcmp.c b/src/postmulti/fake_strcmp.c new file mode 100644 index 000000000..0f5da471e --- /dev/null +++ b/src/postmulti/fake_strcmp.c @@ -0,0 +1,42 @@ +/* System library. */ +#include <sys_defs.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <dlfcn.h> + +/* Utility library. */ +#include <msg.h> + +/* Global library. */ +#include <mail_params.h> + +static int (*real_strcmp) (const char *, const char *); + +/* find_real_func - libc lookup */ + +static void *find_real_func(const char *name) +{ + void *sym; + + /* + * XXX Casting a data pointer into a function pointer is non-portable. + * Unfortunately, the dlfunc() function is available on FreeBSD but not + * on Linux or Solaris. This is a cosmetic issue except on systems with + * non-flat memory models. + */ + if ((sym = dlsym(RTLD_NEXT, name)) == 0) { + fprintf(stderr, "preload error for %s: %s\n", name, dlerror()); + exit(1); + } + return (sym); +} + +int strcmp(const char *s1, const char *s2) +{ + if (real_strcmp == 0) + real_strcmp = find_real_func("strcmp"); + if (real_strcmp(DEF_CONFIG_DIR, s2) == 0) + return (0); + return real_strcmp(s1, s2); +} |
