]> granicus.if.org Git - sudo/commitdiff
combine skey/opie code into rfc1938.c
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 11 Jul 1999 18:42:34 +0000 (18:42 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 11 Jul 1999 18:42:34 +0000 (18:42 +0000)
auth/opie.c [deleted file]
auth/rfc1938.c [moved from auth/skey.c with 74% similarity]
auth/sudo_auth.h

diff --git a/auth/opie.c b/auth/opie.c
deleted file mode 100644 (file)
index 74f2869..0000000
+++ /dev/null
@@ -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);
-}
similarity index 74%
rename from auth/skey.c
rename to auth/rfc1938.c
index c930a24bcacc013ad963bfd6645f5ad63639315a..3047d9ad68c4a06f2ba7ba337ad89c066071928b 100644 (file)
@@ -1,6 +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
  *  it under the terms of the GNU General Public License as published by
 #include <sys/param.h>
 #include <sys/types.h>
 #include <pwd.h>
+
+#if defined(HAVE_SKEY)
 #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_auth.h"
@@ -47,7 +58,7 @@ static const char rcsid[] = "$Sudo$";
 #endif /* lint */
 
 int
-skey_setup(pw, promptp, data)
+rfc1938_setup(pw, promptp, data)
     struct passwd *pw;
     char **promptp;
     void **data;
@@ -55,11 +66,11 @@ skey_setup(pw, promptp, data)
     char challenge[256];
     static char *orig_prompt = NULL, *new_prompt = NULL;
     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)
-       *data = &skey;
+       *data = &rfc1938;
 
     /* Save the original prompt */
     if (orig_prompt == NULL) {
@@ -71,15 +82,17 @@ skey_setup(pw, promptp, data)
            op_len--;
     }
 
+#ifdef HAVE_SKEY
     /* Close old stream */
-    if (skey.keyfile)
-       (void) fclose(skey.keyfile);
+    if (rfc1938.keyfile)
+       (void) fclose(rfc1938.keyfile);
+#endif
 
-    /* Get the skey part of the prompt */
-    if (skeychallenge(&skey, user_name, challenge) != 0) {
+    /* Get the rfc1938 part of the prompt */
+    if (rfc1938challenge(&rfc1938, pw->pw_name, challenge) != 0) {
 #ifdef OTP_ONLY
        (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]);
        return(AUTH_FATAL);
 #else
@@ -104,14 +117,13 @@ skey_setup(pw, promptp, data)
 }
 
 int
-skey_verify(pw, pass, data)
+rfc1938_verify(pw, pass, data)
     struct passwd *pw;
     char *pass;
     void **data;
 {
-    struct skey *skeyp = (struct skey *) (*data);
 
-    if (skeyverify(skeyp, pass) == 0)
+    if (rfc1938verify((struct RFC1938 *) (*data), pass) == 0)
        return(AUTH_SUCCESS);
     else
        return(AUTH_FAILURE);
index e0224eb6b942f9cc963dd9968aacebfc04924ad3..7870f841228d291cd1f054789110f1496730e831 100644 (file)
@@ -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 secureware_setup __P((struct passwd *pw, char **prompt, 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 skey_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 rfc1938_setup __P((struct passwd *pw, char **prompt, void **data));
+int rfc1938_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_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)
 #  define AUTH_STANDALONE \
        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 \
-       AUTH_ENTRY(1, "skey", skey_setup, skey_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)
+       AUTH_ENTRY(1, "rfc1938", rfc1938_setup, rfc1938_verify, NULL)
 #  define AUTH_STANDALONE_GETPASS
 #endif