htdigest.c revision 0942697a9b5de44865676345a3828741c827efe6
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder/* ====================================================================
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Redistribution and use in source and binary forms, with or without
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * modification, are permitted provided that the following conditions
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 1. Redistributions of source code must retain the above copyright
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * notice, this list of conditions and the following disclaimer.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 2. Redistributions in binary form must reproduce the above copyright
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * notice, this list of conditions and the following disclaimer in
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * the documentation and/or other materials provided with the
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * distribution.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 3. All advertising materials mentioning features or use of this
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * software must display the following acknowledgment:
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * "This product includes software developed by the Apache Group
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * for use in the Apache HTTP server project (http://www.apache.org/)."
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * 4. The names "Apache Server" and "Apache Group" must not be used to
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * endorse or promote products derived from this software without
70e83495a9753d2a104a9869ac2a997ac30d05c1Christian Maeder * prior written permission. For written permission, please contact
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * apache@apache.org.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 5. Products derived from this software may not be called "Apache"
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * nor may "Apache" appear in their names without prior written
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * permission of the Apache Group.
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder * 6. Redistributions of any form whatsoever must retain the following
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * acknowledgment:
62d8627183cce49c052386186ad69c95b1aa3953Christian Maeder * "This product includes software developed by the Apache Group
62d8627183cce49c052386186ad69c95b1aa3953Christian Maeder * for use in the Apache HTTP server project (http://www.apache.org/)."
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * OF THE POSSIBILITY OF SUCH DAMAGE.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ====================================================================
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * This software consists of voluntary contributions made by many
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * individuals on behalf of the Apache Group and was originally based
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * on public domain software written at the National Center for
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Supercomputing Applications, University of Illinois, Urbana-Champaign.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * For more information on the Apache Group and the Apache HTTP server
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder * project, please see <http://www.apache.org/>.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder/******************************************************************************
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ******************************************************************************
7862e8fb34d79382e93b45ce894acdd928da8a51Christian Maeder * NOTE! This program is not safe as a setuid executable! Do not make it
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ******************************************************************************
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder *****************************************************************************/
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * htdigest.c: simple program for manipulating digest passwd file for Apache
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * by Alexei Kosut, based on htpasswd.c, by Rob McCool
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder#if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM) || defined(BEOS)
62d8627183cce49c052386186ad69c95b1aa3953Christian Maeder#endif /* CHARSET_EBCDIC */
if (line[x])
s[i] = (char) fgetc(f);
if (s[i] == CR)
s[i] = fgetc(f);
fputc(l[x], f);
char *pw;
if (tn) {
static void usage(void)
static void interrupted(void)
if (tn)
char l[MAX_STRING_LEN];
char w[MAX_STRING_LEN];
char x[MAX_STRING_LEN];
int found;
usage();
exit(0);
usage();
found = 0;
if (!found) {
fclose(f);