From: Karl Fleischmann Date: Tue, 16 Jan 2024 12:34:17 +0000 (+0100) Subject: lib-imap: imap_id_reply_generate() - Remove obsolete IMAP ID defaults resolving X-Git-Tag: 2.4.1~1044 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eca4b143c101b1567dcbc9a12e4ba792adec56bb;p=thirdparty%2Fdovecot%2Fcore.git lib-imap: imap_id_reply_generate() - Remove obsolete IMAP ID defaults resolving --- diff --git a/src/lib-imap/imap-id.c b/src/lib-imap/imap-id.c index 24cdb56574..5685a17ca3 100644 --- a/src/lib-imap/imap-id.c +++ b/src/lib-imap/imap-id.c @@ -9,48 +9,9 @@ #include "imap-id.h" #include "dovecot-version.h" -#ifdef HAVE_SYS_UTSNAME_H -# include -#endif - /* Limit the allowed characters that an IMAP ID parameter might have. */ #define IMAP_ID_KEY_ACCEPT_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_-" -static struct utsname utsname_result; -static bool utsname_set = FALSE; - -static const char *imap_id_get_uname(const char *key) -{ - if (!utsname_set) { - utsname_set = TRUE; - if (uname(&utsname_result) < 0) { - i_error("uname() failed: %m"); - i_zero(&utsname_result); - } - } - - if (strcasecmp(key, "os") == 0) - return utsname_result.sysname; - if (strcasecmp(key, "os-version") == 0) - return utsname_result.release; - return NULL; -} - -static const char *imap_id_get_default(const char *key) -{ - if (strcasecmp(key, "name") == 0) - return DOVECOT_NAME; - if (strcasecmp(key, "version") == 0) - return PACKAGE_VERSION; - if (strcasecmp(key, "revision") == 0) - return DOVECOT_REVISION; - if (strcasecmp(key, "support-url") == 0) - return PACKAGE_WEBPAGE; - if (strcasecmp(key, "support-email") == 0) - return PACKAGE_BUGREPORT; - return imap_id_get_uname(key); -} - const char *imap_id_reply_generate(const ARRAY_TYPE(const_string) *args) { if (array_is_empty(args)) @@ -66,12 +27,10 @@ const char *imap_id_reply_generate(const ARRAY_TYPE(const_string) *args) imap_append_quoted(str, kv[i]); str_append_c(str, ' '); const char *value = kv[i + 1]; - if (strcmp(value, "*") == 0) - value = imap_id_get_default(kv[i]); #if defined(DOVECOT_EDITION) - else if (strcasecmp(kv[i], "name") == 0 && - strcmp(DOVECOT_EDITION, "Pro") == 0) - value = imap_id_get_default(kv[i]); + if (strcasecmp(kv[i], "name") == 0 && + strcmp(DOVECOT_EDITION, "Pro") == 0) + value = DOVECOT_NAME; #endif imap_append_nstring(str, value); }