<<< Date Index >>>     <<< Thread Index >>>

[Mutt] #3217: mutt-1.5.19: compile with gpgme backend fails on systems with missing mkdtemp



#3217: mutt-1.5.19: compile with gpgme backend fails on systems with missing
mkdtemp
----------------------------------------------+-----------------------------
  Reporter:  Thomas Wiegner <wiegner@xxxxxx>  |       Owner:  mutt-dev
      Type:  defect                           |      Status:  new     
  Priority:  major                            |   Milestone:          
 Component:  mutt                             |     Version:          
Resolution:  fixed                            |    Keywords:          
----------------------------------------------+-----------------------------
 {{{
 Package: mutt
 Version: 1.5.19
 Severity: normal

 -- Please type your report below this line

 On some Unix systems the mkdtemp is not part of the normal libc.
 When trying to use the gpgme crypto backend, compiling fails
 on these systems (e.g. Solaris)

 Please use the included patch. It will fix that issue. I took
 a slightly modified version of XFCE's xarchiers mkdtemp function.


 --- configure.ac        2009-04-20 13:06:28.574263000 +0200
 +++ configure.ac        2009-04-20 13:06:37.463942000 +0200
 @@ -306,6 +306,7 @@
  AC_CHECK_HEADERS(unix.h)

  AC_CHECK_FUNCS(setrlimit getsid)
 +AC_CHECK_FUNCS(mkdtemp)

  AC_TYPE_SIGNAL

 --- config.h.in 2009-04-20 13:03:27.969580000 +0200
 +++ config.h.in 2009-04-20 13:19:04.000000000 +0200
 @@ -255,6 +255,9 @@
  /* Define if you have meta, as a function or macro. */
  #undef HAVE_META

 +/* Define to 1 if you have the `mkdtemp' function. */
 +#undef HAVE_MKDTEMP
 +
  /* Define to 1 if you have a working `mmap' system call. */
  #undef HAVE_MMAP

 --- crypt-gpgme.c       2009-04-20 13:14:55.029092000 +0200
 +++ crypt-gpgme.c       2009-04-20 13:21:06.828052000 +0200
 @@ -129,6 +129,43 @@
   * General helper functions.
   */

 +#ifndef HAVE_MKDTEMP
 +/* mkdtemp fuction for systems which don't have one */
 +char *mkdtemp (char *tmpl)
 +{
 +    static const char LETTERS[] =
 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 +    static long       value = 0;
 +    long              v;
 +    int               len;
 +    int               i, j;
 +
 +    len = strlen (tmpl);
 +    if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0)
 +    {
 +        errno = EINVAL;
 +        return NULL;
 +    }
 +
 +    value += ((long) time (NULL)) ^ getpid ();
 +
 +    for (i = 0; i < 7 ; ++i, value += 7777)
 +    {
 +        /* fill in the random bits */
 +        for (j = 0, v = value; j < 6; ++j)
 +            tmpl[(len - 6) + j] = LETTERS[v % 62]; v /= 62;
 +
 +        /* try to create the directory */
 +        if (mkdir (tmpl, 0700) == 0)
 +            return tmpl;
 +        else if (errno != EEXIST)
 +            return NULL;
 +    }
 +
 +    errno = EEXIST;
 +    return NULL;
 +}
 +#endif
 +
  /* return true when S pints to a didgit or letter. */
  static int
  digit_or_letter (const unsigned char *s)
 }}}

-- 
Ticket URL: <http://dev.mutt.org/trac/ticket/3217>
Mutt <http://www.mutt.org/>
The Mutt mail user agent