]> granicus.if.org Git - apache/commitdiff
Use apr_temp_dir_get() to get the temporary directory
authorBradley Nicholes <bnicholes@apache.org>
Wed, 17 Mar 2004 00:04:35 +0000 (00:04 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Wed, 17 Mar 2004 00:04:35 +0000 (00:04 +0000)
Submitted by: Guenter Knauf <eflash@gmx.net>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102998 13f79535-47bb-0310-9956-ffa450edef68

support/htdigest.c

index e0801b1687cba7ac276c9a5ff6c0150cc6701794..56917d59280b0363a12fb6930e6e304b502fa9a5 100644 (file)
@@ -208,6 +208,7 @@ int main(int argc, const char * const argv[])
     apr_file_t *f;
     apr_status_t rv;
     char tn[] = "htdigest.tmp.XXXXXX";
+    char *dirname;
     char user[MAX_STRING_LEN];
     char realm[MAX_STRING_LEN];
     char line[MAX_STRING_LEN];
@@ -251,7 +252,14 @@ int main(int argc, const char * const argv[])
     else if (argc != 4)
        usage();
 
-    if (apr_file_mktemp(&tfp, tn,
+    if (apr_temp_dir_get((const char**)&dirname, cntxt) != APR_SUCCESS) {
+        fprintf(stderr, "%s: could not determine temp dir\n",
+                        argv[0]);
+        exit(1);
+    }
+    dirname = apr_psprintf(cntxt, "%s/%s", dirname, tn);
+
+    if (apr_file_mktemp(&tfp, dirname,
 #ifdef OMIT_DELONCLOSE
     APR_CREATE | APR_READ | APR_WRITE | APR_EXCL
 #else
@@ -296,15 +304,15 @@ int main(int argc, const char * const argv[])
     }
     apr_file_close(f);
 #if defined(OS2) || defined(WIN32)
-    sprintf(command, "copy \"%s\" \"%s\"", tn, argv[1]);
+    sprintf(command, "copy \"%s\" \"%s\"", dirname, argv[1]);
 #else
-    sprintf(command, "cp %s %s", tn, argv[1]);
+    sprintf(command, "cp %s %s", dirname, argv[1]);
 #endif
 
 #ifdef OMIT_DELONCLOSE
     apr_file_close(tfp);
     system(command);
-    apr_file_remove(tn, cntxt);
+    apr_file_remove(dirname, cntxt);
 #else
     system(command);
     apr_file_close(tfp);