You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by ml...@swl.msd.ray.com on 2000/07/24 19:46:48 UTC

[patch for htpasswd bug on HP-UX 11 (fopen, tmpnam)]

Greg Stein suggested I send these patches to this address.  I hope deja hasn't mangled it.

--Milton L. Hankins  ><>

------------------------------------------------------------------------------

This message was forwarded to you from Deja.com by mlh@swl.msd.ray.com.
Deja.com offers free consumer information, including ratings and reviews on
thousands of products and services.  Before you buy, visit 
http://www.deja.com/%5bST_rn%3dps%5d/
------------------------------------------------------------------------------

(beginning of original message)

Subject: Apache 1.3.12: Unofficial patch for htpasswd bug on HP-UX 11 (fopen, tmpnam)
From: "Milton L. Hankins" <ml...@swl.msd.ray.com>
Date: 2000/06/30
Newsgroups: comp.infosystems.www.servers.unix
This is my fix for the bug regarding tmpnam in htpasswd which presents 
itself in HP-UX 11.  It addresses PR numbers 6185, 5558, and 5383.  This 
will be fixed in future versions of Apache.  I am posting it now because 
I haven't found patches in either the bug database or in past Usenet 
posts for the current version.

Problem description:  htpasswd -c doesn't work under HP-UX 11.  It fails 
with these messages:

	htpasswd: unable to create temporary file
	fopen: No such file or directory

Reason:  HP-UX's implementation of tmpnam(NULL) is rendered useless in a 
multi-threading environment.  htpasswd.c expects useful values 
tmpnam(NULL).

Solution:  Pass a buffer argument to tmpnam instead of NULL in 
src/support/htpasswd.c.

Patch follows.

-----8<-----cut here---------------------------------------------------
*** src/support/htpasswd.c.dist	Thu Oct 21 16:46:32 1999
--- src/support/htpasswd.c	Thu Jun 29 14:40:06 2000
***************
*** 119,125 ****
   * This needs to be declared statically so the signal handler can
   * access it.
   */
! static char *tempfilename;
  
  /*
   * Get a line of input from the user, not including any terminating
--- 119,125 ----
   * This needs to be declared statically so the signal handler can
   * access it.
   */
! static char tempfilename[L_tmpnam] = "";
  
  /*
   * Get a line of input from the user, not including any terminating
***************
*** 266,272 ****
  static void interrupted(void)
  {
      fprintf(stderr, "Interrupted.\n");
!     if (tempfilename != NULL) {
  	unlink(tempfilename);
      }
      exit(ERR_INTERRUPTED);
--- 266,272 ----
  static void interrupted(void)
  {
      fprintf(stderr, "Interrupted.\n");
!     if (tempfilename[0] != '\0') {
  	unlink(tempfilename);
      }
      exit(ERR_INTERRUPTED);
***************
*** 358,364 ****
      int i;
      int args_left = 2;
  
!     tempfilename = NULL;
      signal(SIGINT, (void (*)(int)) interrupted);
  
      /*
--- 358,364 ----
      int i;
      int args_left = 2;
  
!     tempfilename[0] = '\0';
      signal(SIGINT, (void (*)(int)) interrupted);
  
      /*
***************
*** 516,525 ****
       * We can access the files the right way, and we have a record
       * to add or update.  Let's do it..
       */
!     tempfilename = tmpnam(NULL);
      ftemp = fopen(tempfilename, "w+");
      if (ftemp == NULL) {
! 	fprintf(stderr, "%s: unable to create temporary file\n", argv[0]);
  	perror("fopen");
  	exit(ERR_FILEPERM);
      }
--- 516,525 ----
       * We can access the files the right way, and we have a record
       * to add or update.  Let's do it..
       */
!     tmpnam(tempfilename);
      ftemp = fopen(tempfilename, "w+");
      if (ftemp == NULL) {
! 	fprintf(stderr, "%s: unable to create temporary file \"%s\"\n", argv[0], tempfilename);
  	perror("fopen");
  	exit(ERR_FILEPERM);
      }
-----8<-----cut here---------------------------------------------------

--
              Milton L. Hankins              \\  ><> Ephesians 5:2 ><>
      http://www.snurgle.org/~mhankins       //  <ml...@swl.msd.ray.com>
    These are my opinions, not Raytheon's.   \\      W. W. J. D. ?



(end of original message)
------------------------------------------------------------------------------

You can view this message and the related discussion by following this link:
http://www.deja.com/%5bST_rn%3dps%5d/dnquery.xp?search=thread&svcclass=dnserver&recnum=%3cPine.SGI.4.21.0006301759490.62059-100000@masox201.msd.ray.com%3e%231/1
We hope to see you soon at Deja.com.
Before you buy.
http://www.deja.com/%5bST_rn%3dps%5d/