[2012] in Moira Commits

home help back first fref pref prev next nref lref last post

/svn/moira r4153 - trunk/moira/server

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu Feb 6 14:09:44 2014

Date: Thu, 6 Feb 2014 14:09:37 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201402061909.s16J9bK8004455@drugstore.mit.edu>
To: moira-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2014-02-06 14:09:37 -0500 (Thu, 06 Feb 2014)
New Revision: 4153

Modified:
   trunk/moira/server/qsupport.pc
   trunk/moira/server/queries2.c
Log:
Add user pin queries, tweak register_user semantics for Kerberos-only registrations.

Modified: trunk/moira/server/qsupport.pc
===================================================================
--- trunk/moira/server/qsupport.pc	2013-12-11 14:01:40 UTC (rev 4152)
+++ trunk/moira/server/qsupport.pc	2014-02-06 19:09:37 UTC (rev 4153)
@@ -94,6 +94,8 @@
     }
   else if (!strcmp(argv[1], "SMTP") || !strcmp(argv[1], "SPLIT"))
     {
+      if (!*box)
+	return MR_BAD_CHAR;
       if (strchr(box, '/') || strchr(box, '|'))
 	return MR_BAD_CHAR;
       status = name_to_id(box, STRINGS_TABLE, &id);
@@ -1750,7 +1752,7 @@
   EXEC SQL SELECT users_id, status INTO :users_id, :ostatus
     FROM users
     WHERE unix_uid = :uid AND
-    (status = 0 OR status = 5 OR status = 6 OR status = 9);
+    (status = 0 OR status = 5 OR status = 6 OR status = 8 OR status = 9);
 
   if (sqlca.sqlerrd[2] == 0)
     return MR_NO_MATCH;
@@ -1795,7 +1797,7 @@
 	WHERE label = :login || '.po';
       if (dbms_errno)
 	return mr_errcode;
-      if ((ostatus == 0 || ostatus == 9) || (tmp != users_id))
+      if ((ostatus == 0 || ostatus == 8 || ostatus == 9) || (tmp != users_id))
 	return MR_IN_USE;
       else
 	po_exists = 1;
@@ -1817,7 +1819,7 @@
     po_exists = 1;
 
   /* choose type and location for pobox */
-  if (!po_exists)
+  if (!po_exists && ostatus != 8)
     {
       if (!strcmp(potype, "POP"))
 	{
@@ -1951,6 +1953,9 @@
   nstatus = 2;
   if (ostatus == 5 || ostatus == 6 || ostatus == 9)
     nstatus = 1;
+  /* Weird, but correct */
+  if (ostatus == 8)
+    nstatus = 8;
   EXEC SQL UPDATE users SET login = :login, status = :nstatus,
     modtime = SYSDATE, modby = :who, modwith = :entity,
     pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity,
@@ -1969,6 +1974,13 @@
   com_err(whoami, 0, "set login name to %s", login);
   incremental_after(USERS_TABLE, buffer, 0);
 
+  /* If this is a status 8 -> status 9 registration, we're done. */
+  if (ostatus == 8) {
+    EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
+      WHERE table_name = 'users';
+    return MR_SUCCESS;
+  }
+
   /* create filesystem */
   if (set_next_object_id("filsys_id", FILESYS_TABLE, 0))
     return MR_NO_ID;

Modified: trunk/moira/server/queries2.c
===================================================================
--- trunk/moira/server/queries2.c	2013-12-11 14:01:40 UTC (rev 4152)
+++ trunk/moira/server/queries2.c	2014-02-06 19:09:37 UTC (rev 4153)
@@ -1102,6 +1102,33 @@
   set_modtime_by_id,
 };
 
+static char *uupi_fields[] = {
+  "login",
+  "pin",
+};
+
+static struct valobj uupi_valobj[] = {
+  {V_ID, 0, USERS_TABLE, "login", "users_id", MR_USER},
+  {V_CHAR, 1, USERS_TABLE, "pin"},
+};
+
+static struct validate uupi_validate = {
+  uupi_valobj,
+  2,
+  0,
+  0,
+  0,
+  "users_id",
+  0,
+  0,
+  set_modtime_by_id,
+};
+
+static char *gupi_fields[] = {
+  "login",
+  "pin",
+};
+
 static char *dusr_fields[] = {
   "login",
 };
@@ -5776,6 +5803,42 @@
   },
 
   {
+    /* Q_UUPI - UPDATE_USER_PIN */
+    "update_user_pin",
+    "uupi",
+    2,
+    MR_Q_UPDATE,
+    "u",
+    USERS_TABLE,
+    "users SET pin = '%s'",
+    uupi_fields,
+    2,
+    1,
+    "users_id = %d",
+    1,
+    NULL,
+    &uupi_validate,
+  },
+
+  {
+    /* Q_GUPI - GET_USER_PIN */
+    "get_user_pin",
+    "gupi",
+    2,
+    MR_Q_RETRIEVE,
+    "u",
+    USERS_TABLE,
+    "u.pin FROM users u",
+    gupi_fields,
+    2,
+    1,
+    "u.login = '%s'",
+    1,
+    "u.login",
+    NULL,
+  },
+
+  {
     /* Q_DUSR - DELETE_USER */
     "delete_user",
     "dusr",


home help back first fref pref prev next nref lref last post