[exim-cvs] Build: move xtext routines out of auths drivers t…

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Exim Git Commits Mailing List
Data:  
Para: exim-cvs
Asunto: [exim-cvs] Build: move xtext routines out of auths drivers to main
Gitweb: https://git.exim.org/exim.git/commitdiff/7482553d06b156505e38b4cb1b72324bcfb62b37
Commit:     7482553d06b156505e38b4cb1b72324bcfb62b37
Parent:     35c22ec7c2bd08ba6631e29769a8ece18cbc76c0
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Jul 25 14:37:21 2024 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu Jul 25 14:37:21 2024 +0100


    Build: move xtext routines out of auths drivers to main
---
 src/OS/Makefile-Base                           |  3 +-
 src/scripts/MakeLinks                          |  4 +--
 src/src/auths/Makefile                         |  4 +--
 src/src/auths/xtextencode.c                    | 44 --------------------------
 src/src/deliver.c                              |  6 ++--
 src/src/expand.c                               |  2 +-
 src/src/functions.h                            |  4 +--
 src/src/smtp_in.c                              |  2 +-
 src/src/transports/smtp.c                      |  2 +-
 src/src/xclient.c                              |  2 +-
 src/src/{auths/xtextdecode.c => xtextencode.c} | 41 +++++++++++++++++++++---
 11 files changed, 50 insertions(+), 64 deletions(-)


diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base
index 1daded431..4df9451f8 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -518,7 +518,7 @@ OBJ_EXIM = acl.o base64.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o \
         rda.o readconf.o receive.o retry.o rewrite.o rfc2047.o regex_cache.o \
         route.o search.o sieve.o smtp_in.o smtp_out.o spool_in.o spool_out.o \
         std-crypto.o store.o string.o tls.o tod.o transport.o tree.o verify.o \
-        environment.o macro.o \
+        xtextencode.o environment.o macro.o \
         $(OBJ_LOOKUPS) \
         local_scan.o $(EXIM_PERL) $(OBJ_WITH_CONTENT_SCAN) \
         $(OBJ_EXPERIMENTAL)
@@ -869,6 +869,7 @@ tod.o:           $(HDRS) tod.c
 transport.o:     $(HDRS) transport.c
 tree.o:          $(HDRS) tree.c
 verify.o:        $(HDRS) transports/smtp.h verify.c
+xtextencode.o:   $(HDRS) xtextencode.c
 dkim.o:          $(HDRS) pdkim/pdkim.h dkim.c
 dkim_transport.o: $(HDRS) dkim_transport.c


diff --git a/src/scripts/MakeLinks b/src/scripts/MakeLinks
index cda5ef65b..77dbe26bd 100755
--- a/src/scripts/MakeLinks
+++ b/src/scripts/MakeLinks
@@ -78,7 +78,7 @@ cd $d
 for f in README Makefile call_pam.c call_pwcheck.c \
   call_radius.c check_serv_cond.c cyrus_sasl.c cyrus_sasl.h gsasl_exim.c \
   gsasl_exim.h get_data.c get_no64_data.c heimdal_gssapi.c heimdal_gssapi.h \
-  xtextencode.c xtextdecode.c cram_md5.c cram_md5.h plaintext.c plaintext.h \
+  cram_md5.c cram_md5.h plaintext.c plaintext.h \
   pwcheck.c pwcheck.h auth-spa.c auth-spa.h dovecot.c dovecot.h sha1.c spa.c \
   spa.h tls.c tls.h external.c external.h
 do
@@ -125,7 +125,7 @@ for f in blob.h dbfunctions.h exim.h functions.h globals.h \
   sieve.c smtp_in.c smtp_out.c spool_in.c spool_out.c std-crypto.c store.c \
   string.c tls.c tlscert-gnu.c tlscert-openssl.c tls-cipher-stdname.c \
   tls-gnu.c tls-openssl.c \
-  tod.c transport.c tree.c verify.c version.c \
+  tod.c transport.c tree.c verify.c version.c xtextencode.c \
   dkim.c dkim.h dkim_transport.c dmarc.c dmarc.h \
   valgrind.h memcheck.h \
   macro_predef.c macro_predef.h
diff --git a/src/src/auths/Makefile b/src/src/auths/Makefile
index e85b22a8a..ac5cf865b 100644
--- a/src/src/auths/Makefile
+++ b/src/src/auths/Makefile
@@ -9,7 +9,7 @@ OBJ = auth-spa.o call_pam.o call_pwcheck.o \
       call_radius.o check_serv_cond.o cram_md5.o cyrus_sasl.o dovecot.o \
       external.o get_data.o get_no64_data.o gsasl_exim.o heimdal_gssapi.o \
       plaintext.o pwcheck.o \
-      spa.o tls.o xtextdecode.o xtextencode.o
+      spa.o tls.o


 auths.a:         $(OBJ)
          @$(RM_COMMAND) -f auths.a
@@ -29,8 +29,6 @@ check_serv_cond.o:  $(HDRS) check_serv_cond.c
 get_data.o:         $(HDRS) get_data.c
 get_no64_data.o:    $(HDRS) get_no64_data.c
 pwcheck.o:          $(HDRS) pwcheck.c pwcheck.h
-xtextdecode.o:      $(HDRS) xtextdecode.c
-xtextencode.o:      $(HDRS) xtextencode.c


 cram_md5.o:         $(HDRS) cram_md5.c cram_md5.h
 cyrus_sasl.o:       $(HDRS) cyrus_sasl.c cyrus_sasl.h
diff --git a/src/src/auths/xtextencode.c b/src/src/auths/xtextencode.c
deleted file mode 100644
index 04cd302de..000000000
--- a/src/src/auths/xtextencode.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************
-*     Exim - an Internet mail transport agent    *
-*************************************************/
-
-/* Copyright (c) The Exim Maintainers 2022 - 2024 */
-/* Copyright (c) University of Cambridge 1995 - 2018 */
-/* See the file NOTICE for conditions of use and distribution. */
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#include "../exim.h"
-
-
-/*************************************************
-*          Encode byte-string in xtext           *
-*************************************************/
-
-/* This function encodes a string of bytes, containing any values whatsoever,
-as "xtext", as defined in RFC 1891 and required by the SMTP AUTH extension (RFC
-2554).
-
-Arguments:
-  clear       points to the clear text bytes
-  len         the number of bytes to encode
-
-Returns:      a pointer to the zero-terminated xtext string, which
-              is in working store
-*/
-
-uschar *
-auth_xtextencode(uschar *clear, int len)
-{
-gstring * g = NULL;
-for(uschar ch; len > 0; len--, clear++)
-  g = (ch = *clear) < 33 || ch > 126 || ch == '+' || ch == '='
-    ? string_fmt_append(g, "+%.02X", ch)
-    : string_catn(g, clear, 1);
-gstring_release_unused(g);
-return string_from_gstring(g);
-}
-
-
-/* End of xtextencode.c */
-/* vi: aw ai sw=2
-*/
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 64a53c7ba..19b5c81df 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -6085,7 +6085,7 @@ wording. */
     {
     /* must be decoded from xtext: see RFC 3461:6.3a */
     uschar * xdec_envid;
-    if (auth_xtextdecode(dsn_envid, &xdec_envid) > 0)
+    if (xtextdecode(dsn_envid, &xdec_envid) > 0)
       fprintf(fp, "Original-Envelope-ID: %s\n", dsn_envid);
     else
       fprintf(fp, "X-Original-Envelope-ID: error decoding xtext formatted ENVID\n");
@@ -6390,7 +6390,7 @@ if (dsn_envid)
   {
   /* must be decoded from xtext: see RFC 3461:6.3a */
   uschar *xdec_envid;
-  if (auth_xtextdecode(dsn_envid, &xdec_envid) > 0)
+  if (xtextdecode(dsn_envid, &xdec_envid) > 0)
     fprintf(f,"Original-Envelope-ID: %s\n", dsn_envid);
   else
     fprintf(f,"X-Original-Envelope-ID: error decoding xtext formatted ENVID\n");
@@ -6549,7 +6549,7 @@ if (addr_senddsn)
     if (dsn_envid)
       {            /* must be decoded from xtext: see RFC 3461:6.3a */
       uschar * xdec_envid;
-      if (auth_xtextdecode(dsn_envid, &xdec_envid) > 0)
+      if (xtextdecode(dsn_envid, &xdec_envid) > 0)
         fprintf(f, "Original-Envelope-ID: %s\n", dsn_envid);
       else
         fprintf(f, "X-Original-Envelope-ID: error decoding xtext formatted ENVID\n");
diff --git a/src/src/expand.c b/src/src/expand.c
index 8232ed942..ca9c7c3ac 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -8329,7 +8329,7 @@ NOT_ITEM: ;
       case EOP_XTEXTD:
     {
     uschar * s;
-    int len = auth_xtextdecode(sub, &s);
+    int len = xtextdecode(sub, &s);
     yield = string_catn(yield, s, len);
     break;
     }
diff --git a/src/src/functions.h b/src/src/functions.h
index 4bd6ff51b..079e94f5e 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -137,8 +137,6 @@ extern int     auth_get_no64_data(uschar **, uschar *);
 extern int     auth_prompt(const uschar *);
 extern int     auth_read_input(const uschar *);
 extern gstring * auth_show_supported(gstring *);
-extern uschar *auth_xtextencode(uschar *, int);
-extern int     auth_xtextdecode(uschar *, uschar **);
 extern uschar *authenticator_current_name(void);


 #ifdef EXPERIMENTAL_ARC
@@ -693,6 +691,8 @@ extern uschar *wrap_header(const uschar *, unsigned, unsigned, const uschar *, u
 extern uschar * xclient_smtp_command(uschar *, int *, BOOL *);
 extern gstring * xclient_smtp_advertise_str(gstring *);
 #endif
+extern uschar *xtextencode(uschar *, int);
+extern int     xtextdecode(uschar *, uschar **);



 /******************************************************************************/
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index f8656a6e8..eadad682b 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -4565,7 +4565,7 @@ while (done <= 0)
           int rc;
           uschar *ignore_msg;


-          if (auth_xtextdecode(value, &authenticated_sender) < 0)
+          if (xtextdecode(value, &authenticated_sender) < 0)
         {
         /* Put back terminator overrides for error message */
         value[-1] = '=';
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 5b54fa1ae..769c5d235 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -1809,7 +1809,7 @@ if (  (f.smtp_authenticated || ob->authenticated_sender_force)
    && local_authenticated_sender)
   {
   string_format_nt(p, sizeof(sx->buffer) - (p-sx->buffer), " AUTH=%s",
-    auth_xtextencode(local_authenticated_sender,
+    xtextencode(local_authenticated_sender,
       Ustrlen(local_authenticated_sender)));
   client_authenticated_sender = string_copy(local_authenticated_sender);
   }
diff --git a/src/src/xclient.c b/src/src/xclient.c
index cca5dd887..af2f287b9 100644
--- a/src/src/xclient.c
+++ b/src/src/xclient.c
@@ -66,7 +66,7 @@ Returns:      the number of bytes in the result, excluding the final zero;
 static int
 xclient_xtextdecode(uschar * code, uschar * end, uschar ** ptr)
 {
-return auth_xtextdecode(string_copyn(code, end-code), ptr);
+return xtextdecode(string_copyn(code, end-code), ptr);
 }


 /*************************************************
diff --git a/src/src/auths/xtextdecode.c b/src/src/xtextencode.c
similarity index 61%
rename from src/src/auths/xtextdecode.c
rename to src/src/xtextencode.c
index d261801ae..fa2b26bed 100644
--- a/src/src/auths/xtextdecode.c
+++ b/src/src/xtextencode.c
@@ -2,12 +2,41 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/


-/* Copyright (c) The Exim Maintainers 2022 - 2023 */
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) The Exim Maintainers 2022 - 2024 */
+/* Copyright (c) University of Cambridge 1995 - 2018 */
/* See the file NOTICE for conditions of use and distribution. */
/* SPDX-License-Identifier: GPL-2.0-or-later */

-#include "../exim.h"
+#include "exim.h"
+
+
+/*************************************************
+*          Encode byte-string in xtext           *
+*************************************************/
+
+/* This function encodes a string of bytes, containing any values whatsoever,
+as "xtext", as defined in RFC 1891 and required by the SMTP AUTH extension (RFC
+2554).
+
+Arguments:
+  clear       points to the clear text bytes
+  len         the number of bytes to encode
+
+Returns:      a pointer to the zero-terminated xtext string, which
+              is in working store
+*/
+
+uschar *
+xtextencode(uschar *clear, int len)
+{
+gstring * g = NULL;
+for(uschar ch; len > 0; len--, clear++)
+  g = (ch = *clear) < 33 || ch > 126 || ch == '+' || ch == '='
+    ? string_fmt_append(g, "+%.02X", ch)
+    : string_catn(g, clear, 1);
+gstring_release_unused(g);
+return string_from_gstring(g);
+}



 /*************************************************
@@ -32,7 +61,7 @@ Returns:      the number of bytes in the result, excluding the final zero;
 */


int
-auth_xtextdecode(uschar * code, uschar ** ptr)
+xtextdecode(uschar * code, uschar ** ptr)
{
int x;
uschar * result = store_get(Ustrlen(code) + 1, code);
@@ -56,4 +85,6 @@ while ((x = (*code++)) != 0)
return result - *ptr;
}

-/* End of xtextdecode.c */
+/* End of xtextencode.c */
+/* vi: aw ai sw=2
+*/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/