combine skey/opie code into rfc1938.c
This commit is contained in:
114
auth/opie.c
114
auth/opie.c
@@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* CU sudo version 1.6
|
|
||||||
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 1, or (at your option)
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*
|
|
||||||
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] = "$Sudo$";
|
|
||||||
#endif /* lint */
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef STDC_HEADERS
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif /* STDC_HEADERS */
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif /* HAVE_UNISTD_H */
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif /* HAVE_STRING_H */
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif /* HAVE_STRINGS_H */
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <opie.h>
|
|
||||||
|
|
||||||
#include "sudo.h"
|
|
||||||
#include "sudo_auth.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
opie_setup(pw, promptp, data)
|
|
||||||
struct passwd *pw;
|
|
||||||
char **promptp;
|
|
||||||
void **data;
|
|
||||||
{
|
|
||||||
char challenge[OPIE_CHALLENGE_MAX];
|
|
||||||
static char *orig_prompt = NULL, *new_prompt = NULL;
|
|
||||||
static int op_len, np_size;
|
|
||||||
static struct opie opie;
|
|
||||||
|
|
||||||
/* Stash a pointer to the opie struct if we have not initialized */
|
|
||||||
if (!*data)
|
|
||||||
*data = &opie;
|
|
||||||
|
|
||||||
/* Save the original prompt */
|
|
||||||
if (orig_prompt == NULL) {
|
|
||||||
orig_prompt = *promptp;
|
|
||||||
op_len = strlen(orig_prompt);
|
|
||||||
|
|
||||||
/* Ignore trailing colon (we will add our own) */
|
|
||||||
if (orig_prompt[op_len - 1] == ':')
|
|
||||||
op_len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the opie part of the prompt */
|
|
||||||
if (opiechallenge(&opie, user_name, challenge) != 0) {
|
|
||||||
#ifdef OTP_ONLY
|
|
||||||
(void) fprintf(stderr,
|
|
||||||
"%s: You do not exist in the s/key database.\n",
|
|
||||||
Argv[0]);
|
|
||||||
return(AUTH_FATAL);
|
|
||||||
#else
|
|
||||||
return(AUTH_FAILURE);
|
|
||||||
#endif /* OTP_ONLY */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get space for new prompt with embedded S/Key challenge */
|
|
||||||
if (np_size < op_len + strlen(challenge) + 7) {
|
|
||||||
np_size = op_len + strlen(challenge) + 7;
|
|
||||||
new_prompt = (char *) erealloc(new_prompt, np_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LONG_OTP_PROMPT
|
|
||||||
(void) sprintf(new_prompt, "%s\n%s", challenge, orig_prompt);
|
|
||||||
#else
|
|
||||||
(void) sprintf(new_prompt, "%.*s [ %s ]:", op_len, orig_prompt, challenge);
|
|
||||||
#endif /* LONG_OTP_PROMPT */
|
|
||||||
|
|
||||||
*promptp = new_prompt;
|
|
||||||
return(AUTH_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
opie_verify(pw, pass, data)
|
|
||||||
struct passwd *pw;
|
|
||||||
char *pass;
|
|
||||||
void **data;
|
|
||||||
{
|
|
||||||
struct opie *opiep = (struct opie *) (*data);
|
|
||||||
|
|
||||||
if (opieverify(opiep, pass) == 0)
|
|
||||||
return(AUTH_SUCCESS);
|
|
||||||
else
|
|
||||||
return(AUTH_FAILURE);
|
|
||||||
}
|
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CU sudo version 1.6
|
* CU sudo version 1.6
|
||||||
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -37,7 +37,18 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_SKEY)
|
||||||
#include <skey.h>
|
#include <skey.h>
|
||||||
|
#define RFC1938 skey
|
||||||
|
#define rfc1938challenge skeychallenge
|
||||||
|
#define rfc1938verify skeyverify
|
||||||
|
#elif defined(HAVE_OPIE)
|
||||||
|
#include <opie.h>
|
||||||
|
#define RFC1938 opie
|
||||||
|
#define rfc1938challenge opiechallenge
|
||||||
|
#define rfc1938verify opieverify
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
#include "sudo_auth.h"
|
#include "sudo_auth.h"
|
||||||
@@ -47,7 +58,7 @@ static const char rcsid[] = "$Sudo$";
|
|||||||
#endif /* lint */
|
#endif /* lint */
|
||||||
|
|
||||||
int
|
int
|
||||||
skey_setup(pw, promptp, data)
|
rfc1938_setup(pw, promptp, data)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char **promptp;
|
char **promptp;
|
||||||
void **data;
|
void **data;
|
||||||
@@ -55,11 +66,11 @@ skey_setup(pw, promptp, data)
|
|||||||
char challenge[256];
|
char challenge[256];
|
||||||
static char *orig_prompt = NULL, *new_prompt = NULL;
|
static char *orig_prompt = NULL, *new_prompt = NULL;
|
||||||
static int op_len, np_size;
|
static int op_len, np_size;
|
||||||
static struct skey skey;
|
static struct RFC1938 rfc1938;
|
||||||
|
|
||||||
/* Stash a pointer to the skey struct if we have not initialized */
|
/* Stash a pointer to the rfc1938 struct if we have not initialized */
|
||||||
if (!*data)
|
if (!*data)
|
||||||
*data = &skey;
|
*data = &rfc1938;
|
||||||
|
|
||||||
/* Save the original prompt */
|
/* Save the original prompt */
|
||||||
if (orig_prompt == NULL) {
|
if (orig_prompt == NULL) {
|
||||||
@@ -71,15 +82,17 @@ skey_setup(pw, promptp, data)
|
|||||||
op_len--;
|
op_len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SKEY
|
||||||
/* Close old stream */
|
/* Close old stream */
|
||||||
if (skey.keyfile)
|
if (rfc1938.keyfile)
|
||||||
(void) fclose(skey.keyfile);
|
(void) fclose(rfc1938.keyfile);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the skey part of the prompt */
|
/* Get the rfc1938 part of the prompt */
|
||||||
if (skeychallenge(&skey, user_name, challenge) != 0) {
|
if (rfc1938challenge(&rfc1938, pw->pw_name, challenge) != 0) {
|
||||||
#ifdef OTP_ONLY
|
#ifdef OTP_ONLY
|
||||||
(void) fprintf(stderr,
|
(void) fprintf(stderr,
|
||||||
"%s: You do not exist in the s/key database.\n",
|
"%s: You do not exist in the OTP database.\n",
|
||||||
Argv[0]);
|
Argv[0]);
|
||||||
return(AUTH_FATAL);
|
return(AUTH_FATAL);
|
||||||
#else
|
#else
|
||||||
@@ -104,14 +117,13 @@ skey_setup(pw, promptp, data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
skey_verify(pw, pass, data)
|
rfc1938_verify(pw, pass, data)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *pass;
|
char *pass;
|
||||||
void **data;
|
void **data;
|
||||||
{
|
{
|
||||||
struct skey *skeyp = (struct skey *) (*data);
|
|
||||||
|
|
||||||
if (skeyverify(skeyp, pass) == 0)
|
if (rfc1938verify((struct RFC1938 *) (*data), pass) == 0)
|
||||||
return(AUTH_SUCCESS);
|
return(AUTH_SUCCESS);
|
||||||
else
|
else
|
||||||
return(AUTH_FAILURE);
|
return(AUTH_FAILURE);
|
@@ -33,10 +33,8 @@ int dce_verify __P((struct passwd *pw, char *pass, void **data));
|
|||||||
int passwd_verify __P((struct passwd *pw, char *pass, void **data));
|
int passwd_verify __P((struct passwd *pw, char *pass, void **data));
|
||||||
int secureware_setup __P((struct passwd *pw, char **prompt, void **data));
|
int secureware_setup __P((struct passwd *pw, char **prompt, void **data));
|
||||||
int secureware_verify __P((struct passwd *pw, char *pass, void **data));
|
int secureware_verify __P((struct passwd *pw, char *pass, void **data));
|
||||||
int skey_setup __P((struct passwd *pw, char **prompt, void **data));
|
int rfc1938_setup __P((struct passwd *pw, char **prompt, void **data));
|
||||||
int skey_verify __P((struct passwd *pw, char *pass, void **data));
|
int rfc1938_verify __P((struct passwd *pw, char *pass, void **data));
|
||||||
int opie_setup __P((struct passwd *pw, char **prompt, void **data));
|
|
||||||
int opie_verify __P((struct passwd *pw, char *pass, void **data));
|
|
||||||
int afs_verify __P((struct passwd *pw, char *pass, void **data));
|
int afs_verify __P((struct passwd *pw, char *pass, void **data));
|
||||||
int kerb4_setup __P((struct passwd *pw, char **prompt, void **data));
|
int kerb4_setup __P((struct passwd *pw, char **prompt, void **data));
|
||||||
int kerb4_verify __P((struct passwd *pw, char *pass, void **data));
|
int kerb4_verify __P((struct passwd *pw, char *pass, void **data));
|
||||||
@@ -65,13 +63,9 @@ int kerb5_verify __P((struct passwd *pw, char *pass, void **data));
|
|||||||
#elif defined(HAVE_FWTK)
|
#elif defined(HAVE_FWTK)
|
||||||
# define AUTH_STANDALONE \
|
# define AUTH_STANDALONE \
|
||||||
AUTH_ENTRY(1, "fwtk", fwtk_setup, fwtk_verify, fwtk_cleanup)
|
AUTH_ENTRY(1, "fwtk", fwtk_setup, fwtk_verify, fwtk_cleanup)
|
||||||
#elif defined(HAVE_SKEY) && defined(OTP_ONLY)
|
#elif defined(OTP_ONLY) && (defined(HAVE_SKEY) || defined(HAVE_OPIE))
|
||||||
# define AUTH_STANDALONE \
|
# define AUTH_STANDALONE \
|
||||||
AUTH_ENTRY(1, "skey", skey_setup, skey_verify, NULL)
|
AUTH_ENTRY(1, "rfc1938", rfc1938_setup, rfc1938_verify, NULL)
|
||||||
# define AUTH_STANDALONE_GETPASS
|
|
||||||
#elif defined(HAVE_OPIE) && defined(OTP_ONLY)
|
|
||||||
# define AUTH_STANDALONE \
|
|
||||||
AUTH_ENTRY(1, "opie", opie_setup, opie_verify, NULL)
|
|
||||||
# define AUTH_STANDALONE_GETPASS
|
# define AUTH_STANDALONE_GETPASS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user