httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: httpd-2.0/support htpasswd.c
Date Tue, 08 Oct 2002 01:15:46 GMT
rbb         2002/10/07 18:15:46

  Modified:    support  htpasswd.c
  Log:
  We can't just create the temporary file in the current directory.  If that
  directory isn't writable, htpasswd won't work.  This adds a function
  whose responsibility it is to find a valid directory for temporary files.
  
  Revision  Changes    Path
  1.66      +14 -1     httpd-2.0/support/htpasswd.c
  
  Index: htpasswd.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/htpasswd.c,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- htpasswd.c	14 Sep 2002 23:05:42 -0000	1.65
  +++ htpasswd.c	8 Oct 2002 01:15:46 -0000	1.66
  @@ -407,6 +407,18 @@
       }
   }
   
  +static const char *get_tempname(apr_pool_t *p)
  +{
  +    char tn[] = "htpasswd.tmp.XXXXXX";
  +    char *dirname;
  +
  +    if (!(dirname = getenv("TEMP")) && !(dirname = getenv("TMPDIR"))) {
  +            dirname = P_tmpdir;
  +    }
  +    dirname = apr_psprintf(p, "%s/%s", dirname, tn);
  +    return dirname;
  +}
  +
   /*
    * Let's do it.  We end up doing a lot of file opening and closing,
    * but what do we care?  This application isn't run constantly.
  @@ -419,7 +431,7 @@
       char *password = NULL;
       char *pwfilename = NULL;
       char *user = NULL;
  -    char tn[] = "htpasswd.tmp.XXXXXX";
  +    const char *tn;
       char scratch[MAX_STRING_LEN];
       int found = 0;
       int i;
  @@ -533,6 +545,7 @@
        * We can access the files the right way, and we have a record
        * to add or update.  Let's do it..
        */
  +    tn = get_tempname(pool);
       if (apr_file_mktemp(&ftemp, tn, 0, pool) != APR_SUCCESS) {
           apr_file_printf(errfile, "%s: unable to create temporary file %s\n", 
                           argv[0], tn);
  
  
  

Mime
View raw message