Re: [PATCH libgpg-error] Add support for IBM z/OS

Sachin T via Gnupg-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <CO1PR15MB5003C1ECA0048B0AA45464489770A@CO1PR15MB5003.namprd15.prod.outlook.com>
Hi,

Please review the updated patch with comments from Werner, Jacob and Todd fixed.

*Renamed environ variable to avoid conflict with environ defined in z/os stdlib header

Regards
Sachin

---

Signed-off-by: Sachin T [email protected]<mailto:[email protected]>
---
src/Makefile.am   | 2 +-
src/spawn-posix.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index e56bb23..7e874cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -275,7 +275,7 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in

mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile
               $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
-              $(CPPFLAGS_FOR_BUILD) -g -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
+             $(CPPFLAGS_FOR_BUILD) -g -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c $(LIBS)

parts_of_gpg_error_h =                               \
               gpg-error.h.in  \
diff --git a/src/spawn-posix.c b/src/spawn-posix.c
index ac19761..0ffc71e 100644
--- a/src/spawn-posix.c
+++ b/src/spawn-posix.c
@@ -63,7 +63,7 @@
struct gpgrt_spawn_actions {
   int fd[3];
   const int *except_fds;
-  char **environ;
+  char **environ_p;
   const char *const *envchange;
   void (*atfork) (void *);
   void *atfork_arg;
@@ -414,8 +414,8 @@ my_exec (const char *pgmname, const char *argv[], gpgrt_spawn_actions_t act)
   if (pgmname == NULL)
     return 0;

-  if (act->environ)
-    execve (pgmname, (char *const *)argv, act->environ);
+  if (act->environ_p)
+    execve (pgmname, (char *const *)argv, act->environ_p);
   else
     execv (pgmname, (char *const *)argv);

@@ -516,7 +516,7 @@ void
_gpgrt_spawn_actions_set_environ (gpgrt_spawn_actions_t act,
                                   char **environ_for_child)
{
-  act->environ = environ_for_child;
+  act->environ_p = environ_for_child;
}

void
--
2.39.5 (Apple Git-154)

From: Sachin T <[email protected]>
Date: Tuesday, 10 June 2025 at 8:45 PM
To: [email protected] <[email protected]>
Cc: Sachin T <[email protected]>
Subject: [PATCH libgpg-error] Add support for IBM z/OS
Hi,

Please review patch required for IBM z/OS platform.


  1.  mkheader target depends on “zoslib”(specific to z/OS platform) which is passed via LIBS
  2.  Uses AF_UNIX instead of AF_LOCAL in socketpair().
  3.  On z/OS, environ is defined as a macro in <stdlib.h>, so it is temporarily redefined around the header inclusion to avoid conflicts.

Regards
Sachin

---

From cbea5636c31668ae238d899dfa6d1f4682704f83 Mon Sep 17 00:00:00 2001
From: Sachin T [email protected]<mailto:[email protected]>
Date: Tue, 10 Jun 2025 20:14:04 +0530
Subject: [PATCH] Add patches for IBM z/OS

Signed-off-by: Sachin T [email protected]<mailto:[email protected]>
---
src/Makefile.am   |  2 +-
src/spawn-posix.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index e56bb23..7e874cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -275,7 +275,7 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in

mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile
               $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
-              $(CPPFLAGS_FOR_BUILD) -g -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
+             $(CPPFLAGS_FOR_BUILD) -g -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c $(LIBS)

parts_of_gpg_error_h =                               \
               gpg-error.h.in    \
diff --git a/src/spawn-posix.c b/src/spawn-posix.c
index ac19761..2666862 100644
--- a/src/spawn-posix.c
+++ b/src/spawn-posix.c
@@ -27,8 +27,17 @@
#error This code is only used on POSIX
#endif

+#if defined(__MVS__)
+#define environ environ_replace
+#endif
+
#include <stdio.h>
#include <stdlib.h>
+
+#if defined(__MVS__)
+#undef environ
+#endif
+
#include <stdint.h>
#include <string.h>
#include <errno.h>
@@ -330,7 +339,11 @@ do_create_socketpair (int filedes[2])
   gpg_error_t err = 0;

   _gpgrt_pre_syscall ();
+#if defined(__MVS__)
+  if (socketpair (AF_UNIX, SOCK_STREAM, 0, filedes) == -1)
+#else
   if (socketpair (AF_LOCAL, SOCK_STREAM, 0, filedes) == -1)
+#endif
     {
       err = _gpg_err_code_from_syserror ();
       filedes[0] = filedes[1] = -1;
--
2.39.5 (Apple Git-154)

_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.