]> andersk Git - moira.git/blobdiff - server/mr_sauth.c
added copyright message
[moira.git] / server / mr_sauth.c
index f723c0027c3c9f4219d13504eac0e6c58697490c..3930979a6a4ce3e1cfe4309a44c37949451ca9a1 100644 (file)
@@ -4,14 +4,9 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *
- *     $Log$
- *     Revision 1.2  1987-06-04 01:34:35  wesommer
- *     Added logging of arguments for some perverse reason.
- *
- * Revision 1.1  87/06/02  20:06:57  wesommer
- * Initial revision
- * 
  */
 
 #ifndef lint
@@ -19,9 +14,8 @@ static char *rcsid_sms_sauth_c = "$Header$";
 #endif lint
 
 extern int krb_err_base;
-#include <krb.h>
+#include <mit-copyright.h>
 #include <strings.h>
-#include "sms_private.h"
 #include "sms_server.h"
 
 extern char buf1[];
@@ -45,22 +39,35 @@ do_auth(cl)
        int status;
        char buf[REALM_SZ+INST_SZ+ANAME_SZ];
        extern int krb_err_base;
+       static char *unknown = "???";
+       
+       if (cl->clname) {
+               free(cl->clname);
+               cl->clname = 0;
+               cl->users_id = 0;
+               bzero(&cl->kname, sizeof(cl->kname));
+       }
+       if (cl->entity && cl->entity != unknown) {
+               free(cl->entity);
+               cl->entity = 0;
+       }
        
-       com_err(whoami, 0, "Processing auth: ");
-       log_args(cl->args->sms_argc, cl->args->sms_argv);
-
        auth.length = cl->args->sms_argl[0];
-
        bcopy(cl->args->sms_argv[0], (char *)auth.dat, auth.length);
        auth.mbz = 0;
        
-       if ((status = rd_ap_req (&auth, "sms", "sms", cl->haddr.sin_addr,
+       if ((status = krb_rd_req (&auth, "sms", "sms", cl->haddr.sin_addr,
                                 &ad, "")) != KSUCCESS) {
                status += krb_err_base;
                cl->reply.sms_status = status;
-               com_err(whoami, status, "(authentication failed)");
+               if (log_flags & LOG_RES)
+                       com_err(whoami, status, "(authentication failed)");
                return;
        }
+       bcopy(ad.pname, cl->kname.name, ANAME_SZ);
+       bcopy(ad.pinst, cl->kname.inst, INST_SZ);
+       bcopy(ad.prealm, cl->kname.realm, REALM_SZ);
+       
        (void) strcpy(buf, ad.pname);
        if(ad.pinst[0]) {
                (void) strcat(buf, ".");
@@ -72,6 +79,22 @@ do_auth(cl)
        
        cl->clname = (char *)malloc((unsigned)(strlen(buf)+1));
        (void) strcpy(cl->clname, buf);
-       (void) sprintf(buf1, "Authenticated to %s", cl->clname);
-       com_err(whoami, 0, buf1);
+       bzero(&ad, sizeof(ad)); /* Clean up session key, etc. */
+
+       cl->users_id = get_users_id(cl->kname.name);
+
+       if (cl->args->sms_version_no == SMS_VERSION_2) {
+           unsigned len = strlen(cl->args->sms_argv[1]) + 1;
+
+           cl->entity = (char *)malloc(len);
+           bcopy(cl->args->sms_argv[1], cl->entity, len+1);
+       } else {
+           cl->entity = unknown;
+       }
+
+       if (log_flags & LOG_RES)
+           com_err(whoami, 0, "Authenticated to %s using %s, id %d",
+                   cl->clname, cl->entity, cl->users_id);
+       if (cl->users_id == 0)
+         cl->reply.sms_status = SMS_USER_AUTH;
 }
This page took 0.035619 seconds and 4 git commands to generate.