Subject: --disable-tmpnam

From: Matt Wette <[email-masked]>
Date: Sat, 21 Mar 2020 13:22:07 -0700

"make" and "make check" succeeds on 3.0.1 / Ubuntu 18.04 / x86_64 with
1) --disable-tmpnam
2) --enable-tmpnam
3) neither

This updates libguile/posix.c and configure.ac to allow extra
configuration option --disable-tmpnam.   This is made available
for installations that don't want to allow the insecure tmpnam
function.  (Use mkstemp! instead.)

--- libguile/posix.c-orig    2020-03-18 16:55:09.349588085 -0700
+++ libguile/posix.c    2020-03-18 17:07:20.860142083 -0700
@@ -65,6 +65,7 @@

  #include "async.h"
  #include "bitvectors.h"
+#include "deprecation.h"
  #include "dynwind.h"
  #include "extensions.h"
  #include "feature.h"
@@ -1588,6 +1589,7 @@
  }
  #undef FUNC_NAME

+#ifdef ENABLE_TMPNAM
  #ifdef L_tmpnam

  SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0,
@@ -1602,6 +1604,9 @@
    char name[L_tmpnam];
    char *rv;

+  scm_c_issue_deprecation_warning
+      ("Use of tmpnam is deprecated.  Use mkstemp! instead.");
+
    SCM_SYSCALL (rv = tmpnam (name));
    if (rv == NULL)
      /* not SCM_SYSERROR since errno probably not set.  */
@@ -1611,6 +1616,7 @@
  #undef FUNC_NAME

  #endif
+#endif

  SCM_DEFINE (scm_tmpfile, "tmpfile", 0, 0, 0,
              (void),
--- configure.ac-orig    2020-03-18 17:11:17.977427035 -0700
+++ configure.ac    2020-03-18 17:09:57.850334685 -0700
@@ -166,6 +166,10 @@
    [  --disable-regex         omit regular expression interfaces],,
    enable_regex=yes)

+AC_ARG_ENABLE(tmpnam,
+  [  --disable-tmpnam        omit POSIX tmpnam],,
+  enable_tmpnam=yes)
+
  AC_ARG_ENABLE([deprecated],
    AS_HELP_STRING([--disable-deprecated],[omit deprecated features]))

@@ -909,6 +913,10 @@
     AC_DEFINE([ENABLE_REGEX], 1, [Define when regex support is enabled.])
  fi

+if test "$enable_tmpnam" = yes; then
+   AC_DEFINE([ENABLE_TMPNAM], 1, [Define when tmpnam support is enabled.])
+fi
+
  AC_REPLACE_FUNCS([strerror memmove])

  # Reasons for testing: