htdigest.c revision 08cb74ca432a8c24e39f17dedce527e6a47b8001
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/******************************************************************************
******************************************************************************
* NOTE! This program is not safe as a setuid executable! Do not make it
* setuid!
******************************************************************************
*****************************************************************************/
/*
* htdigest.c: simple program for manipulating digest passwd file for Apache
*
* by Alexei Kosut, based on htpasswd.c, by Rob McCool
*/
#include "apr.h"
#include "apr_file_io.h"
#include "apr_md5.h"
#include "apr_lib.h" /* for apr_getpass() */
#include "apr_general.h"
#include "apr_signal.h"
#include "apr_strings.h" /* for apr_pstrdup() */
#define APR_WANT_STDIO
#define APR_WANT_STRFUNC
#include "apr_want.h"
#endif
#include <stdlib.h>
#endif
#ifdef WIN32
#include <conio.h>
#endif
#define LF '\n'
#define CR '\r'
#else
#define LF 10
#define CR 13
#endif /* APR_CHARSET_EBCDIC */
#define MAX_STRING_LEN 256
#endif
static void cleanup_tempfile_and_exit(int rc)
{
if (tfp) {
}
}
{
int x = 0, y;
word[x] = '\0';
if (line[x])
++x;
y = 0;
}
static int get_line(char *s, int n, apr_file_t *f)
{
register int i = 0;
char ch;
while (i < (n - 1) &&
s[i++] = ch;
}
if (ch == '\n')
s[i++] = ch;
s[i] = '\0';
if (rv != APR_SUCCESS)
return 1;
return 0;
}
static void putline(apr_file_t *f, char *l)
{
int x;
for (x = 0; l[x]; x++)
apr_file_putc(l[x], f);
}
{
char *pw;
unsigned char digest[16];
char string[MAX_STRING_LEN];
char pwin[MAX_STRING_LEN];
char pwv[MAX_STRING_LEN];
unsigned int i;
}
}
/* Do MD5 stuff */
#endif
for (i = 0; i < 16; i++)
apr_file_printf(f, "\n");
}
static void usage(void)
{
exit(1);
}
static void interrupted(void)
{
}
static void terminate(void)
{
#ifdef NETWARE
pressanykey();
#endif
}
{
apr_file_t *f;
char tn[] = "htdigest.tmp.XXXXXX";
char *dirname;
char user[MAX_STRING_LEN];
char realm[MAX_STRING_LEN];
char line[MAX_STRING_LEN];
char l[MAX_STRING_LEN];
char w[MAX_STRING_LEN];
char x[MAX_STRING_LEN];
int found;
if (rv) {
exit(1);
}
#endif
if (argc == 5) {
usage();
if (rv != APR_SUCCESS) {
char errmsg[120];
argv[2],
exit(1);
}
apr_file_close(f);
exit(0);
}
else if (argc != 4)
usage();
argv[0]);
exit(1);
}
exit(1);
}
}
found = 0;
continue;
}
getword(w, l, ':');
getword(x, l, ':');
continue;
}
else {
found = 1;
}
}
if (!found) {
}
apr_file_close(f);
/* The temporary file has all the data, just copy it to the new location.
*/
APR_SUCCESS) {
}
return 0;
}