Files debianutils-1.16.7.orig/mktemp and debianutils-1.16.7/mktemp differ diff -Nru debianutils-1.16.7.orig/mktemp.c debianutils-1.16.7/mktemp.c --- debianutils-1.16.7.orig/mktemp.c 2002-09-28 12:17:03.000000000 -0700 +++ debianutils-1.16.7/mktemp.c 2005-02-18 20:31:48.789710000 -0800 @@ -31,14 +31,26 @@ static const char rcsid[] = "$OpenBSD: mktemp.c,v 1.8 2002/02/16 21:27:49 millert Exp $"; #endif /* not lint */ +#if defined(sun) +#define _PATH_TMP "/tmp" +#else #include +#endif #include #include #include #include +#if defined(sun) +#define warn printf +#define warnx printf +#include +#include +#include +#else #include +#endif -void usage(void); +void usage(char *progname); int main(argc, argv) @@ -48,6 +60,10 @@ int ch, fd, uflag = 0, quiet = 0, tflag = 0, makedir = 0; char *cp, *template, *tempfile, *prefix = _PATH_TMP; size_t plen; +#if defined(sun) + int retries=10; + char rndm[256]; +#endif while ((ch = getopt(argc, argv, "dp:qtu")) != -1) switch(ch) { @@ -68,7 +84,7 @@ uflag = 1; break; default: - usage(); + usage(argv[0]); } /* If no template specified use a default one (implies -t mode) */ @@ -81,7 +97,7 @@ tflag = 1; break; default: - usage(); + usage(argv[0]); } if (tflag) { @@ -116,11 +132,36 @@ } if (makedir) { +#if defined(sun) + while (retries) + { + srandom((unsigned int)getpid()); + sprintf(rndm,"%d%d%d%d%d%d",random(),random(),random(), + random(),random(),random()); + strncpy(tempfile+strlen(tempfile)-6, rndm, 6); + if (mkdir(tempfile, S_IRWXU) < 0) + { + if (errno != EEXIST) + { + if (!quiet) warn("cannot make temp dir %s", tempfile); + exit(1); + } + retries--; + } + else break; + } + if (!retries) + { + if (!quiet) warn("cannot make temp dir %s", tempfile); + exit(1); + } +#else if (mkdtemp(tempfile) == NULL) { if (!quiet) warn("cannot make temp dir %s", tempfile); exit(1); } +#endif if (uflag) (void)rmdir(tempfile); @@ -143,11 +184,9 @@ } void -usage() +usage(char *progname) { - extern char *__progname; - (void)fprintf(stderr, - "Usage: %s [-dqtu] [-p prefix] [template]\n", __progname); + "Usage: %s [-dqtu] [-p prefix] [template]\n", progname); exit(1); } Files debianutils-1.16.7.orig/run-parts and debianutils-1.16.7/run-parts differ diff -Nru debianutils-1.16.7.orig/run-parts.c debianutils-1.16.7/run-parts.c --- debianutils-1.16.7.orig/run-parts.c 2005-02-18 20:29:31.573295000 -0800 +++ debianutils-1.16.7/run-parts.c 2005-02-18 20:31:30.599038000 -0800 @@ -20,7 +20,9 @@ #include #include #include +#if !defined(sun) #include +#endif #include #include #include @@ -38,6 +40,26 @@ int argcount = 0, argsize = 0; char **args = 0; +#if defined(sun) + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + int has_arg; + int *flag; + int val; +}; + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 + +#endif + void error (char *format,...) { va_list ap; @@ -279,6 +301,49 @@ } } +#if defined(sun) + +int scandir(const char *dir, struct dirent ***namelist, + int(*filter)(const struct dirent *), + int(*compar)(const struct dirent **, const struct dirent **)) +{ + DIR *dirp; + struct dirent *dp; + struct dirent **dp_array; + int i=0; + + dirp = opendir(dir); + while (dirp) { + errno = 0; + if ((dp = readdir(dirp)) != NULL) { + if ((strcmp(dp->d_name, ".") != 0) && (strcmp(dp->d_name, "..") != 0) && filter(dp)) { + if (i == 0) + dp_array = (struct dirent **)malloc(sizeof(struct dirent *)); + else + dp_array = (struct dirent **)realloc(dp_array, (i+1)*sizeof(struct dirent *)); + dp_array[i] = (struct dirent *)malloc(sizeof(struct dirent)); + memcpy(dp_array[i], dp, sizeof(struct dirent)); + i++; + } + } else { + if (errno == 0) { + /* we are done, sort and return */ + qsort((void *)dp_array, i, sizeof(struct dirent *), compar); + *namelist = dp_array; + closedir(dirp); + return 0; + } + return -1; + } + } +} + +int alphasort(const struct dirent **s1, const struct dirent **s2) +{ + return strcoll((*s2)->d_name, (*s2)->d_name); +} + +#endif /* sun */ /* Find the parts to run & call run_part() */ void run_parts (char *dirname) @@ -351,6 +416,53 @@ /* Process options */ int main (int argc, char *argv[]) { + +#if defined(sun) + + int i, j, len; + static struct option long_options[] = { + {"test", 0, &test_mode, 't'}, + {"verbose", 0, &verbose_mode, 'V'}, + {"report", 0, &report_mode, 'r'}, + {"umask", 1, 0, 'u'}, + {"arg", 1, 0, 'a'}, + {"help", 0, 0, 'h'}, + {"version", 0, 0, 'v'}, + {0, 0, 0, 0} + }; + + len = sizeof(long_options) / sizeof(struct option); + for (i=1;i #include #include +#if !defined(sun) #include +#endif #include #include #include @@ -10,6 +12,26 @@ char *progname; +#if defined(sun) + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + int has_arg; + int *flag; + int val; +}; + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 + +#endif + void usage (int status) { @@ -54,6 +76,9 @@ int main (int argc, char **argv) { +#if defined(sun) + int i, j, len; +#endif char *name=0, *dir=0, *pfx=0, *sfx=0; mode_t mode = 0600; int fd, optc; @@ -69,7 +94,27 @@ }; progname = argv[0]; +#if defined(sun) + + len = sizeof(long_options) / sizeof(struct option); + for (i=1;i