]> andersk Git - moira.git/blobdiff - server/mr_glue.c
use new com_err library; update Kerberos com_err usage
[moira.git] / server / mr_glue.c
index 95dca80d853ce919d6c30cbc7ea642e01b85a8fb..aa851d3163c05f49cc9f74ea2f419a9fabf65a50 100644 (file)
@@ -4,50 +4,45 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *
  *     Glue routines to allow the database stuff to be linked in to
  *     a program expecting a library level interface.
- * 
- *     $Log$
- *     Revision 1.4  1987-09-21 15:17:09  wesommer
- *     Also need to initialize pseudo_client.clname.
- *
- * Revision 1.3  87/08/22  17:31:56  wesommer
- * Fix a "fall-through".
- * 
- * Revision 1.2  87/07/29  16:03:58  wesommer
- * Initialize krb_realm.
- * 
- * Revision 1.1  87/07/14  00:41:18  wesommer
- * Initial revision
- * 
  */
 
 #ifndef lint
 static char *rcsid_sms_glue_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include "sms_server.h"
-#include <krb.h>               /* XXX for error codes */
+#include <krb_et.h>
 #include <pwd.h>
+#include "query.h"
+
 static int already_connected = 0;
 
 #define CHECK_CONNECTED { if (!already_connected) return SMS_NOT_CONNECTED; }
 
 static client pseudo_client;
-extern int krb_err_base;
-extern char *malloc();
+extern int errno;
+extern char *malloc(), *whoami;
+extern time_t now;
 
-sms_connect()
+sms_connect(server)
+char *server;
 {
     register int status;
+    extern int query_timeout;
 
     if (already_connected) return SMS_ALREADY_CONNECTED;
 
-    init_sms_err_tbl();
-    init_krb_err_tbl();
+    initialize_sms_error_table();
+    initialize_krb_error_table();
     bzero((char *)&pseudo_client, sizeof(pseudo_client)); /* XXX */
 
+    query_timeout = 0;
     status =  sms_open_database();
     if (!status) already_connected = 1;
     return status;
@@ -69,15 +64,16 @@ sms_noop()
 /*
  * This routine is rather bogus, as it only fills in who you claim to be.
  */
-sms_auth()
+sms_auth(prog)
+char *prog;
 {
     struct passwd *pw;
     extern char *krb_realm;
-    char buf[1024];
+    char buf[1024], *strsave();
     
     CHECK_CONNECTED;
     pw = getpwuid(getuid());
-    if (!pw) return (KDC_PR_UNKNOWN + krb_err_base); /* XXX hack (we 
+    if (!pw) return (KDC_PR_UNKNOWN + ERROR_TABLE_BASE_krb); /* XXX hack (we 
                                                    * need an extended 
                                                    * error code table)
                                                    */
@@ -90,9 +86,30 @@ sms_auth()
     strcat(buf, pseudo_client.kname.realm);
     pseudo_client.clname = malloc(strlen(buf)+1);
     strcpy(pseudo_client.clname, buf);
+    pseudo_client.users_id = get_users_id(pseudo_client.kname.name);
+    pseudo_client.entity = strsave(prog);
+    pseudo_client.args = (sms_params *) malloc(sizeof(sms_params));
+    pseudo_client.args->sms_version_no = SMS_VERSION_2;
     return 0;
 }
 
+struct hint {
+    int (*proc)();
+    char *hint;
+};
+
+callback(argc, argv, arg)
+int argc;
+char **argv;
+struct hint *arg;
+{
+    if (sms_trim_args(argc, argv) == SMS_NO_MEM) {
+       com_err(whoami, SMS_NO_MEM, "while trimmming args");
+    }
+    (*arg->proc)(argc, argv, arg->hint);
+}
+
+
 int sms_query(name, argc, argv, callproc, callarg)
     char *name;                /* Query name */
     int argc;          /* Arg count */
@@ -100,8 +117,13 @@ int sms_query(name, argc, argv, callproc, callarg)
     int (*callproc)(); /* Callback procedure */
     char *callarg;             /* Callback argument */
 {
+    struct hint hints;
+
+    time(&now);
+    hints.proc = callproc;
+    hints.hint = callarg;
     return sms_process_query(&pseudo_client, name, argc, argv,
-                            callproc, callarg);
+                            callback, &hints);
 }
 
 int sms_access(name, argc, argv)
@@ -109,6 +131,7 @@ int sms_access(name, argc, argv)
     int argc;                  /* Arg count */
     char **argv;               /* Args */
 {
+    time(&now);
     return sms_check_access(&pseudo_client, name, argc, argv);
 }
 
@@ -118,14 +141,20 @@ int sms_query_internal(argc, argv, callproc, callarg)
     int (*callproc)();
     char *callarg;
 {
+    struct hint hints;
+
+    time(&now);
+    hints.proc = callproc;
+    hints.hint = callarg;
     return sms_process_query(&pseudo_client, argv[0], argc-1, argv+1,
-                            callproc, callarg);
+                            callback, &hints);
 }
 
 int sms_access_internal(argc, argv)
     int argc;
     char **argv;
 {
+    time(&now);
     return sms_check_access(&pseudo_client, argv[0], argc-1, argv+1);
 }
 
@@ -135,13 +164,35 @@ sms_shutdown(why)
     fprintf(stderr, "Sorry, not implemented\n");
 }
 
-/*
- * 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:
+
+/* trigger_dcm is also used as a followup routine to the 
+ * set_server_host_override query, hence the two dummy arguments.
  */
+
+struct query pseudo_query = {
+       "trigger_dcm",
+       "tdcm",
+};
+
+trigger_dcm(dummy0, dummy1, cl)
+       int dummy0, dummy1;
+       client *cl;
+{
+       register int pid, status;
+       
+       if (status = check_query_access(&pseudo_query, 0, cl))
+           return(status);
+
+       pid = vfork();
+       switch (pid) {
+       case 0:
+               execl("/u1/sms/bin/startdcm", "startdcm", 0);
+               exit(1);
+               
+       case -1:
+               return(errno);
+
+       default:
+               return(SMS_SUCCESS);
+       }
+}
This page took 0.075126 seconds and 4 git commands to generate.