tmpdir: Ignore environment variables; use effective uid only.
[checkpath] / tmpdir.c
index 943c4d4..b2881c8 100644 (file)
--- a/tmpdir.c
+++ b/tmpdir.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: tmpdir.c,v 1.4 2003/01/25 23:58:44 mdw Exp $
+ * $Id: tmpdir.c,v 1.5 2004/04/08 01:36:22 mdw Exp $
  *
  * Choose and check temporary directories
  *
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: tmpdir.c,v $
- * Revision 1.4  2003/01/25 23:58:44  mdw
- * Make guts into official library.
- *
- * Revision 1.3  1999/05/21 22:07:20  mdw
- * Take advantage of new dynamic string macros.
- *
- * Revision 1.2  1999/05/19 20:37:28  mdw
- * Track gratuitous change in mdwopt interface.
- *
- * Revision 1.1.1.1  1999/04/06 20:12:07  mdw
- * Import new project.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <errno.h>
@@ -222,16 +205,12 @@ static char *goodtmp(void)
 
   /* --- Try making a directory in `/tmp' --- */
 
-  if (!(q = getenv("USER")) && !(q = getenv("LOGNAME")))
-    q = pw->pw_name;
-  if ((q = trytmp("/tmp", q)) != 0)
+  if ((q = trytmp("/tmp", pw->pw_name)) != 0)
     return (q);
 
   /* --- That failed: try a directory in the user's home --- */
 
-  if (!(q = getenv("HOME")))
-    q = pw->pw_dir;
-  if ((q = trytmp(q, "tmp")) != 0)
+  if ((q = trytmp(pw->pw_dir, "tmp")) != 0)
     return (q);
 
   /* --- Still no joy: give up --- *
@@ -311,7 +290,7 @@ int main(int argc, char *argv[])
   /* --- Initialize variables --- */
 
   ego(argv[0]);
-  me = getuid();
+  me = geteuid();
   cp.cp_what = CP_WRWORLD | CP_WRGRP | CP_WROTHUSR | CP_STICKYOK;
   cp.cp_verbose = 0;
   cp.cp_report = 0;