[1408] in Moira
evil moirad patch
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu Mar 9 02:48:43 2000
Message-Id: <200003090748.CAA1041901@w20-spare-o2.mit.edu>
To: moiradev@MIT.EDU
Date: Thu, 09 Mar 2000 02:48:39 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
I sat down this evening with the intent of fixing the bug mvan
reported earlier today with register_user. I discovered that
register_user is a tangled mess, and attempting to construct logic out
of it is like trying to build bookshelves out of mashed potatoes.
Here's a *very* rough patch Mike and I came up with that appears
to let you register a status 5/6 account with an IMAP pobox. As a
bonus, you get to keep the pobox you had, rather than getting a new one.
I don't intend to commit this in it's current form, and I'm kind of
embarassed to have produced it. Please bleed on it; I'd particularly
like someone to comment on the logic, as my brain currently has the
consistancy of a Tosci's frappe.
Garry
Index: qsupport.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository//moira/server/qsupport.pc,v
retrieving revision 2.19
diff -c -w -r2.19 qsupport.pc
*** qsupport.pc 2000/01/28 00:31:58 2.19
--- qsupport.pc 2000/03/09 07:42:14
***************
*** 1196,1201 ****
--- 1196,1202 ----
int who, rowcount, mid, uid, users_id;
int ostatus, nstatus, fsidval, popid;
int npid, tmp;
+ int po_exists = 0;
static int m_id, def_quota, def_imap_quota, list_id;
EXEC SQL END DECLARE SECTION;
char buffer[256], *aargv[3];
***************
*** 1250,1260 ****
if (rowcount > 0)
return MR_IN_USE;
EXEC SQL SELECT COUNT(label) INTO :rowcount FROM filesys
! WHERE label = :login OR label = :login || '.po';
if (dbms_errno)
return mr_errcode;
if (rowcount > 0)
return MR_IN_USE;
EXEC SQL SELECT COUNT(name) INTO :rowcount FROM alias
WHERE ( name = :login OR name = :login || '.po' )
AND type = 'FILESYS';
--- 1251,1278 ----
if (rowcount > 0)
return MR_IN_USE;
EXEC SQL SELECT COUNT(label) INTO :rowcount FROM filesys
! WHERE label = :login;
if (dbms_errno)
return mr_errcode;
if (rowcount > 0)
return MR_IN_USE;
+ EXEC SQL SELECT COUNT(label) INTO :rowcount
+ FROM filesys WHERE label = :login || '.po' AND type = 'IMAP';
+ if (dbms_errno)
+ return mr_errcode;
+ if (rowcount > 0)
+ {
+ EXEC SQL SELECT owner INTO :tmp FROM filesys
+ WHERE label = :login || '.po' AND type = 'IMAP';
+ if ((ostatus != 5 && ostatus != 6) || (tmp != users_id))
+ return MR_IN_USE;
+ EXEC SQL SELECT count(potype) INTO :rowcount FROM users WHERE
+ login = :login AND potype != 'NONE';
+ if (dbms_errno)
+ return mr_errcode;
+ if (rowcount > 0)
+ po_exists = 1;
+ }
EXEC SQL SELECT COUNT(name) INTO :rowcount FROM alias
WHERE ( name = :login OR name = :login || '.po' )
AND type = 'FILESYS';
***************
*** 1265,1270 ****
--- 1283,1290 ----
com_err(whoami, 0, "login name OK");
/* choose type and location for pobox */
+ if (!po_exists)
+ {
if (!strcmp(potype, "IMAP"))
{
/* Select all IMAP nfsphys entries in order of increasing
***************
*** 1382,1387 ****
--- 1402,1408 ----
WHERE users_id = :users_id;
com_err(whoami, 0, "pobox set to POP:%s", strtrim(machname));
}
+ }
/* change login name, set pobox */
sprintf(buffer, "u.users_id = %d", users_id);
***************
*** 1461,1468 ****
return mr_errcode;
return MR_SUCCESS;
}
-
-
/** set_pop_usage - incr/decr usage count for pop server in serverhosts talbe
**
--- 1482,1487 ----