]> andersk Git - moira.git/blobdiff - lib/mr_auth.c
Make sure error code is always non-zero on failed connect.
[moira.git] / lib / mr_auth.c
index 1fbaeeeb678f3bee673f9bd8554de4b4cb548e29..852bf251508efd5df3d51803da489368e1b122e7 100644 (file)
@@ -6,9 +6,12 @@
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  *
  *     $Log$
- *     Revision 1.2  1987-05-31 22:03:23  wesommer
- *     It's working better.
+ *     Revision 1.3  1987-06-16 17:47:20  wesommer
+ *     Clean up memory allocation, indenting.
  *
+ * Revision 1.2  87/05/31  22:03:23  wesommer
+ * It's working better.
+ * 
  * Revision 1.1  87/05/20  03:11:18  wesommer
  * Initial revision
  * 
@@ -28,45 +31,49 @@ extern int krb_err_base;
 
 int sms_auth()
 {
-       int status;
-       sms_params *params = NULL, *reply = NULL;
-       KTEXT_ST auth;
+    register int status;
+    sms_params params_st;
+    char *args[1];
+    int argl[1];
+    
+    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.
-        */
+    status = mk_ap_req(&auth, "sms", "sms", "ATHENA.MIT.EDU", 0);
+    if (status != KSUCCESS) {
+       status += krb_err_base;
+       return status;
+    }
+    params->sms_procno = SMS_AUTH;
+    params->sms_argc = 1;
+    params->sms_argv = args;
+    params->sms_argl = argl;
+    params->sms_argv[0] = (char *)auth.dat;
+    params->sms_argl[0] = auth.length;
        
-       status = mk_ap_req(&auth, "sms", "sms", "ATHENA.MIT.EDU", 0);
-       if (status != KSUCCESS) {
-               status += krb_err_base;
-               goto punt;
-       }
-       params = (struct sms_params *) malloc(sizeof(*params));
-       params->sms_procno = SMS_AUTH;
-       params->sms_argc = 1;
+    if ((status = sms_do_call(params, &reply)) == 0)
+       status = reply->sms_status;
 
-       params->sms_argv = (char **)malloc(sizeof(char *) * 2);
-       params->sms_argl = (int *)malloc(sizeof(int) * 2);
-       params->sms_argv[0] = (char *)auth.dat;
-       params->sms_argl[0] = auth.length;
-       params->sms_argv[1] = NULL;
-       params->sms_argl[1] = 0;
-       
-       if ((status = sms_do_call(params, &reply)) || (status = reply->sms_status))
-               goto punt;
-punt:
-       sms_destroy_reply(reply);
-ok:
-       if(params) {
-               if(params->sms_argv)
-                       free(params->sms_argv);
-               if(params->sms_argl)
-                       free(params->sms_argl);
-               free(params);
-       }
-       return status;
+    sms_destroy_reply(reply);
+
+    return status;
 }
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-continued-statement-offset: 4
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * End:
+ */
This page took 0.061342 seconds and 4 git commands to generate.