ANSI fixes (two real bug fixes!), convert to struct dirent, cleanups
[unix-history] / usr / src / libexec / bugfiler / bugfiler.c
index 10c90c4..5e0a698 100644 (file)
@@ -2,12 +2,7 @@
  * Copyright (c) 1983, 1986, 1987 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983, 1986, 1987 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -17,19 +12,23 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)bugfiler.c 5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)bugfiler.c 5.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-
 /*
  * Bug report processing program, designed to be invoked
  * through aliases(5).
  */
 /*
  * Bug report processing program, designed to be invoked
  * through aliases(5).
  */
-#include <bug.h>
+#include <sys/param.h>
 #include <sys/time.h>
 #include <sys/time.h>
-#include <sys/file.h>
+#include <sys/stat.h>
+#include <dirent.h>
 #include <pwd.h>
 #include <pwd.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "bug.h"
 
 char   bfr[MAXBSIZE],                  /* general I/O buffer */
        tmpname[sizeof(TMP_BUG) + 5];   /* temp bug file */
 
 char   bfr[MAXBSIZE],                  /* general I/O buffer */
        tmpname[sizeof(TMP_BUG) + 5];   /* temp bug file */
@@ -43,9 +42,8 @@ main(argc, argv)
        register int    ch;             /* getopts char */
        int     do_ack,                 /* acknowledge bug report */
                do_redist;              /* redistribut BR */
        register int    ch;             /* getopts char */
        int     do_ack,                 /* acknowledge bug report */
                do_redist;              /* redistribut BR */
-       char    *argversion,            /* folder name provided */
-               *strcpy();
-       struct passwd   *getpwnam();
+       char    *argversion;            /* folder name provided */
+       static void logit(), make_copy();
 
        do_ack = do_redist = YES;
        argversion = NULL;
 
        do_ack = do_redist = YES;
        argversion = NULL;
@@ -86,7 +84,7 @@ main(argc, argv)
 
        process();
 
 
        process();
 
-       if (setuid(0, 0))
+       if (setuid(0))
                error("can't set id to root.", CHN);
        if (do_ack)
                reply();
                error("can't set id to root.", CHN);
        if (do_ack)
                reply();
@@ -100,17 +98,15 @@ main(argc, argv)
  * make_copy --
  *     make a copy of bug report in error folder
  */
  * make_copy --
  *     make a copy of bug report in error folder
  */
-static
+static void
 make_copy()
 {
        register int    cnt,                    /* read return value */
                        tfd;                    /* temp file descriptor */
        char    *strcpy();
 
 make_copy()
 {
        register int    cnt,                    /* read return value */
                        tfd;                    /* temp file descriptor */
        char    *strcpy();
 
-       if (access(TMP_DIR, F_OK)) {
-               (void)mkdir(TMP_DIR);
-               (void)chmod(TMP_DIR, 0775);
-       }
+       if (access(TMP_DIR, F_OK))
+               (void)mkdir(TMP_DIR, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
        (void)strcpy(tmpname, TMP_BUG);
        if (tfd = mkstemp(tmpname)) {
                while ((cnt = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && cnt)
        (void)strcpy(tmpname, TMP_BUG);
        if (tfd = mkstemp(tmpname)) {
                while ((cnt = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && cnt)
@@ -125,7 +121,7 @@ make_copy()
  * logit --
  *     log this run of the bugfiler
  */
  * logit --
  *     log this run of the bugfiler
  */
-static
+static void
 logit()
 {
        struct timeval  tp;
 logit()
 {
        struct timeval  tp;