]> andersk Git - moira.git/blobdiff - reg_svr/reg_svr.pc
Build without krb4 if it's unavailable.
[moira.git] / reg_svr / reg_svr.pc
index 7beb6f0af8b0bc9ab914f550960f90aecef9eb4f..1016e18649431f7594cfcf918e4271890f1183f6 100644 (file)
@@ -33,7 +33,9 @@
 #include <unistd.h>
 
 #include <com_err.h>
+#ifdef HAVE_KRB4
 #include <krb.h>
+#endif
 
 EXEC SQL INCLUDE sqlca;
 
@@ -788,6 +790,9 @@ void QUIT(reg_client *rc, int argc, char **argv)
 /* Register a user in Moira */
 int register_user(int uid, char *username)
 {
+  EXEC SQL BEGIN DECLARE SECTION;
+  char class[USERS_TYPE_SIZE];
+  EXEC SQL END DECLARE SECTION;
   char uidbuf[10], *qargv[3], *motd = NULL;
   long status;
 
@@ -802,13 +807,7 @@ int register_user(int uid, char *username)
       return MR_DOWN;
     }
 
-  status = krb_get_svc_in_tkt(REG_SVR_PRINCIPAL, REG_SVR_INSTANCE,
-                             krb_realmofhost(hostname), MOIRA_SNAME,
-                             shorthostname, 3, KEYFILE);
-  if (status)
-    status += ERROR_TABLE_BASE_krb;
-  else
-    status = mr_auth("reg_svr");
+  status = mr_krb5_auth("reg_svr");
   if (status)
     {
       com_err(whoami, status, "authenticating to moira");
@@ -816,10 +815,28 @@ int register_user(int uid, char *username)
       return MR_INTERNAL;
     }
 
+  EXEC SQL SELECT type INTO :class FROM users WHERE unix_uid = :uid;
+
   sprintf(uidbuf, "%d", uid);
   qargv[0] = uidbuf;
   qargv[1] = username;
-  qargv[2] = "IMAP";
+
+  /* Incoming students should be given Exchange poboxes.
+   * Doesn't work for undergrads in the class of 2100 or higher.
+   */ 
+  if (!strcmp(strtrim(class), "G") || !strncmp(class, "FALL", 4) ||
+      !strncmp(class, "SPRING", 5) || !strncmp(class, "SUMMER", 6) ||
+      !strncmp(class, "20", 2))
+    {
+      com_err(whoami, 0, "assigning EXCHANGE pobox to user %s, class %s", username, class);
+      qargv[2] = "EXCHANGE";
+    }
+  else 
+    {
+      com_err(whoami, 0, "assigning IMAP pobox to user %s, class %s", username, class);
+      qargv[2] = "IMAP";
+    }
+
   status = mr_query("register_user", 3, qargv, NULL, NULL);
   mr_disconnect();
   return status;
@@ -985,6 +1002,13 @@ int check_username_available(char *username)
   if (count != 0)
     return MR_IN_USE;
 
+  EXEC SQL SELECT COUNT(login) INTO :count FROM userhistory
+    WHERE login = :username;
+  if (sqlca.sqlcode)
+    return MR_DBMS_ERR;
+  if (count != 0)
+    return MR_IN_USE;
+
   return MR_SUCCESS;
 }
 
This page took 0.039845 seconds and 4 git commands to generate.