--- dillo/dpid/dpiddir.c.orig Fri Aug 8 22:28:02 2003 +++ dillo/dpid/dpiddir.c Tue Aug 26 17:04:09 2003 @@ -1,6 +1,10 @@ #include #include "dpi.h" +#ifndef HAVE_MKDTEMP_H +#include "mkdtemp.h" +#endif + extern int errno; /*! Writes socket directory to DPID_DIR */ @@ -43,9 +47,15 @@ username = g_get_user_name(); template = g_strconcat(ROOTDIR, "/tmp/", username, "-", "XXXXXX", NULL); - mkdtemp(template); - printf("mk_sockdir: socket dir = %s\n", template); - return template; + if(mkdtemp(template)) + { + printf("mk_sockdir: socket dir = %s\n", template); + return template; + } + else + { + printf("mk_sockdir: failed\n"); + } } /*! Creates socket directory if it does not exist and writes its name to @@ -71,6 +81,8 @@ return (sockdir); } else { sockdir = mk_sockdir(); + if(!sockdir) + return (NULL); if ((w_dpid_dir(dpid_dir, sockdir)) == -1) { fprintf(stderr, "init_sockdir: failed to save %s\n", sockdir); if (sockdir) --- dillo/dpid/Makefile.am.orig Fri Aug 8 22:28:02 2003 +++ dillo/dpid/Makefile.am Tue Aug 26 17:05:04 2003 @@ -1,3 +1,4 @@ +INCLUDES = -I../lib bin_PROGRAMS = dpid @@ -11,3 +12,4 @@ dpiddir.c \ misc_new.c \ main.c +dpid_LDADD = -L../lib -ldillo --- dillo/Makefile.am.orig Fri Aug 8 22:27:57 2003 +++ dillo/Makefile.am Tue Aug 26 17:01:22 2003 @@ -1,4 +1,4 @@ -SUBDIRS = doc src dpid dpi +SUBDIRS = lib doc src dpid dpi EXTRA_DIST = ChangeLog.old dillorc --- dillo/configure.in.orig Fri Aug 8 22:27:57 2003 +++ dillo/configure.in Tue Aug 26 17:05:25 2003 @@ -215,10 +215,11 @@ fi AC_CHECK_FUNCS(socket) +AC_REPLACE_FUNCS(mkdtemp) AC_SUBST(LIBJPEG_LIB) AC_SUBST(datadir) AC_SUBST(src doc bin util lib) -AC_OUTPUT(Makefile dpid/Makefile dpi/Makefile doc/Makefile src/Makefile src/IO/Makefile) +AC_OUTPUT(Makefile lib/Makefile dpid/Makefile dpi/Makefile doc/Makefile src/Makefile src/IO/Makefile) --- dillo/lib/Makefile.am.orig Tue Aug 26 17:01:22 2003 +++ dillo/lib/Makefile.am Tue Aug 26 17:06:20 2003 @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libdillo.a +noinst_HEADERS = mkdtemp.h + +libdillo_a_SOURCES = +libdillo_a_LIBADD = @LIBOBJS@ +libdillo_a_DEPENDENCIES = $(libdillo_a_LIBADD) + +EXTRADIST = mkdtemp.c --- dillo/lib/mkdtemp.c.orig Tue Aug 26 17:01:22 2003 +++ dillo/lib/mkdtemp.c Tue Aug 26 17:01:22 2003 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +char * +mkdtemp(char *path) +{ + char *start, *trv; + pid_t pid; + int rval; + struct stat sbuf; + + if (!path) + return (char*)NULL; + + for (trv = path; *trv; ++trv) + ; + trv--; + if (trv < path) + return (char*)NULL; + pid = getpid(); + while (trv >= path && *trv == 'X' && pid != 0) { + *trv-- = (pid % 10) + '0'; + pid /= 10; + } + while (trv >= path && *trv == 'X') { + char c; + pid = rand() % (26+26); + if (pid < 26) + c = pid + 'A'; + else + c = (pid - 26) + 'a'; + *trv-- = c; + } + start = trv + 1; + + /* + * check the target directory; if you have six X's and it + * doesn't exist this runs for a *very* long time. + */ + for (;; --trv) { + if (trv <= path) + break; + if (*trv == '/') { + *trv = '\0'; + rval = stat(path,&sbuf); + *trv = '/'; + if (rval != 0) + return (char*)NULL; + if (!S_ISDIR(sbuf.st_mode)) { + errno = ENOTDIR; + return (char*)NULL; + } + break; + } + } + + for (;;) { + if (mkdir(path,0700) == 0) + return path; + if (errno != EEXIST) + return (char*)NULL; + for (trv = start;;) { + if (!*trv) + return (char*)NULL; + if (*trv == 'Z') + *trv++ = 'a'; + else { + if (isdigit(*trv)) + *trv = 'a'; + else if (*trv == 'z') /* inc from z to A */ + *trv = 'A'; + else { + ++*trv; + } + break; + } + } + } + /*NOTREACHED*/ +} --- dillo/lib/mkdtemp.h.orig Tue Aug 26 17:06:04 2003 +++ dillo/lib/mkdtemp.h Tue Aug 26 17:01:22 2003 @@ -0,0 +1,6 @@ +#ifndef Mkdtemp_Header +#define Mkdtemp_Header + +char * mkdtemp(char*); + +#endif