don't redefine _PATH_TMP; don't assume it begins "/tmp/";
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 28 Aug 1990 04:42:55 +0000 (20:42 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 28 Aug 1990 04:42:55 +0000 (20:42 -0800)
tmpfile => tempfile for System V

SCCS-vsn: usr.bin/rdist/main.c 5.6
SCCS-vsn: usr.bin/rdist/server.c 5.13
SCCS-vsn: usr.bin/rdist/docmd.c 5.7
SCCS-vsn: usr.bin/rdist/defs.h 5.9
SCCS-vsn: usr.bin/rdist/pathnames.h 5.4

usr/src/usr.bin/rdist/defs.h
usr/src/usr.bin/rdist/docmd.c
usr/src/usr.bin/rdist/main.c
usr/src/usr.bin/rdist/pathnames.h
usr/src/usr.bin/rdist/server.c

index 4bbbfeb..9a2b34a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)defs.h      5.8 (Berkeley) %G%
+ *     @(#)defs.h      5.9 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -113,7 +113,7 @@ extern int options;         /* global options */
 extern int nerrs;              /* number of errors seen */
 extern int rem;                        /* remote file descriptor */
 extern int iamremote;          /* acting as remote server */
 extern int nerrs;              /* number of errors seen */
 extern int rem;                        /* remote file descriptor */
 extern int iamremote;          /* acting as remote server */
-extern char tmpfile[];         /* file name for logging changes */
+extern char tempfile[];                /* file name for logging changes */
 extern struct linkbuf *ihead;  /* list of files with more than one link */
 extern struct passwd *pw;      /* pointer to static area used by getpwent */
 extern struct group *gr;       /* pointer to static area used by getgrent */
 extern struct linkbuf *ihead;  /* list of files with more than one link */
 extern struct passwd *pw;      /* pointer to static area used by getpwent */
 extern struct group *gr;       /* pointer to static area used by getgrent */
index 5ac37ec..f7fe6c5 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)docmd.c    5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)docmd.c    5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "defs.h"
 #endif /* not lint */
 
 #include "defs.h"
@@ -107,8 +107,8 @@ doarrow(filev, files, rhost, cmds)
                signal(SIGPIPE, lostconn);
                if (!makeconn(rhost))
                        return;
                signal(SIGPIPE, lostconn);
                if (!makeconn(rhost))
                        return;
-               if ((lfp = fopen(tmpfile, "w")) == NULL) {
-                       fatal("cannot open %s\n", tmpfile);
+               if ((lfp = fopen(tempfile, "w")) == NULL) {
+                       fatal("cannot open %s\n", tempfile);
                        exit(1);
                }
        }
                        exit(1);
                }
        }
@@ -142,9 +142,9 @@ done:
        }
        for (sc = cmds; sc != NULL; sc = sc->sc_next)
                if (sc->sc_type == NOTIFY)
        }
        for (sc = cmds; sc != NULL; sc = sc->sc_next)
                if (sc->sc_type == NOTIFY)
-                       notify(tmpfile, rhost, sc->sc_args, 0);
+                       notify(tempfile, rhost, sc->sc_args, 0);
        if (!nflag) {
        if (!nflag) {
-               (void) unlink(tmpfile);
+               (void) unlink(tempfile);
                for (; ihead != NULL; ihead = ihead->nextp) {
                        free(ihead);
                        if ((opts & IGNLNKS) || ihead->count == 0)
                for (; ihead != NULL; ihead = ihead->nextp) {
                        free(ihead);
                        if ((opts & IGNLNKS) || ihead->count == 0)
@@ -319,7 +319,7 @@ dodcolon(filev, files, stamp, cmds)
        if (nflag || (options & VERIFY))
                tfp = NULL;
        else {
        if (nflag || (options & VERIFY))
                tfp = NULL;
        else {
-               if ((tfp = fopen(tmpfile, "w")) == NULL) {
+               if ((tfp = fopen(tempfile, "w")) == NULL) {
                        error("%s: %s\n", stamp, strerror(errno));
                        return;
                }
                        error("%s: %s\n", stamp, strerror(errno));
                        return;
                }
@@ -344,9 +344,9 @@ dodcolon(filev, files, stamp, cmds)
                (void) fclose(tfp);
        for (sc = cmds; sc != NULL; sc = sc->sc_next)
                if (sc->sc_type == NOTIFY)
                (void) fclose(tfp);
        for (sc = cmds; sc != NULL; sc = sc->sc_next)
                if (sc->sc_type == NOTIFY)
-                       notify(tmpfile, NULL, sc->sc_args, lastmod);
+                       notify(tempfile, NULL, sc->sc_args, lastmod);
        if (!nflag && !(options & VERIFY))
        if (!nflag && !(options & VERIFY))
-               (void) unlink(tmpfile);
+               (void) unlink(tempfile);
 }
 
 /*
 }
 
 /*
index a445956..fd426db 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "defs.h"
 #endif /* not lint */
 
 #include "defs.h"
@@ -24,8 +24,9 @@ static char sccsid[] = "@(#)main.c    5.5 (Berkeley) %G%";
  */
 
 char   *distfile = NULL;
  */
 
 char   *distfile = NULL;
-char   tmpfile[] = _PATH_TMP;
-char   *tmpname = &tmpfile[5];
+#define _RDIST_TMP     "/rdistXXXXXX"
+char   tempfile[sizeof _PATH_TMP + sizeof _RDIST_TMP + 1];
+char   *tempname;
 
 int    debug;          /* debugging flag */
 int    nflag;          /* NOP flag, just print commands without executing */
 
 int    debug;          /* debugging flag */
 int    nflag;          /* NOP flag, just print commands without executing */
@@ -62,6 +63,12 @@ main(argc, argv)
        strcpy(homedir, pw->pw_dir);
        groupid = pw->pw_gid;
        gethostname(host, sizeof(host));
        strcpy(homedir, pw->pw_dir);
        groupid = pw->pw_gid;
        gethostname(host, sizeof(host));
+       strcpy(tempfile, _PATH_TMP);
+       strcat(tempfile, _RDIST_TMP);
+       if ((tempname = rindex(tempfile, '/')) != 0)
+               tempname++;
+       else
+               tempname = tempfile;
 
        while (--argc > 0) {
                if ((arg = *++argv)[0] != '-')
 
        while (--argc > 0) {
                if ((arg = *++argv)[0] != '-')
@@ -153,7 +160,7 @@ main(argc, argv)
        *hp = NULL;
 
        setreuid(0, userid);
        *hp = NULL;
 
        setreuid(0, userid);
-       mktemp(tmpfile);
+       mktemp(tempfile);
 
        if (iamremote) {
                server();
 
        if (iamremote) {
                server();
index 42605ad..9a4b290 100644 (file)
@@ -4,11 +4,9 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pathnames.h 5.3 (Berkeley) %G%
+ *     @(#)pathnames.h 5.4 (Berkeley) %G%
  */
 
 #include <paths.h>
 
 #define        _PATH_RDIST     "rdist"
  */
 
 #include <paths.h>
 
 #define        _PATH_RDIST     "rdist"
-#undef _PATH_TMP
-#define        _PATH_TMP       "/tmp/rdistXXXXXX"
index 95b6693..534bf09 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)server.c   5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)server.c   5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "defs.h"
 #endif /* not lint */
 
 #include "defs.h"
@@ -652,7 +652,7 @@ recvf(cmd, type)
        struct timeval tvp[2];
        char *owner, *group;
        char new[BUFSIZ];
        struct timeval tvp[2];
        char *owner, *group;
        char new[BUFSIZ];
-       extern char *tmpname;
+       extern char *tempname;
 
        cp = cmd;
        opts = 0;
 
        cp = cmd;
        opts = 0;
@@ -747,12 +747,12 @@ recvf(cmd, type)
                (void) sprintf(tp, "/%s", cp);
        cp = rindex(target, '/');
        if (cp == NULL)
                (void) sprintf(tp, "/%s", cp);
        cp = rindex(target, '/');
        if (cp == NULL)
-               strcpy(new, tmpname);
+               strcpy(new, tempname);
        else if (cp == target)
        else if (cp == target)
-               (void) sprintf(new, "/%s", tmpname);
+               (void) sprintf(new, "/%s", tempname);
        else {
                *cp = '\0';
        else {
                *cp = '\0';
-               (void) sprintf(new, "%s/%s", target, tmpname);
+               (void) sprintf(new, "%s/%s", target, tempname);
                *cp = '/';
        }
 
                *cp = '/';
        }
 
@@ -1463,7 +1463,7 @@ response()
  */
 cleanup()
 {
  */
 cleanup()
 {
-       (void) unlink(tmpfile);
+       (void) unlink(tempfile);
        exit(1);
 }
 
        exit(1);
 }