don't redefine _PATH_TMP; don't assume it begins "/tmp/";
[unix-history] / usr / src / usr.bin / rdist / main.c
index 88b5c5f..fd426db 100644 (file)
@@ -2,17 +2,7 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "defs.h"
 #endif /* not lint */
 
 #include "defs.h"
@@ -34,8 +24,9 @@ static char sccsid[] = "@(#)main.c    5.3 (Berkeley) %G%";
  */
 
 char   *distfile = NULL;
  */
 
 char   *distfile = NULL;
-char   tmpfile[] = "/tmp/rdistXXXXXX";
-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 */
@@ -72,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] != '-')
@@ -163,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();