httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bnicho...@apache.org
Subject cvs commit: httpd-2.0/support htpasswd.c
Date Mon, 29 Mar 2004 23:51:44 GMT
bnicholes    2004/03/29 15:51:44

  Modified:    .        Tag: APACHE_2_0_BRANCH STATUS
               support  Tag: APACHE_2_0_BRANCH htpasswd.c
  Log:
  Use apr_temp_dir_get for htpasswd
  
  Submitted by: Guenter Knauf <eflash gmx.net>
  Reviewed by: thommay, bnicholes, jjclar
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.751.2.785 +1 -5      httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.751.2.784
  retrieving revision 1.751.2.785
  diff -u -r1.751.2.784 -r1.751.2.785
  --- STATUS	29 Mar 2004 23:43:29 -0000	1.751.2.784
  +++ STATUS	29 Mar 2004 23:51:43 -0000	1.751.2.785
  @@ -110,10 +110,6 @@
              modules/dav/fs/lock.c: r1.31
          +1: trawick
   
  -    *) Use apr_temp_dir_get for htpasswd
  -       support/htpasswd.c: 1.75
  -       +1: thommay, bnicholes, jjclar
  -
       *) Allow Satisfy directives to be influenced by <Limit>.
          PR: 14726
            include/http_core.h: r1.81
  
  
  
  No                   revision
  No                   revision
  1.67.2.7  +17 -24    httpd-2.0/support/htpasswd.c
  
  Index: htpasswd.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/htpasswd.c,v
  retrieving revision 1.67.2.6
  retrieving revision 1.67.2.7
  diff -u -r1.67.2.6 -r1.67.2.7
  --- htpasswd.c	9 Feb 2004 20:59:49 -0000	1.67.2.6
  +++ htpasswd.c	29 Mar 2004 23:51:44 -0000	1.67.2.7
  @@ -261,12 +261,13 @@
       return ((check || sbuf.filetype != APR_REG) ? 0 : 1);
   }
   
  -#ifdef NETWARE
  -void nwTerminate()
  +static void terminate(void)
   {
  +    apr_terminate();
  +#ifdef NETWARE
       pressanykey();
  -}
   #endif
  +}
   
   static void check_args(apr_pool_t *pool, int argc, const char *const argv[], 
                          int *alg, int *mask, char **user, char **pwfilename, 
  @@ -379,18 +380,6 @@
       }
   }
   
  -static 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.
  @@ -403,7 +392,8 @@
       char *password = NULL;
       char *pwfilename = NULL;
       char *user = NULL;
  -    char *tn;
  +    char tn[] = "htpasswd.tmp.XXXXXX";
  +    char *dirname;
       char scratch[MAX_STRING_LEN];
       int found = 0;
       int i;
  @@ -417,10 +407,7 @@
   #endif
   
       apr_app_initialize(&argc, &argv, NULL);
  -    atexit(apr_terminate);
  -#ifdef NETWARE
  -    atexit(nwTerminate);
  -#endif
  +    atexit(terminate);
       apr_pool_create(&pool, NULL);
       apr_file_open_stderr(&errfile, pool);
   
  @@ -519,10 +506,16 @@
        * 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) {
  +    if (apr_temp_dir_get((const char**)&dirname, pool) != APR_SUCCESS) {
  +        apr_file_printf(errfile, "%s: could not determine temp dir\n",
  +                        argv[0]);
  +        exit(ERR_FILEPERM);
  +    }
  +    dirname = apr_psprintf(pool, "%s/%s", dirname, tn);
  +
  +    if (apr_file_mktemp(&ftemp, dirname, 0, pool) != APR_SUCCESS) {
           apr_file_printf(errfile, "%s: unable to create temporary file %s\n", 
  -                        argv[0], tn);
  +                        argv[0], dirname);
           exit(ERR_FILEPERM);
       }
   
  @@ -600,7 +593,7 @@
   
       /* The temporary file has all the data, just copy it to the new location.
        */
  -    if (apr_file_copy(tn, pwfilename, APR_FILE_SOURCE_PERMS, pool) !=
  +    if (apr_file_copy(dirname, pwfilename, APR_FILE_SOURCE_PERMS, pool) !=
           APR_SUCCESS) {
           apr_file_printf(errfile, "%s: unable to update file %s\n", 
                           argv[0], pwfilename);
  
  
  

Mime
View raw message