randy       97/09/14 15:48:14

  Modified:    src/support cls.c htdigest.c htpasswd.c logresolve.c
                        rotatelogs.c suexec.c suexec.h
  Log:
  indent
  
  Revision  Changes    Path
  1.4       +66 -65    apachen/src/support/cls.c
  
  Index: cls.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/cls.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- cls.c     1996/11/03 21:02:30     1.3
  +++ cls.c     1997/09/14 22:48:08     1.4
  @@ -14,150 +14,151 @@
    *   * - swallow remaining characters 
    *  <x> - exact match for any other character
    */
  -static int
  -checkmask(const char *data, const char *mask)
  +static int checkmask(const char *data, const char *mask)
   {
       int i, ch, d;
   
  -    for (i=0; mask[i] != '\0' && mask[i] != '*'; i++)
  -    {
  +    for (i = 0; mask[i] != '\0' && mask[i] != '*'; i++) {
        ch = mask[i];
        d = data[i];
  -     if (ch == '@')
  -     {
  -         if (!isupper(d)) return 0;
  -     } else if (ch == '$')
  -     {
  -         if (!islower(d)) return 0;
  -     } else if (ch == '#')
  -     {
  -         if (!isdigit(d)) return 0;
  -     } else if (ch == '&')
  -     {
  -         if (!isxdigit(d)) return 0;
  -     } else if (ch != d) return 0;
  +     if (ch == '@') {
  +         if (!isupper(d))
  +             return 0;
  +     }
  +     else if (ch == '$') {
  +         if (!islower(d))
  +             return 0;
  +     }
  +     else if (ch == '#') {
  +         if (!isdigit(d))
  +             return 0;
  +     }
  +     else if (ch == '&') {
  +         if (!isxdigit(d))
  +             return 0;
  +     }
  +     else if (ch != d)
  +         return 0;
       }
   
  -    if (mask[i] == '*') return 1;
  -    else return (data[i] == '\0');
  +    if (mask[i] == '*')
  +     return 1;
  +    else
  +     return (data[i] == '\0');
   }
   
   /*
    * Converts 8 hex digits to a time integer
    */
  -static int
  -hex2sec(const char *x)
  +static int hex2sec(const char *x)
   {
       int i, ch;
       unsigned int j;
   
  -    for (i=0, j=0; i < 8; i++)
  -    {
  +    for (i = 0, j = 0; i < 8; i++) {
        ch = x[i];
        j <<= 4;
  -     if (isdigit(ch)) j |= ch - '0';
  -     else if (isupper(ch)) j |= ch - ('A' - 10);
  -     else j |= ch - ('a' - 10);
  +     if (isdigit(ch))
  +         j |= ch - '0';
  +     else if (isupper(ch))
  +         j |= ch - ('A' - 10);
  +     else
  +         j |= ch - ('a' - 10);
       }
  -    if (j == 0xffffffff) return -1;  /* so that it works with 8-byte ints */
  -    else return j;
  +    if (j == 0xffffffff)
  +     return -1;              /* so that it works with 8-byte ints */
  +    else
  +     return j;
   }
   
  -int
  -main(int argc, char **argv)
  +int main(int argc, char **argv)
   {
       int i, ver;
       DIR *d;
       struct dirent *e;
       const char *s;
       FILE *fp;
  -    char path[FILENAME_MAX+1];
  +    char path[FILENAME_MAX + 1];
       char line[1035];
       time_t date, lmod, expire;
       unsigned int len;
       struct tm ts;
       char sdate[30], slmod[30], sexpire[30];
  -    const char time_format[]="%e %b %Y %R";
  +    const char time_format[] = "%e %b %Y %R";
   
  -    if (argc != 2)
  -    {
  +    if (argc != 2) {
        printf("Usage: cls directory\n");
        exit(0);
       }
   
       d = opendir(argv[1]);
  -    if (d == NULL)
  -    {
  +    if (d == NULL) {
        perror("opendir");
        exit(1);
       }
   
  -    for (;;)
  -    {
  +    for (;;) {
        e = readdir(d);
  -     if (e == NULL) break;
  +     if (e == NULL)
  +         break;
        s = e->d_name;
  -     if (s[0] == '.' || s[0] == '#') continue;
  +     if (s[0] == '.' || s[0] == '#')
  +         continue;
        sprintf(path, "%s/%s", argv[1], s);
        fp = fopen(path, "r");
  -     if (fp == NULL)
  -     {
  +     if (fp == NULL) {
            perror("fopen");
            continue;
        }
  -     if (fgets(line, 1034, fp) == NULL)
  -     {
  +     if (fgets(line, 1034, fp) == NULL) {
            perror("fgets");
            fclose(fp);
            continue;
        }
  -     if (!checkmask(line, "&&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&\n"))
  -     {
  +     if (!checkmask(line, "&&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&\n")) 
{
            fprintf(stderr, "Bad cache file\n");
            fclose(fp);
            continue;
        }
        date = hex2sec(line);
  -     lmod = hex2sec(line+9);
  -     expire = hex2sec(line+18);
  -     ver = hex2sec(line+27);
  -     len = hex2sec(line+35);
  -     if (fgets(line, 1034, fp) == NULL)
  -     {
  +     lmod = hex2sec(line + 9);
  +     expire = hex2sec(line + 18);
  +     ver = hex2sec(line + 27);
  +     len = hex2sec(line + 35);
  +     if (fgets(line, 1034, fp) == NULL) {
            perror("fgets");
            fclose(fp);
            continue;
        }
        fclose(fp);
        i = strlen(line);
  -     if (strncmp(line, "X-URL: ", 7) != 0 || line[i-1] != '\n')
  -     {
  +     if (strncmp(line, "X-URL: ", 7) != 0 || line[i - 1] != '\n') {
            fprintf(stderr, "Bad cache file\n");
            continue;
        }
  -     line[i-1] = '\0';
  -     if (date != -1)
  -     {
  +     line[i - 1] = '\0';
  +     if (date != -1) {
            ts = *gmtime(&date);
            strftime(sdate, 30, time_format, &ts);
  -     } else
  +     }
  +     else
            strcpy(sdate, "-");
   
  -     if (lmod != -1)
  -     {       
  +     if (lmod != -1) {
            ts = *gmtime(&lmod);
            strftime(slmod, 30, time_format, &ts);
  -     } else
  +     }
  +     else
            strcpy(slmod, "-");
   
  -     if (expire != -1)
  -     {
  +     if (expire != -1) {
            ts = *gmtime(&expire);
            strftime(sexpire, 30, time_format, &ts);
  -     } else
  +     }
  +     else
            strcpy(sexpire, "-");
   
  -     printf("%s: %d; %s  %s  %s\n", line+7, ver, sdate, slmod, sexpire);
  +     printf("%s: %d; %s  %s  %s\n", line + 7, ver, sdate, slmod, sexpire);
       }
   
       closedir(d);
  
  
  
  1.11      +104 -91   apachen/src/support/htdigest.c
  
  Index: htdigest.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/htdigest.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- htdigest.c        1997/09/02 16:12:16     1.10
  +++ htdigest.c        1997/09/14 22:48:09     1.11
  @@ -26,53 +26,60 @@
   
   char *tn;
   
  -char *strd(char *s) {
  +char *strd(char *s)
  +{
       char *d;
   
  -    d=(char *)malloc(strlen(s) + 1);
  -    strcpy(d,s);
  -    return(d);
  +    d = (char *) malloc(strlen(s) + 1);
  +    strcpy(d, s);
  +    return (d);
   }
   
  -void getword(char *word, char *line, char stop) {
  -    int x = 0,y;
  +void getword(char *word, char *line, char stop)
  +{
  +    int x = 0, y;
   
  -    for(x=0;((line[x]) && (line[x] != stop));x++)
  -        word[x] = line[x];
  +    for (x = 0; ((line[x]) && (line[x] != stop)); x++)
  +     word[x] = line[x];
   
       word[x] = '\0';
  -    if(line[x]) ++x;
  -    y=0;
  +    if (line[x])
  +     ++x;
  +    y = 0;
   
  -    while((line[y++] = line[x++]));
  +    while ((line[y++] = line[x++]));
   }
   
  -int getline(char *s, int n, FILE *f) {
  -    register int i=0;
  +int getline(char *s, int n, FILE *f)
  +{
  +    register int i = 0;
   
  -    while(1) {
  -        s[i] = (char)fgetc(f);
  +    while (1) {
  +     s[i] = (char) fgetc(f);
   
  -        if(s[i] == CR)
  -            s[i] = fgetc(f);
  +     if (s[i] == CR)
  +         s[i] = fgetc(f);
   
  -        if((s[i] == 0x4) || (s[i] == LF) || (i == (n-1))) {
  -            s[i] = '\0';
  -            return (feof(f) ? 1 : 0);
  -        }
  -        ++i;
  +     if ((s[i] == 0x4) || (s[i] == LF) || (i == (n - 1))) {
  +         s[i] = '\0';
  +         return (feof(f) ? 1 : 0);
  +     }
  +     ++i;
       }
   }
   
  -void putline(FILE *f,char *l) {
  +void putline(FILE *f, char *l)
  +{
       int x;
   
  -    for(x=0;l[x];x++) fputc(l[x],f);
  -    fputc('\n',f);
  +    for (x = 0; l[x]; x++)
  +     fputc(l[x], f);
  +    fputc('\n', f);
   }
   
   
  -void add_password(char *user, char *realm, FILE *f) {
  +void add_password(char *user, char *realm, FILE *f)
  +{
       char *pw;
       AP_MD5_CTX context;
       unsigned char digest[16];
  @@ -80,41 +87,45 @@
       unsigned int i;
   
       pw = strd((char *) getpass("New password:"));
  -    if(strcmp(pw,(char *) getpass("Re-type new password:"))) {
  -        fprintf(stderr,"They don't match, sorry.\n");
  -        if(tn)
  -            unlink(tn);
  -        exit(1);
  +    if (strcmp(pw, (char *) getpass("Re-type new password:"))) {
  +     fprintf(stderr, "They don't match, sorry.\n");
  +     if (tn)
  +         unlink(tn);
  +     exit(1);
       }
  -    fprintf(f,"%s:%s:",user,realm);
  +    fprintf(f, "%s:%s:", user, realm);
   
       /* Do MD5 stuff */
       sprintf(string, "%s:%s:%s", user, realm, pw);
   
  -    MD5Init (&context);
  -    MD5Update (&context, (unsigned char *) string, strlen(string));
  -    MD5Final (digest, &context);
  +    MD5Init(&context);
  +    MD5Update(&context, (unsigned char *) string, strlen(string));
  +    MD5Final(digest, &context);
   
       for (i = 0; i < 16; i++)
  -        fprintf(f, "%02x", digest[i]);
  +     fprintf(f, "%02x", digest[i]);
   
       fprintf(f, "\n");
   }
   
  -void usage() {
  -    fprintf(stderr,"Usage: htdigest [-c] passwordfile realm username\n");
  -    fprintf(stderr,"The -c flag creates a new file.\n");
  +void usage()
  +{
  +    fprintf(stderr, "Usage: htdigest [-c] passwordfile realm username\n");
  +    fprintf(stderr, "The -c flag creates a new file.\n");
       exit(1);
   }
   
  -void interrupted() {
  -    fprintf(stderr,"Interrupted.\n");
  -    if(tn) unlink(tn);
  +void interrupted()
  +{
  +    fprintf(stderr, "Interrupted.\n");
  +    if (tn)
  +     unlink(tn);
       exit(1);
   }
   
  -void main(int argc, char *argv[]) {
  -    FILE *tfp,*f;
  +void main(int argc, char *argv[])
  +{
  +    FILE *tfp, *f;
       char user[MAX_STRING_LEN];
       char realm[MAX_STRING_LEN];
       char line[MAX_STRING_LEN];
  @@ -125,63 +136,65 @@
       int found;
   
       tn = NULL;
  -    signal(SIGINT,(void (*)())interrupted);
  -    if(argc == 5) {
  -        if(strcmp(argv[1],"-c"))
  -            usage();
  -        if(!(tfp = fopen(argv[2],"w"))) {
  -            fprintf(stderr,"Could not open passwd file %s for writing.\n",
  -                    argv[2]);
  -            perror("fopen");
  -            exit(1);
  -        }
  -        printf("Adding password for %s in realm %s.\n",argv[4], argv[3]);
  -        add_password(argv[4],argv[3],tfp);
  -        fclose(tfp);
  -        exit(0);
  -    } else if(argc != 4) usage();
  +    signal(SIGINT, (void (*)()) interrupted);
  +    if (argc == 5) {
  +     if (strcmp(argv[1], "-c"))
  +         usage();
  +     if (!(tfp = fopen(argv[2], "w"))) {
  +         fprintf(stderr, "Could not open passwd file %s for writing.\n",
  +                 argv[2]);
  +         perror("fopen");
  +         exit(1);
  +     }
  +     printf("Adding password for %s in realm %s.\n", argv[4], argv[3]);
  +     add_password(argv[4], argv[3], tfp);
  +     fclose(tfp);
  +     exit(0);
  +    }
  +    else if (argc != 4)
  +     usage();
   
       tn = tmpnam(NULL);
  -    if(!(tfp = fopen(tn,"w"))) {
  -        fprintf(stderr,"Could not open temp file.\n");
  -        exit(1);
  +    if (!(tfp = fopen(tn, "w"))) {
  +     fprintf(stderr, "Could not open temp file.\n");
  +     exit(1);
       }
   
  -    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");
  -        exit(1);
  +    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");
  +     exit(1);
       }
  -    strcpy(user,argv[3]);
  -    strcpy(realm,argv[2]);
  +    strcpy(user, argv[3]);
  +    strcpy(realm, argv[2]);
   
       found = 0;
  -    while(!(getline(line,MAX_STRING_LEN,f))) {
  -        if(found || (line[0] == '#') || (!line[0])) {
  -            putline(tfp,line);
  -            continue;
  -        }
  -        strcpy(l,line);
  -        getword(w,l,':');
  -     getword(x,l,':');
  -        if(strcmp(user,w) || strcmp(realm,x)) {
  -            putline(tfp,line);
  -            continue;
  -        }
  -        else {
  -            printf("Changing password for user %s in realm %s\n",user,realm);
  -            add_password(user,realm,tfp);
  -            found = 1;
  -        }
  -    }
  -    if(!found) {
  -        printf("Adding user %s in realm %s\n",user,realm);
  -        add_password(user,realm,tfp);
  +    while (!(getline(line, MAX_STRING_LEN, f))) {
  +     if (found || (line[0] == '#') || (!line[0])) {
  +         putline(tfp, line);
  +         continue;
  +     }
  +     strcpy(l, line);
  +     getword(w, l, ':');
  +     getword(x, l, ':');
  +     if (strcmp(user, w) || strcmp(realm, x)) {
  +         putline(tfp, line);
  +         continue;
  +     }
  +     else {
  +         printf("Changing password for user %s in realm %s\n", user, realm);
  +         add_password(user, realm, tfp);
  +         found = 1;
  +     }
  +    }
  +    if (!found) {
  +     printf("Adding user %s in realm %s\n", user, realm);
  +     add_password(user, realm, tfp);
       }
       fclose(f);
       fclose(tfp);
  -    sprintf(command,"cp %s %s",tn,argv[1]);
  +    sprintf(command, "cp %s %s", tn, argv[1]);
       system(command);
       unlink(tn);
   }
  
  
  
  1.7       +120 -103  apachen/src/support/htpasswd.c
  
  Index: htpasswd.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/htpasswd.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- htpasswd.c        1997/02/04 23:54:27     1.6
  +++ htpasswd.c        1997/09/14 22:48:09     1.7
  @@ -23,113 +23,128 @@
   
   char *tn;
   
  -char *strd(char *s) {
  +char *strd(char *s)
  +{
       char *d;
   
  -    d=(char *)malloc(strlen(s) + 1);
  -    strcpy(d,s);
  -    return(d);
  +    d = (char *) malloc(strlen(s) + 1);
  +    strcpy(d, s);
  +    return (d);
   }
   
  -void getword(char *word, char *line, char stop) {
  -    int x = 0,y;
  +void getword(char *word, char *line, char stop)
  +{
  +    int x = 0, y;
   
  -    for(x=0;((line[x]) && (line[x] != stop));x++)
  -        word[x] = line[x];
  +    for (x = 0; ((line[x]) && (line[x] != stop)); x++)
  +     word[x] = line[x];
   
       word[x] = '\0';
  -    if(line[x]) ++x;
  -    y=0;
  +    if (line[x])
  +     ++x;
  +    y = 0;
   
  -    while((line[y++] = line[x++]));
  +    while ((line[y++] = line[x++]));
   }
   
  -int getline(char *s, int n, FILE *f) {
  -    register int i=0;
  +int getline(char *s, int n, FILE *f)
  +{
  +    register int i = 0;
   
  -    while(1) {
  -        s[i] = (char)fgetc(f);
  +    while (1) {
  +     s[i] = (char) fgetc(f);
   
  -        if(s[i] == CR)
  -            s[i] = fgetc(f);
  +     if (s[i] == CR)
  +         s[i] = fgetc(f);
   
  -        if((s[i] == 0x4) || (s[i] == LF) || (i == (n-1))) {
  -            s[i] = '\0';
  -            return (feof(f) ? 1 : 0);
  -        }
  -        ++i;
  +     if ((s[i] == 0x4) || (s[i] == LF) || (i == (n - 1))) {
  +         s[i] = '\0';
  +         return (feof(f) ? 1 : 0);
  +     }
  +     ++i;
       }
   }
   
  -void putline(FILE *f,char *l) {
  +void putline(FILE *f, char *l)
  +{
       int x;
   
  -    for(x=0;l[x];x++) fputc(l[x],f);
  -    fputc('\n',f);
  +    for (x = 0; l[x]; x++)
  +     fputc(l[x], f);
  +    fputc('\n', f);
   }
   
   
   /* From local_passwd.c (C) Regents of Univ. of California blah blah */
  -static unsigned char itoa64[] =         /* 0 ... 63 => ascii - 64 */
  -        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  +static unsigned char itoa64[] =      /* 0 ... 63 => ascii - 64 */
  +"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   
  -void to64(register char *s, register long v, register int n) {
  +void to64(register char *s, register long v, register int n)
  +{
       while (--n >= 0) {
  -        *s++ = itoa64[v&0x3f];
  -        v >>= 6;
  +     *s++ = itoa64[v & 0x3f];
  +     v >>= 6;
       }
   }
   
   #ifdef MPE
   /* MPE lacks getpass() and a way to suppress stdin echo.  So for now, just
  -issue the prompt and read the results with echo.  (Ugh). */
  + * issue the prompt and read the results with echo.  (Ugh).
  + */
   
  -char *getpass(const char *prompt) {
  +char *getpass(const char *prompt)
  +{
   
  -static char password[81];
  +    static char password[81];
   
  -fputs(prompt,stderr);
  -gets((char *)&password);
  +    fputs(prompt, stderr);
  +    gets((char *) &password);
   
  -if (strlen((char *)&password) > 8) {
  -  password[8]='\0';
  -}
  +    if (strlen((char *) &password) > 8) {
  +     password[8] = '\0';
  +    }
   
  -return (char *)&password;
  +    return (char *) &password;
   }
  +
   #endif
   
  -void add_password(char *user, FILE *f) {
  +void add_password(char *user, FILE *f)
  +{
       char *pw, *cpw, salt[3];
   
       pw = strd((char *) getpass("New password:"));
  -    if(strcmp(pw,(char *) getpass("Re-type new password:"))) {
  -        fprintf(stderr,"They don't match, sorry.\n");
  -        if(tn)
  -            unlink(tn);
  -        exit(1);
  -    }
  -    (void)srand((int)time((time_t *)NULL));
  -    to64(&salt[0],rand(),2);
  -    cpw = crypt(pw,salt);
  +    if (strcmp(pw, (char *) getpass("Re-type new password:"))) {
  +     fprintf(stderr, "They don't match, sorry.\n");
  +     if (tn)
  +         unlink(tn);
  +     exit(1);
  +    }
  +    (void) srand((int) time((time_t *) NULL));
  +    to64(&salt[0], rand(), 2);
  +    cpw = crypt(pw, salt);
       free(pw);
  -    fprintf(f,"%s:%s\n",user,cpw);
  +    fprintf(f, "%s:%s\n", user, cpw);
   }
   
  -void usage() {
  -    fprintf(stderr,"Usage: htpasswd [-c] passwordfile username\n");
  -    fprintf(stderr,"The -c flag creates a new file.\n");
  +void usage()
  +{
  +    fprintf(stderr, "Usage: htpasswd [-c] passwordfile username\n");
  +    fprintf(stderr, "The -c flag creates a new file.\n");
       exit(1);
   }
   
  -void interrupted() {
  -    fprintf(stderr,"Interrupted.\n");
  -    if(tn) unlink(tn);
  +void interrupted()
  +{
  +    fprintf(stderr, "Interrupted.\n");
  +    if (tn)
  +     unlink(tn);
       exit(1);
   }
   
  -void main(int argc, char *argv[]) {
  -    FILE *tfp,*f;
  +void main(int argc, char *argv[])
  +{
  +    FILE *tfp, *f;
       char user[MAX_STRING_LEN];
       char line[MAX_STRING_LEN];
       char l[MAX_STRING_LEN];
  @@ -138,61 +153,63 @@
       int found;
   
       tn = NULL;
  -    signal(SIGINT,(void (*)())interrupted);
  -    if(argc == 4) {
  -        if(strcmp(argv[1],"-c"))
  -            usage();
  -        if(!(tfp = fopen(argv[2],"w"))) {
  -            fprintf(stderr,"Could not open passwd file %s for writing.\n",
  -                    argv[2]);
  -            perror("fopen");
  -            exit(1);
  -        }
  -        printf("Adding password for %s.\n",argv[3]);
  -        add_password(argv[3],tfp);
  -        fclose(tfp);
  -        exit(0);
  -    } else if(argc != 3) usage();
  +    signal(SIGINT, (void (*)()) interrupted);
  +    if (argc == 4) {
  +     if (strcmp(argv[1], "-c"))
  +         usage();
  +     if (!(tfp = fopen(argv[2], "w"))) {
  +         fprintf(stderr, "Could not open passwd file %s for writing.\n",
  +                 argv[2]);
  +         perror("fopen");
  +         exit(1);
  +     }
  +     printf("Adding password for %s.\n", argv[3]);
  +     add_password(argv[3], tfp);
  +     fclose(tfp);
  +     exit(0);
  +    }
  +    else if (argc != 3)
  +     usage();
   
       tn = tmpnam(NULL);
  -    if(!(tfp = fopen(tn,"w"))) {
  -        fprintf(stderr,"Could not open temp file.\n");
  -        exit(1);
  +    if (!(tfp = fopen(tn, "w"))) {
  +     fprintf(stderr, "Could not open temp file.\n");
  +     exit(1);
       }
   
  -    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");
  -        exit(1);
  +    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");
  +     exit(1);
       }
  -    strcpy(user,argv[2]);
  +    strcpy(user, argv[2]);
   
       found = 0;
  -    while(!(getline(line,MAX_STRING_LEN,f))) {
  -        if(found || (line[0] == '#') || (!line[0])) {
  -            putline(tfp,line);
  -            continue;
  -        }
  -        strcpy(l,line);
  -        getword(w,l,':');
  -        if(strcmp(user,w)) {
  -            putline(tfp,line);
  -            continue;
  -        }
  -        else {
  -            printf("Changing password for user %s\n",user);
  -            add_password(user,tfp);
  -            found = 1;
  -        }
  -    }
  -    if(!found) {
  -        printf("Adding user %s\n",user);
  -        add_password(user,tfp);
  +    while (!(getline(line, MAX_STRING_LEN, f))) {
  +     if (found || (line[0] == '#') || (!line[0])) {
  +         putline(tfp, line);
  +         continue;
  +     }
  +     strcpy(l, line);
  +     getword(w, l, ':');
  +     if (strcmp(user, w)) {
  +         putline(tfp, line);
  +         continue;
  +     }
  +     else {
  +         printf("Changing password for user %s\n", user);
  +         add_password(user, tfp);
  +         found = 1;
  +     }
  +    }
  +    if (!found) {
  +     printf("Adding user %s\n", user);
  +     add_password(user, tfp);
       }
       fclose(f);
       fclose(tfp);
  -    sprintf(command,"cp %s %s",tn,argv[1]);
  +    sprintf(command, "cp %s %s", tn, argv[1]);
       system(command);
       unlink(tn);
   }
  
  
  
  1.8       +114 -134  apachen/src/support/logresolve.c
  
  Index: logresolve.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/logresolve.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- logresolve.c      1997/02/04 23:54:28     1.7
  +++ logresolve.c      1997/09/14 22:48:09     1.8
  @@ -1,44 +1,44 @@
  -/***                                                                      
***\
  -    logresolve 1.1
  -
  -    Tom Rathborne - [EMAIL PROTECTED] - http://www.uunet.ca/~tomr/
  -    UUNET Canada, April 16, 1995
  -
  -    Rewritten by David Robinson. ([EMAIL PROTECTED])
  -
  -    Usage: logresolve [-s filename] [-c] < access_log > new_log
  -
  -    Arguments:
  -       -s filename     name of a file to record statistics
  -       -c              check the DNS for a matching A record for the host.
  -
  -    Notes:
  -
  -    To generate meaningful statistics from an HTTPD log file, it's good
  -    to have the domain name of each machine that accessed your site, but
  -    doing this on the fly can slow HTTPD down.
  -
  -    Compiling NCSA HTTPD with the -DMINIMAL_DNS flag turns IP#->hostname
  -    resolution off. Before running your stats program, just run your log
  -    file through this program (logresolve) and all of your IP numbers will
  -    be resolved into hostnames (where possible).
  -
  -    logresolve takes an HTTPD access log (in the COMMON log file format,
  -    or any other format that has the IP number/domain name as the first
  -    field for that matter), and outputs the same file with all of the
  -    domain names looked up. Where no domain name can be found, the IP
  -    number is left in.
  -
  -    To minimize impact on your nameserver, logresolve has its very own
  -    internal hash-table cache. This means that each IP number will only
  -    be looked up the first time it is found in the log file.
  -
  -    The -c option causes logresolve to apply the same check as httpd
  -    compiled with -DMAXIMUM_DNS; after finding the hostname from the IP
  -    address, it looks up the IP addresses for the hostname and checks
  -    that one of these matches the original address.
  +/*
  + * logresolve 1.1
  + *
  + * Tom Rathborne - [EMAIL PROTECTED] - http://www.uunet.ca/~tomr/
  + * UUNET Canada, April 16, 1995
  + *
  + * Rewritten by David Robinson. ([EMAIL PROTECTED])
  + *
  + * Usage: logresolve [-s filename] [-c] < access_log > new_log
  + *
  + * Arguments:
  + *    -s filename     name of a file to record statistics
  + *    -c              check the DNS for a matching A record for the host.
  + *
  + * Notes:
  + *
  + * To generate meaningful statistics from an HTTPD log file, it's good
  + * to have the domain name of each machine that accessed your site, but
  + * doing this on the fly can slow HTTPD down.
  + *
  + * Compiling NCSA HTTPD with the -DMINIMAL_DNS flag turns IP#->hostname
  + * resolution off. Before running your stats program, just run your log
  + * file through this program (logresolve) and all of your IP numbers will
  + * be resolved into hostnames (where possible).
  + *
  + * logresolve takes an HTTPD access log (in the COMMON log file format,
  + * or any other format that has the IP number/domain name as the first
  + * field for that matter), and outputs the same file with all of the
  + * domain names looked up. Where no domain name can be found, the IP
  + * number is left in.
  + *
  + * To minimize impact on your nameserver, logresolve has its very own
  + * internal hash-table cache. This means that each IP number will only
  + * be looked up the first time it is found in the log file.
  + *
  + * The -c option causes logresolve to apply the same check as httpd
  + * compiled with -DMAXIMUM_DNS; after finding the hostname from the IP
  + * address, it looks up the IP addresses for the hostname and checks
  + * that one of these matches the original address.
  + */
   
  -\***                                                                      
***/
   
   #include <sys/types.h>
   
  @@ -74,13 +74,13 @@
   #ifdef MPE
   char *strdup (const char *str)
   {
  -  char *dup; 
  -             
  -  if(!(dup = (char *)malloc (strlen (str) + 1)))
  -      return NULL;
  -  dup = strcpy (dup, str);
  -     
  -  return dup; 
  +    char *dup;
  +
  +    if (!(dup = (char *) malloc(strlen(str) + 1)))
  +     return NULL;
  +    dup = strcpy(dup, str);
  +
  +    return dup;
   }
   #endif
   
  @@ -94,9 +94,9 @@
   struct nsrec {
       struct in_addr ipnum;
       char *hostname;
  -    int      noname;
  +    int noname;
       struct nsrec *next;
  -} *nscache[BUCKETS];
  +}    *nscache[BUCKETS];
   
   /*
    * statistics - obvious
  @@ -112,36 +112,30 @@
   static int entries = 0;
   static int resolves = 0;
   static int withname = 0;
  -static int errors[MAX_ERR+3];
  +static int errors[MAX_ERR + 3];
   
   /*
    * cgethost - gets hostname by IP address, caching, and adding unresolvable
    * IP numbers with their IP number as hostname, setting noname flag
    */
   
  -static void
  -cgethost(ipnum, string, check)
  -struct in_addr ipnum;
  -char *string;
  -int check;
  +static void cgethost (struct in_addr ipnum, char *string, int check)
   {
       struct nsrec **current, *new;
       struct hostent *hostdata;
       char *name;
  -    extern int h_errno;  /* some machines don't have this in their headers */
  +    extern int h_errno;              /* some machines don't have this in 
their headers */
   
       current = &nscache[((ipnum.s_addr + (ipnum.s_addr >> 8) +
  -             (ipnum.s_addr >> 16) + (ipnum.s_addr >> 24)) % BUCKETS)];
  +                      (ipnum.s_addr >> 16) + (ipnum.s_addr >> 24)) % 
BUCKETS)];
   
       while (*current != NULL && ipnum.s_addr != (*current)->ipnum.s_addr)
  -     current = & (*current)->next;
  +     current = &(*current)->next;
   
  -    if (*current == NULL)
  -    {
  +    if (*current == NULL) {
        cachesize++;
        new = (struct nsrec *) malloc(sizeof(struct nsrec));
  -     if (new == NULL)
  -     {
  +     if (new == NULL) {
            perror("malloc");
            fprintf(stderr, "Insufficient memory\n");
            exit(1);
  @@ -150,39 +144,37 @@
        new->next = NULL;
   
        new->ipnum = ipnum;
  -     
  +
        hostdata = gethostbyaddr((const char *) &ipnum, sizeof(struct in_addr),
                                 AF_INET);
  -     if (hostdata == NULL)
  -     {
  -         if (h_errno > MAX_ERR) errors[UNKNOWN_ERR]++;
  -         else errors[h_errno]++;
  +     if (hostdata == NULL) {
  +         if (h_errno > MAX_ERR)
  +             errors[UNKNOWN_ERR]++;
  +         else
  +             errors[h_errno]++;
            new->noname = h_errno;
            name = strdup(inet_ntoa(ipnum));
  -     } else
  -     {
  +     }
  +     else {
            new->noname = 0;
            name = strdup(hostdata->h_name);
  -         if (check)
  -         {
  -             if (name == NULL)
  -             {
  +         if (check) {
  +             if (name == NULL) {
                    perror("strdup");
                    fprintf(stderr, "Insufficient memory\n");
                    exit(1);
                }
                hostdata = gethostbyname(name);
  -             if (hostdata != NULL)
  -             {
  +             if (hostdata != NULL) {
                    char **hptr;
  -                 
  -                 for (hptr=hostdata->h_addr_list; *hptr != NULL; hptr++)
  -                     if(((struct in_addr *)(*hptr))->s_addr == ipnum.s_addr)
  +
  +                 for (hptr = hostdata->h_addr_list; *hptr != NULL; hptr++)
  +                     if (((struct in_addr *) (*hptr))->s_addr == 
ipnum.s_addr)
                            break;
  -                 if (*hptr == NULL) hostdata = NULL;
  +                 if (*hptr == NULL)
  +                     hostdata = NULL;
                }
  -             if (hostdata == NULL)
  -             {
  +             if (hostdata == NULL) {
                    fprintf(stderr, "Bad host: %s != %s\n", name,
                            inet_ntoa(ipnum));
                    new->noname = NO_REVERSE;
  @@ -193,13 +185,13 @@
            }
        }
        new->hostname = name;
  -     if (new->hostname == NULL)
  -     {
  +     if (new->hostname == NULL) {
            perror("strdup");
            fprintf(stderr, "Insufficient memory\n");
            exit(1);
        }
  -    } else
  +    }
  +    else
        cachehits++;
   
       strcpy(string, (*current)->hostname);
  @@ -209,23 +201,22 @@
    * prints various statistics to output
    */
   
  -static void
  -stats(output)
  -FILE *output;
  +static void stats (FILE *output)
   {
       int i;
       char *ipstring;
       struct nsrec *current;
  -    char *errstring[MAX_ERR+3];
  +    char *errstring[MAX_ERR + 3];
   
  -    for (i=0; i < MAX_ERR+3; i++) errstring[i] = "Unknown error";
  +    for (i = 0; i < MAX_ERR + 3; i++)
  +     errstring[i] = "Unknown error";
       errstring[HOST_NOT_FOUND] = "Host not found";
       errstring[TRY_AGAIN] = "Try again";
       errstring[NO_RECOVERY] = "Non recoverable error";
       errstring[NO_DATA] = "No data record";
       errstring[NO_ADDRESS] = "No address";
       errstring[NO_REVERSE] = "No reverse entry";
  -    
  +
       fprintf(output, "logresolve Statistics:\n");
   
       fprintf(output, "Entries: %d\n", entries);
  @@ -246,15 +237,13 @@
       fprintf(output, "Cache buckets   :     IP number * hostname\n");
   
       for (i = 0; i < BUCKETS; i++)
  -     for (current = nscache[i]; current != NULL; current = current->next)
  -     {
  +     for (current = nscache[i]; current != NULL; current = current->next) {
            ipstring = inet_ntoa(current->ipnum);
            if (current->noname == 0)
                fprintf(output, "  %3d  %15s - %s\n", i, ipstring,
                        current->hostname);
  -         else
  -         {
  -             if (current->noname > MAX_ERR+2)
  +         else {
  +             if (current->noname > MAX_ERR + 2)
                    fprintf(output, "  %3d  %15s : Unknown error\n", i,
                            ipstring);
                else
  @@ -269,13 +258,10 @@
    * gets a line from stdin
    */
   
  -static int
  -getline(s, n)
  -char *s;
  -int n;
  +static int getline (char *s, int n)
   {
       char *cp;
  -    
  +
       if (!fgets(s, n, stdin))
        return (0);
       cp = strchr(s, '\n');
  @@ -284,57 +270,53 @@
       return (1);
   }
   
  -int
  -main(argc, argv)
  -int argc;
  -char *argv[];
  +int main (int argc, char *argv[])
   {
       struct in_addr ipnum;
  -    char *bar, hoststring[MAXDNAME+1], line[MAXLINE], *statfile;
  +    char *bar, hoststring[MAXDNAME + 1], line[MAXLINE], *statfile;
       int i, check;
   
       check = 0;
       statfile = NULL;
  -    for (i=1; i < argc; i++)
  -    {
  -     if (strcmp(argv[i], "-c") == 0) check = 1;
  -     else if (strcmp(argv[i], "-s") == 0)
  -     {
  -         if (i == argc-1)
  -         {
  +    for (i = 1; i < argc; i++) {
  +     if (strcmp(argv[i], "-c") == 0)
  +         check = 1;
  +     else if (strcmp(argv[i], "-s") == 0) {
  +         if (i == argc - 1) {
                fprintf(stderr, "logresolve: missing filename to -s\n");
                exit(1);
            }
            i++;
            statfile = argv[i];
        }
  -     else
  -     {
  +     else {
            fprintf(stderr, "Usage: logresolve [-s statfile] [-c] < input > 
output");
            exit(0);
        }
       }
  -    
   
  -    for (i = 0; i < BUCKETS; i++) nscache[i] = NULL;
  -    for (i=0; i < MAX_ERR+2; i++) errors[i] = 0;
   
  -    while (getline(line, MAXLINE))
  -    {
  -     if (line[0] == '\0') continue;
  +    for (i = 0; i < BUCKETS; i++)
  +     nscache[i] = NULL;
  +    for (i = 0; i < MAX_ERR + 2; i++)
  +     errors[i] = 0;
  +
  +    while (getline(line, MAXLINE)) {
  +     if (line[0] == '\0')
  +         continue;
        entries++;
  -     if (!isdigit(line[0]))
  -     { /* short cut */
  +     if (!isdigit(line[0])) {        /* short cut */
            puts(line);
            withname++;
            continue;
        }
        bar = strchr(line, ' ');
  -     if (bar != NULL) *bar = '\0';
  +     if (bar != NULL)
  +         *bar = '\0';
        ipnum.s_addr = inet_addr(line);
  -     if (ipnum.s_addr == 0xffffffffu)
  -     {
  -         if (bar != NULL) *bar = ' ';
  +     if (ipnum.s_addr == 0xffffffffu) {
  +         if (bar != NULL)
  +             *bar = ' ';
            puts(line);
            withname++;
            continue;
  @@ -344,24 +326,22 @@
   
        cgethost(ipnum, hoststring, check);
        if (bar != NULL)
  -         printf("%s %s\n", hoststring, bar+1);
  +         printf("%s %s\n", hoststring, bar + 1);
        else
            puts(hoststring);
       }
  -    
  -    if (statfile != NULL)
  -    {
  +
  +    if (statfile != NULL) {
        FILE *fp;
        fp = fopen(statfile, "w");
  -     if (fp == NULL)
  -     {
  +     if (fp == NULL) {
            fprintf(stderr, "logresolve: could not open statistics file '%s'\n"
  -                 , statfile);
  +                 ,statfile);
            exit(1);
        }
        stats(fp);
        fclose(fp);
       }
  -    
  +
       return (0);
   }
  
  
  
  1.7       +49 -49    apachen/src/support/rotatelogs.c
  
  Index: rotatelogs.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/rotatelogs.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- rotatelogs.c      1997/04/16 06:18:25     1.6
  +++ rotatelogs.c      1997/09/14 22:48:09     1.7
  @@ -1,12 +1,11 @@
   /*
  + * Simple program to rotate Apache logs without having to kill the server.
  + *
  + * Contributed by Ben Laurie <[EMAIL PROTECTED]>
  + *
  + * 12 Mar 1996
  + */
   
  -Simple program to rotate Apache logs without having to kill the server.
  -
  -Contributed by Ben Laurie <[EMAIL PROTECTED]>
  -
  -12 Mar 1996
  -
  -*/
   
   #define BUFSIZE              65536
   #define MAX_PATH     1024
  @@ -18,67 +17,68 @@
   #include <fcntl.h>
   #include <unistd.h>
   
  -void main(int argc,char **argv)
  -    {
  -    char buf[BUFSIZE],buf2[MAX_PATH];
  +void main (int argc, char **argv)
  +{
  +    char buf[BUFSIZE], buf2[MAX_PATH];
       time_t tLogEnd;
       time_t tRotation;
  -    int nLogFD=-1;
  +    int nLogFD = -1;
       int nRead;
       char *szLogRoot;
   
  -    if(argc != 3)
  -     {
  -     fprintf(stderr,"%s <logfile> <rotation time in seconds>\n\n",argv[0]);
  +    if (argc != 3) {
  +     fprintf(stderr,
  +             "%s <logfile> <rotation time in seconds>\n\n",
  +             argv[0]);
   #ifdef __EMX__
  -     fprintf(stderr,"Add this:\n\nTransferLog \"|%s.exe /some/where 
86400\"\n\n",argv[0]);
  +     fprintf(stderr,
  +             "Add this:\n\nTransferLog \"|%s.exe /some/where 86400\"\n\n",
  +             argv[0]);
   #else
  -             fprintf(stderr,"Add this:\n\nTransferLog \"|%s /some/where 
86400\"\n\n",argv[0]);
  +     fprintf(stderr,
  +             "Add this:\n\nTransferLog \"|%s /some/where 86400\"\n\n",
  +             argv[0]);
   #endif
  -     fprintf(stderr,"to httpd.conf. The generated name will be 
/some/where.nnnn where nnnn is the\n");
  -     fprintf(stderr,"system time at which the log nominally starts (N.B. 
this time will always be a\n");
  -     fprintf(stderr,"multiple of the rotation time, so you can synchronize 
cron scripts with it).\n");
  -     fprintf(stderr,"At the end of each rotation time a new log is 
started.\n");
  +     fprintf(stderr,
  +             "to httpd.conf. The generated name will be /some/where.nnnn ",
  +             "where nnnn is the\nsystem time at which the log nominally ",
  +             "starts (N.B. this time will always be a\nmultiple of the "
  +             "rotation time, so you can synchronize cron scripts with 
it).\n",
  +             "At the end of each rotation time a new log is started.\n");
        exit(1);
  -     }
  +    }
   
  -    szLogRoot=argv[1];
  -    tRotation=atoi(argv[2]);
  -    if(tRotation <= 0)
  -     {
  -     fprintf(stderr,"Rotation time must be > 0\n");
  +    szLogRoot = argv[1];
  +    tRotation = atoi(argv[2]);
  +    if (tRotation <= 0) {
  +     fprintf(stderr, "Rotation time must be > 0\n");
        exit(6);
  -     }
  +    }
   
  -    for( ; ; )
  -     {
  -     nRead=read(0,buf,sizeof buf);
  -     if(nRead == 0)
  +    for (;;) {
  +     nRead = read(0, buf, sizeof buf);
  +     if (nRead == 0)
            exit(3);
  -     if(nRead < 0)
  -         if(errno != EINTR)
  +     if (nRead < 0)
  +         if (errno != EINTR)
                exit(4);
  -     if(nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0))
  -         {
  +     if (nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0)) {
            close(nLogFD);
  -         nLogFD=-1;
  -         }
  -     if(nLogFD < 0)
  -         {
  -         time_t tLogStart=(time(NULL)/tRotation)*tRotation;
  -         sprintf(buf2,"%s.%010d",szLogRoot,(int)tLogStart);
  -         tLogEnd=tLogStart+tRotation;
  -         nLogFD=open(buf2,O_WRONLY|O_CREAT|O_APPEND,0666);
  -         if(nLogFD < 0)
  -             {
  +         nLogFD = -1;
  +     }
  +     if (nLogFD < 0) {
  +         time_t tLogStart = (time(NULL) / tRotation) * tRotation;
  +         sprintf(buf2, "%s.%010d", szLogRoot, (int) tLogStart);
  +         tLogEnd = tLogStart + tRotation;
  +         nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666);
  +         if (nLogFD < 0) {
                perror(buf2);
                exit(2);
  -             }
            }
  -     if(write(nLogFD,buf,nRead) != nRead)
  -         {
  +     }
  +     if (write(nLogFD, buf, nRead) != nRead) {
            perror(buf2);
            exit(5);
  -         }
        }
       }
  +}
  
  
  
  1.25      +64 -71    apachen/src/support/suexec.c
  
  Index: suexec.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/suexec.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- suexec.c  1997/07/20 23:44:49     1.24
  +++ suexec.c  1997/09/14 22:48:10     1.25
  @@ -95,7 +95,7 @@
   int initgroups(const char *name, gid_t basegid)
   {
   /* QNX and MPE do not appear to support supplementary groups. */
  -     return 0;
  +    return 0;
   }
   #endif
   
  @@ -168,20 +168,20 @@
   
       time(&timevar);
       lt = localtime(&timevar);
  -    
  +
       fprintf(log, "[%.2d:%.2d:%.2d %.2d-%.2d-%.2d]: ", lt->tm_hour, 
lt->tm_min,
            lt->tm_sec, lt->tm_mday, (lt->tm_mon + 1), lt->tm_year);
  -    
  +
       vfprintf(log, fmt, ap);
   
       fflush(log);
       return;
   }
   
  -void log_err(const char *fmt, ...)
  +void log_err(const char *fmt,...)
   {
   #ifdef LOG_EXEC
  -    va_list     ap;
  +    va_list ap;
   
       va_start(ap, fmt);
       err_output(fmt, ap);
  @@ -190,20 +190,20 @@
       return;
   }
   
  -void clean_env() 
  +void clean_env()
   {
       char pathbuf[512];
       char **cleanenv;
       char **ep;
       int cidx = 0;
       int idx;
  -    
   
  -    if ((cleanenv = (char **)calloc(AP_ENVBUF, sizeof(char *))) == NULL) {
  +
  +    if ((cleanenv = (char **) calloc(AP_ENVBUF, sizeof(char *))) == NULL) {
        log_err("failed to malloc env mem\n");
        exit(120);
       }
  -    
  +
       for (ep = environ; *ep && cidx < AP_ENVBUF; ep++) {
        if (!strncmp(*ep, "HTTP_", 5)) {
            cleanenv[cidx] = *ep;
  @@ -223,30 +223,30 @@
       sprintf(pathbuf, "PATH=%s", SAFE_PATH);
       cleanenv[cidx] = strdup(pathbuf);
       cleanenv[++cidx] = NULL;
  -         
  +
       environ = cleanenv;
   }
   
   int main(int argc, char *argv[])
   {
  -    int userdir = 0;        /* ~userdir flag             */
  -    uid_t uid;              /* user information          */
  -    gid_t gid;              /* target group placeholder  */
  -    char *target_uname;     /* target user name          */
  -    char *target_gname;     /* target group name         */
  -    char *target_homedir;   /* target home directory     */
  -    char *actual_uname;     /* actual user name            */
  -    char *actual_gname;     /* actual group name           */
  -    char *prog;             /* name of this program      */
  -    char *cmd;              /* command to be executed    */
  -    char cwd[AP_MAXPATH];   /* current working directory */
  -    char dwd[AP_MAXPATH];   /* docroot working directory */
  -    struct passwd *pw;      /* password entry holder     */
  -    struct group *gr;       /* group entry holder        */
  -    struct stat dir_info;   /* directory info holder     */
  -    struct stat prg_info;   /* program info holder       */
  +    int userdir = 0;         /* ~userdir flag             */
  +    uid_t uid;                       /* user information          */
  +    gid_t gid;                       /* target group placeholder  */
  +    char *target_uname;              /* target user name          */
  +    char *target_gname;              /* target group name         */
  +    char *target_homedir;    /* target home directory     */
  +    char *actual_uname;              /* actual user name            */
  +    char *actual_gname;              /* actual group name           */
  +    char *prog;                      /* name of this program      */
  +    char *cmd;                       /* command to be executed    */
  +    char cwd[AP_MAXPATH];    /* current working directory */
  +    char dwd[AP_MAXPATH];    /* docroot working directory */
  +    struct passwd *pw;               /* password entry holder     */
  +    struct group *gr;                /* group entry holder        */
  +    struct stat dir_info;    /* directory info holder     */
  +    struct stat prg_info;    /* program info holder       */
  +
   
  -    
   
       /*
        * If there are a proper number of arguments, set
  @@ -270,7 +270,7 @@
        log_err("invalid uid: (%ld)\n", uid);
        exit(102);
       }
  -    
  +
       /*
        * Check to see if the user running this program
        * is the user allowed to do so as defined in
  @@ -280,19 +280,16 @@
        log_err("user mismatch (%s)\n", pw->pw_name);
        exit(103);
       }
  -    
  +
       /*
        * Check for a leading '/' (absolute path) in the command to be executed,
        * or attempts to back up out of the current directory,
        * to protect against attacks.  If any are
        * found, error out.  Naughty naughty crackers.
        */
  -    if (
  -         (cmd[0] == '/') ||
  -         (! strncmp (cmd, "../", 3)) ||
  -         (strstr (cmd, "/../") != NULL)
  -       ) {
  -     log_err("invalid command (%s)\n", cmd);
  +    if ((cmd[0] == '/') || (!strncmp(cmd, "../", 3))
  +     || (strstr(cmd, "/../") != NULL)) {
  +        log_err("invalid command (%s)\n", cmd);
        exit(104);
       }
   
  @@ -342,16 +339,15 @@
        * before we setuid().
        */
       log_err("uid: (%s/%s) gid: (%s/%s) %s\n",
  -             target_uname, actual_uname,
  -             target_gname, actual_gname,
  -             cmd);
  +         target_uname, actual_uname,
  +         target_gname, actual_gname,
  +         cmd);
   
       /*
        * Error out if attempt is made to execute as root or as
        * a UID less than UID_MIN.  Tsk tsk.
        */
  -    if ((uid == 0) ||
  -        (uid < UID_MIN)) {
  +    if ((uid == 0) || (uid < UID_MIN)) {
        log_err("cannot run as forbidden uid (%d/%s)\n", uid, cmd);
        exit(107);
       }
  @@ -360,8 +356,7 @@
        * Error out if attempt is made to execute as root group
        * or as a GID less than GID_MIN.  Tsk tsk.
        */
  -    if ((gid == 0) ||
  -        (gid < GID_MIN)) {
  +    if ((gid == 0) || (gid < GID_MIN)) {
        log_err("cannot run as forbidden gid (%d/%s)\n", gid, cmd);
        exit(108);
       }
  @@ -372,9 +367,9 @@
        * Initialize the group access list for the target user,
        * and setgid() to the target group. If unsuccessful, error out.
        */
  -    if (((setgid(gid)) != 0) || (initgroups(actual_uname,gid) != 0)) {
  -        log_err("failed to setgid (%ld: %s/%s)\n", gid, cwd, cmd);
  -        exit(109);
  +    if (((setgid(gid)) != 0) || (initgroups(actual_uname, gid) != 0)) {
  +     log_err("failed to setgid (%ld: %s/%s)\n", gid, cwd, cmd);
  +     exit(109);
       }
   
       /*
  @@ -394,33 +389,31 @@
        * directories.  Yuck.
        */
       if (getcwd(cwd, AP_MAXPATH) == NULL) {
  -        log_err("cannot get current working directory\n");
  -        exit(111);
  +     log_err("cannot get current working directory\n");
  +     exit(111);
       }
  -    
  +
       if (userdir) {
  -        if (((chdir(target_homedir)) != 0) ||
  -            ((chdir(USERDIR_SUFFIX)) != 0) ||
  +     if (((chdir(target_homedir)) != 0) ||
  +         ((chdir(USERDIR_SUFFIX)) != 0) ||
            ((getcwd(dwd, AP_MAXPATH)) == NULL) ||
  -            ((chdir(cwd)) != 0))
  -        {
  -            log_err("cannot get docroot information (%s)\n", target_homedir);
  -            exit(112);
  -        }
  +         ((chdir(cwd)) != 0)) {
  +         log_err("cannot get docroot information (%s)\n", target_homedir);
  +         exit(112);
  +     }
       }
       else {
  -        if (((chdir(DOC_ROOT)) != 0) ||
  +     if (((chdir(DOC_ROOT)) != 0) ||
            ((getcwd(dwd, AP_MAXPATH)) == NULL) ||
  -         ((chdir(cwd)) != 0))
  -        {
  -            log_err("cannot get docroot information (%s)\n", DOC_ROOT);
  -            exit(113);
  -        }
  +         ((chdir(cwd)) != 0)) {
  +         log_err("cannot get docroot information (%s)\n", DOC_ROOT);
  +         exit(113);
  +     }
       }
   
       if ((strncmp(cwd, dwd, strlen(dwd))) != 0) {
  -        log_err("command not in docroot (%s/%s)\n", cwd, cmd);
  -        exit(114);
  +     log_err("command not in docroot (%s/%s)\n", cwd, cmd);
  +     exit(114);
       }
   
       /*
  @@ -459,7 +452,7 @@
        * Error out if the file is setuid or setgid.
        */
       if ((prg_info.st_mode & S_ISUID) || (prg_info.st_mode & S_ISGID)) {
  -     log_err("file is either setuid or setgid: (%s/%s)\n",cwd,cmd);
  +     log_err("file is either setuid or setgid: (%s/%s)\n", cwd, cmd);
        exit(119);
       }
   
  @@ -470,12 +463,12 @@
       if ((uid != dir_info.st_uid) ||
        (gid != dir_info.st_gid) ||
        (uid != prg_info.st_uid) ||
  -     (gid != prg_info.st_gid))
  -    {
  -     log_err("target uid/gid (%ld/%ld) mismatch with directory (%ld/%ld) or 
program (%ld/%ld)\n",
  -              uid, gid,
  -              dir_info.st_uid, dir_info.st_gid,
  -              prg_info.st_uid, prg_info.st_gid);
  +     (gid != prg_info.st_gid)) {
  +     log_err("target uid/gid (%ld/%ld) mismatch with directory ",
  +             "(%ld/%ld) or program (%ld/%ld)\n",
  +             uid, gid,
  +             dir_info.st_uid, dir_info.st_gid,
  +             prg_info.st_uid, prg_info.st_gid);
        exit(120);
       }
   
  @@ -488,7 +481,7 @@
        */
       fclose(log);
       log = NULL;
  -    
  +
       /*
        * Execute the command, replacing our image with its own.
        */
  
  
  
  1.10      +2 -2      apachen/src/support/suexec.h
  
  Index: suexec.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/support/suexec.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- suexec.h  1997/05/10 05:06:17     1.9
  +++ suexec.h  1997/09/14 22:48:10     1.10
  @@ -114,7 +114,7 @@
    *             debugging purposes.
    */
   #ifndef LOG_EXEC
  -#define LOG_EXEC "/usr/local/etc/httpd/logs/cgi.log" /* Need me? */
  +#define LOG_EXEC "/usr/local/etc/httpd/logs/cgi.log" /* Need me? */
   #endif
   
   /*
  @@ -134,4 +134,4 @@
   #define SAFE_PATH "/usr/local/bin:/usr/bin:/bin"
   #endif
   
  -#endif  /* _SUEXEC_H */
  +#endif /* _SUEXEC_H */
  
  
  

Reply via email to