[1430] in Moira

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

Re: user changed pobox

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Mon Mar 13 21:13:17 2000

Message-Id: <200003140213.VAA31755@alice-whacker.mit.edu>
To: Jonathon Weiss <jweiss@MIT.EDU>
Cc: "Ron Hoffmann" <hoffmann@MIT.EDU>, bug-moira@MIT.EDU
In-Reply-To: Your message of "Mon, 13 Mar 2000 18:18:16 EST."
             <200003132318.SAA11223@speaker-for-the-dead.mit.edu> 
Date: Mon, 13 Mar 2000 21:13:13 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>

	Ok, try this.  Following this I'll be submitting all the changes
we need to make to go to assigning IMAP boxes by default to new users.

Garry

Index: pobox.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository//moira/clients/lib/pobox.c,v
retrieving revision 1.3
diff -c -r1.3 pobox.c
*** pobox.c	2000/02/22 17:45:50	1.3
--- pobox.c	2000/03/13 23:41:26
***************
*** 19,25 ****
  
  RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository//moira/clients/lib/pobox.c,v 1.3 2000/02/22 17:45:50 rbasch Exp $");
  
! enum { POTYPE_ERROR, POTYPE_POP, POTYPE_LOCAL, POTYPE_MAILHUB, POTYPE_SMTP };
  static int potype(char *machine);
  static int save_sloc_machine(int argc, char **argv, void *sq);
  static int save_alias_value(int argc, char **argv, void *sq);
--- 19,25 ----
  
  RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository//moira/clients/lib/pobox.c,v 1.3 2000/02/22 17:45:50 rbasch Exp $");
  
! enum { POTYPE_ERROR, POTYPE_POP, POTYPE_LOCAL, POTYPE_MAILHUB, POTYPE_SMTP, POTYPE_IMAP };
  static int potype(char *machine);
  static int save_sloc_machine(int argc, char **argv, void *sq);
  static int save_alias_value(int argc, char **argv, void *sq);
***************
*** 69,74 ****
--- 69,82 ----
        
        switch (potype(machine))
  	{
+ 	case POTYPE_IMAP:
+ 	  com_err(whoami, 0, "Cannot forward mail to IMAP server %s", 
+ 		  machine);
+ 	  com_err(NULL, 0, "Use \"chpobox -p\" if you are trying to unset "
+ 		  "your mail forwarding.");
+ 	  status = MRCL_REJECT;
+ 	  goto cleanup;
+ 
  	case POTYPE_POP:
  	  if (strcmp(p, user))
  	    {
***************
*** 137,144 ****
    return status;
  }
  
! /* Given a canonicalized machine name, ask the Moira server if it is of type
!  * POP, LOCAL, or MAILHUB -- if none of those, we assume it's foreign.
   */
  static int potype(char *machine)
  {
--- 145,153 ----
    return status;
  }
  
! /* Given a canonicalized machine name, ask the Moira server if it is
!  * of type IMAP, POP, LOCAL, or MAILHUB -- if none of those, we assume
!  * it's foreign.  
   */
  static int potype(char *machine)
  {
***************
*** 146,152 ****
--- 155,190 ----
    int status, match = 0;
    static struct save_queue *pop = NULL, *local = NULL;
    static struct save_queue *mailhub = NULL, *mailhub_name = NULL;
+   static struct save_queue *imap = NULL;
+ 
+   /* 0. Check if the machine is an IMAP server. */
+   if (!imap)
+     {
+       char *service = "POSTOFFICE";
+       imap = sq_create();
+       status = mr_query("get_server_locations", 1, &service,
+ 			save_sloc_machine, imap);
+       if (status && (status != MR_NO_MATCH))
+ 	{
+ 	  com_err(whoami, status, "while reading list of IMAP servers");
+ 	  return POTYPE_ERROR;
+ 	}
+     }
+ 
+   /* Because of how sq_get_data works, we need to go through the entire
+    * queue even if we find a match, so that it gets reset for the next
+    * call.
+    */
+   while (sq_get_data(imap, &name))
+     {
+       if (!match && !strcasecmp(name, machine))
+ 	match = 1;
+     }
  
+   if (match)
+     return POTYPE_IMAP;
+ 
+ 
    /* 1. Check if the machine is a POP server. */
    if (!pop)
      {
***************
*** 161,170 ****
  	}
      }
  
-   /* Because of how sq_get_data works, we need to go through the entire
-    * queue even if we find a match, so that it gets reset for the next
-    * call.
-    */
    while (sq_get_data(pop, &name))
      {
        if (!match && !strcasecmp(name, machine))
--- 199,204 ----


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