dgaudet     98/06/04 13:28:31

  Modified:    src      CHANGES
               src/support htpasswd.c
  Log:
  remove the system() call...
  
  PR:           2332
  Submitted by: "M.D.Parker" <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.886     +3 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.885
  retrieving revision 1.886
  diff -u -r1.885 -r1.886
  --- CHANGES   1998/06/04 20:13:11     1.885
  +++ CHANGES   1998/06/04 20:28:29     1.886
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3.1
   
  +  *) Remove the system() call from htpasswd.c, which eliminates a system
  +     dependancy.  ["M.D.Parker" <[EMAIL PROTECTED]>] PR#2332
  +
     *) PORT: Fix compilation failures on NEXTSTEP.
        [Rex Dieter <[EMAIL PROTECTED]>] PR#2293, 2316
   
  
  
  
  1.16      +13 -9     apache-1.3/src/support/htpasswd.c
  
  Index: htpasswd.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/support/htpasswd.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- htpasswd.c        1998/04/21 20:14:06     1.15
  +++ htpasswd.c        1998/06/04 20:28:31     1.16
  @@ -161,7 +161,7 @@
       if (argc == 4) {
        if (strcmp(argv[1], "-c"))
            usage();
  -     if (!(tfp = fopen(argv[2], "w"))) {
  +      if (!(tfp = fopen(argv[2], "w+"))) {
            fprintf(stderr, "Could not open passwd file %s for writing.\n",
                    argv[2]);
            perror("fopen");
  @@ -176,12 +176,12 @@
        usage();
   
       tn = tmpnam(NULL);
  -    if (!(tfp = fopen(tn, "w"))) {
  +    if (!(tfp = fopen(tn, "w+"))) {
        fprintf(stderr, "Could not open temp file.\n");
        exit(1);
       }
   
  -    if (!(f = fopen(argv[1], "r"))) {
  +    if (!(f = fopen(argv[1], "r+"))) {
        fprintf(stderr,
                "Could not open passwd file %s for reading.\n", argv[1]);
        fprintf(stderr, "Use -c option to create new one.\n");
  @@ -211,14 +211,18 @@
        printf("Adding user %s\n", user);
        add_password(user, tfp);
       }
  +/*
  +* make a copy from the tmp file to the actual file
  +*/  
  +        rewind(f);
  +        rewind(tfp);
  +        while ( fgets(command,MAX_STRING_LEN,tfp) != NULL)
  +        {
  +                fputs(command,f);
  +        } 
  +
       fclose(f);
       fclose(tfp);
  -#if defined(__EMX__) || defined(WIN32)
  -    sprintf(command, "copy \"%s\" \"%s\"", tn, argv[1]);
  -#else
  -    sprintf(command, "cp %s %s", tn, argv[1]);
  -#endif
  -    system(command);
       unlink(tn);
       exit(0);
   }
  
  
  

Reply via email to