]> andersk Git - moira.git/blobdiff - lib/mr_auth.c
#define the zephyr stuff & add syslog definitions as well
[moira.git] / lib / mr_auth.c
index b3c9f4e7653f4e1e95a9b4f40999587643ae1fc0..4d7c717cb662ca23cfba9c176d4ce403bf42d3de 100644 (file)
@@ -4,11 +4,8 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *
- *     $Log$
- *     Revision 1.1  1987-05-20 03:11:18  wesommer
- *     Initial revision
- *
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *
  *     Handles the client side of the sending of authenticators to
  * the sms server.     
 static char *rcsid_sms_auth_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include "sms_private.h"
 #include <krb.h>
+#include <krb_et.h>
+
+/* Authenticate this client with the SMS server.  prog is the name of the
+ * client program, and will be recorded in the database.
+ */
 
-int sms_auth()
+int sms_auth(prog)
+char *prog;
 {
-       int status;
-       struct sms_params aparms;
+    register int status;
+    sms_params params_st;
+    char *args[2];
+    int argl[2];
+    char realm[REALM_SZ];
+    char host[BUFSIZ];
+
+    register sms_params *params = &params_st;
+    sms_params *reply = NULL;
+    KTEXT_ST auth;
+
+    CHECK_CONNECTED;
        
-       if (!_sms_conn) {
-               return SMS_NOT_CONNECTED;
-       }
+    /*
+     * Build a Kerberos authenticator.
+     * The "service" and "instance" should not be hardcoded here.
+     */
        
-       /*
-        * Build a Kerberos authenticator.
-        */
+    bzero(host, sizeof(host));
+    if (status = sms_host(host, sizeof(host) - 1))
+       return status;
+
+    strcpy(realm, krb_realmofhost(host));
+
+    status = krb_mk_req(&auth, "sms", "sms", realm, 0);
+    if (status != KSUCCESS) {
+       status += ERROR_TABLE_BASE_krb;
+       return status;
+    } 
+    params->sms_version_no = sending_version_no;
+    params->sms_procno = SMS_AUTH;
+    params->sms_argc = 2;
+    params->sms_argv = args;
+    params->sms_argl = argl;
+    params->sms_argv[0] = (char *)auth.dat;
+    params->sms_argl[0] = auth.length;
+    params->sms_argv[1] = prog;
+    params->sms_argl[1] = strlen(prog) + 1;
        
-       status = mk_ap_req(&auth, "sms", "sms", "ATHENA.MIT.EDU", 0);
-       if (status != KSUCCESS) {
-               status += krb_err_base;
-               goto punt;
-       }
+    if (sending_version_no == SMS_VERSION_1)
+       params->sms_argc = 1;
 
-       if (!sms_call_op)
-               sms_call_op = create_operation();
+    if ((status = sms_do_call(params, &reply)) == 0)
+       status = reply->sms_status;
 
+    sms_destroy_reply(reply);
 
-               
-       
-       
-       
+    return status;
 }
This page took 0.044667 seconds and 4 git commands to generate.