commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-627-g6e2a375


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-627-g6e2a375
Date: Sun, 29 Jul 2012 11:53:21 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=6e2a37582ae89b43438952059412ea4a994d546c

The branch, master has been updated
       via  6e2a37582ae89b43438952059412ea4a994d546c (commit)
      from  27ac3a545e89bd4aa357d6a624363b4e9a80b859 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6e2a37582ae89b43438952059412ea4a994d546c
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Jul 29 14:06:18 2012 +0300

    Port 0b1e16bea to imap4d
    
    * imap4d/imap4d.c (tls_required): Remove.
    (tls_mode): New variable.
    (imap4d_srv_config) <tls>: Remove.
    (imap4d_srv_config) <tls_mode>: New member.
    (imap4d_srv_param): Change the definition of the "tls" statement.
    Mark "tls-required" as deprecated.
    (imap4d_mainloop): Change type of the tls argument.
    Initialize session and pass it to each handler.
    * imap4d/imap4d.h (imap4d_session): New struct.
    (imap4d_command) <func>: Change signature. All uses changed.
    (tls_mode): New enum.
    (tls_required): Remove.
    (tls_available): New global.
    * imap4d/io.c (io_setio): Don't call tls_encryption_on, leave it to
    the caller.
    * imap4d/login.c (imap4d_login): Use session.
    * imap4d/starttls.c (tls_available): Global. Present even if !WITH_TLS
    (tls_encryption_on): Change signature. All callers updated.

-----------------------------------------------------------------------

Summary of changes:
 imap4d/append.c       |    3 +-
 imap4d/authenticate.c |    3 +-
 imap4d/capability.c   |    3 +-
 imap4d/check.c        |    3 +-
 imap4d/close.c        |    6 ++-
 imap4d/copy.c         |    3 +-
 imap4d/create.c       |    3 +-
 imap4d/delete.c       |    3 +-
 imap4d/examine.c      |    3 +-
 imap4d/expunge.c      |    3 +-
 imap4d/fetch.c        |    3 +-
 imap4d/id.c           |    3 +-
 imap4d/idle.c         |    3 +-
 imap4d/imap4d.c       |  106 ++++++++++++++++++++++++++++++++++++-------
 imap4d/imap4d.h       |  118 ++++++++++++++++++++++++++++++++++--------------
 imap4d/io.c           |    1 -
 imap4d/list.c         |    3 +-
 imap4d/login.c        |    5 +-
 imap4d/logout.c       |    3 +-
 imap4d/lsub.c         |    3 +-
 imap4d/namespace.c    |    3 +-
 imap4d/noop.c         |    3 +-
 imap4d/rename.c       |    3 +-
 imap4d/search.c       |    3 +-
 imap4d/select.c       |    3 +-
 imap4d/starttls.c     |   12 +++--
 imap4d/status.c       |    3 +-
 imap4d/store.c        |    3 +-
 imap4d/subscribe.c    |    3 +-
 imap4d/uid.c          |    3 +-
 imap4d/unsubscribe.c  |    3 +-
 imap4d/util.c         |    4 +-
 32 files changed, 237 insertions(+), 90 deletions(-)

diff --git a/imap4d/append.c b/imap4d/append.c
index 365c246..897c673 100644
--- a/imap4d/append.c
+++ b/imap4d/append.c
@@ -195,7 +195,8 @@ imap4d_append0 (mu_mailbox_t mbox, int flags, char 
*date_time, char *text,
 
 /* APPEND mbox [(flags)] [date_time] message_literal */
 int
-imap4d_append (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_append (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int i;
   char *mboxname;
diff --git a/imap4d/authenticate.c b/imap4d/authenticate.c
index 3cec356..1dbe120 100644
--- a/imap4d/authenticate.c
+++ b/imap4d/authenticate.c
@@ -90,7 +90,8 @@ imap4d_auth_capability ()
 */
 
 int
-imap4d_authenticate (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_authenticate (struct imap4d_session *session,
+                    struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *auth_type;
   struct imap4d_auth adata;
diff --git a/imap4d/capability.c b/imap4d/capability.c
index cb47c67..0e62350 100644
--- a/imap4d/capability.c
+++ b/imap4d/capability.c
@@ -68,7 +68,8 @@ print_capa (void *item, void *data)
 }
 
 int
-imap4d_capability (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_capability (struct imap4d_session *session,
+                  struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/check.c b/imap4d/check.c
index 6acb7b5..548378f 100644
--- a/imap4d/check.c
+++ b/imap4d/check.c
@@ -29,7 +29,8 @@
 */
 
 int
-imap4d_check (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_check (struct imap4d_session *session,
+              struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/close.c b/imap4d/close.c
index 47e2822..7fb42d1 100644
--- a/imap4d/close.c
+++ b/imap4d/close.c
@@ -77,7 +77,8 @@ imap4d_close0 (struct imap4d_command *command, 
imap4d_tokbuf_t tok,
       EXPUNGE responses are sent. */
 
 int
-imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_close (struct imap4d_session *session,
+              struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   return imap4d_close0 (command, tok, 1);
 }
@@ -101,7 +102,8 @@ imap4d_close (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
       selected mailbox.
 */
 int
-imap4d_unselect (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_unselect (struct imap4d_session *session,
+                 struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   return imap4d_close0 (command, tok, 0);
 }
diff --git a/imap4d/copy.c b/imap4d/copy.c
index 12ad324..10c0607 100644
--- a/imap4d/copy.c
+++ b/imap4d/copy.c
@@ -34,7 +34,8 @@
  */
 
 int
-imap4d_copy (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_copy (struct imap4d_session *session,
+             struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *text;
diff --git a/imap4d/create.c b/imap4d/create.c
index 08e753f..09e11c5 100644
--- a/imap4d/create.c
+++ b/imap4d/create.c
@@ -33,7 +33,8 @@
    deleted, its unique identifiers MUST be greater than any unique identifiers
    used in the previous incarnation of the mailbox.  */
 int
-imap4d_create (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_create (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *name;
   int isdir = 0;
diff --git a/imap4d/delete.c b/imap4d/delete.c
index 33107e3..ae62008 100644
--- a/imap4d/delete.c
+++ b/imap4d/delete.c
@@ -28,7 +28,8 @@
                BAD - command unknown or arguments invalid
 */  
 int
-imap4d_delete (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_delete (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc = RESP_OK;
   const char *msg = "Completed";
diff --git a/imap4d/examine.c b/imap4d/examine.c
index e4bacc2..a0d689a 100644
--- a/imap4d/examine.c
+++ b/imap4d/examine.c
@@ -31,7 +31,8 @@
                BAD - command unknown or arguments invalid
 */
 int
-imap4d_examine (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_examine (struct imap4d_session *session,
+                struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 3)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/expunge.c b/imap4d/expunge.c
index 6b73c0b..28ff581 100644
--- a/imap4d/expunge.c
+++ b/imap4d/expunge.c
@@ -31,7 +31,8 @@
 */
 
 int
-imap4d_expunge (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_expunge (struct imap4d_session *session,
+                struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 0ab9876..0fe988d 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -1856,7 +1856,8 @@ imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char 
**err_text)
    mailbox.  The data items to be fetched can be either a single atom
    or a parenthesized list.  */
 int
-imap4d_fetch (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_fetch (struct imap4d_session *session,
+              struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *err_text = "Completed";
diff --git a/imap4d/id.c b/imap4d/id.c
index 1d87f1e..d16f8ba 100644
--- a/imap4d/id.c
+++ b/imap4d/id.c
@@ -163,7 +163,8 @@ get_id_value (const char *name)
 }
 
 int
-imap4d_id (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_id (struct imap4d_session *session,
+           struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc = eat_args (tok);
   if (rc != RESP_OK)
diff --git a/imap4d/idle.c b/imap4d/idle.c
index 9787e97..5561980 100644
--- a/imap4d/idle.c
+++ b/imap4d/idle.c
@@ -17,7 +17,8 @@
 #include "imap4d.h"
 
 int
-imap4d_idle (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_idle (struct imap4d_session *session,
+             struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   time_t start;
   char *token_str = NULL;
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index d05c862..b90ff43 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -17,6 +17,7 @@
 #include "imap4d.h"
 #include <mailutils/gsasl.h>
 #include "mailutils/libargp.h"
+#include "mailutils/kwd.h"
 #include "tcpwrap.h"
 
 mu_m_server_t server;
@@ -30,8 +31,8 @@ char *modify_homedir;           /* Expression to produce 
imap4d_homedir */
 int state = STATE_NONAUTH;      /* Current IMAP4 state */
 struct mu_auth_data *auth_data; 
 
+enum tls_mode tls_mode;
 int login_disabled;             /* Disable LOGIN command */
-int tls_required;               /* Require STARTTLS */
 int create_home_dir;            /* Create home directory if it does not
                                   exist */
 int home_dir_mode = S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
@@ -94,8 +95,6 @@ static const char *imap4d_capa[] = {
   NULL
 };
 
-static int imap4d_mainloop (int, int, int);
-
 static error_t
 imap4d_parse_opt (int key, char *arg, struct argp_state *state)
 {
@@ -251,14 +250,61 @@ cb_mailbox_mode (void *data, mu_config_value_t *val)
 struct imap4d_srv_config
 {
   struct mu_srv_config m_cfg;
-  int tls;
+  enum tls_mode tls_mode;
 };
 
+#ifdef WITH_TLS
+static int
+cb_tls (void *data, mu_config_value_t *val)
+{
+  int *res = data;
+  static struct mu_kwd tls_kwd[] = {
+    { "no", tls_no },
+    { "false", tls_no },
+    { "off", tls_no },
+    { "0", tls_no },
+    { "ondemand", tls_ondemand },
+    { "stls", tls_ondemand },
+    { "required", tls_required },
+    { "connection", tls_connection },
+    /* For compatibility with prior versions: */
+    { "yes", tls_connection }, 
+    { "true", tls_connection },
+    { "on", tls_connection },
+    { "1", tls_connection },
+    { NULL }
+  };
+  
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
+    return 1;
+
+  if (mu_kwd_xlat_name (tls_kwd, val->v.string, res))
+    mu_error (_("not a valid tls keyword: %s"), val->v.string);
+  return 0;
+}
+#endif
+
+static int
+cb_tls_required (void *data, mu_config_value_t *val)
+{
+  int *res = data;
+  int bv;
+  
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
+    return 1;
+  if (mu_cfg_parse_boolean (val->v.string, &bv))
+    mu_error (_("Not a boolean value"));
+  else
+    *res = tls_required;
+  return 0;
+}
+
 static struct mu_cfg_param imap4d_srv_param[] = {
-  { "tls", mu_cfg_bool, NULL, mu_offsetof (struct imap4d_srv_config, tls),
-    NULL,
-    N_("Use TLS encryption for this server")
-  },
+#ifdef WITH_TLS
+  { "tls", mu_cfg_callback,
+    NULL, mu_offsetof (struct imap4d_srv_config, tls_mode), cb_tls,
+    N_("Kind of TLS encryption to use for this server") },
+#endif
   { NULL }
 };
 
@@ -287,8 +333,13 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
   { "home-dir-mode", mu_cfg_callback, NULL, 0, cb_mode,
     N_("File mode for creating user home directories (octal)."),
     N_("mode") },
-  { "tls-required", mu_cfg_bool, &tls_required, 0, NULL,
-    N_("Always require STARTTLS before entering authentication phase.") },
+#ifdef WITH_TLS
+  { "tls", mu_cfg_callback, &tls_mode, 0, cb_tls,
+    N_("Kind of TLS encryption to use") },
+  { "tls-required", mu_cfg_callback, &tls_mode, 0, cb_tls_required,
+    N_("Always require STLS before entering authentication phase.\n"
+       "Deprecated, use \"tls required\" instead.") },
+#endif
   { "preauth", mu_cfg_callback, NULL, 0, cb_preauth,
     N_("Configure PREAUTH mode.  MODE is one of:\n"
        "  prog:///<full-program-name: string>\n"
@@ -480,11 +531,12 @@ imap4d_child_signal_setup (RETSIGTYPE (*handler) (int 
signo))
 }
 
 static int
-imap4d_mainloop (int ifd, int ofd, int tls)
+imap4d_mainloop (int ifd, int ofd, enum tls_mode tls)
 {
   imap4d_tokbuf_t tokp;
   char *text;
   int signo;
+  struct imap4d_session session;
 
   if (!test_mode)
     test_mode = isatty (ifd);
@@ -521,7 +573,29 @@ imap4d_mainloop (int ifd, int ofd, int tls)
       imap4d_child_signal_setup (imap4d_child_signal);
     }
   
-  io_setio (ifd, ofd, tls);
+  if (tls == tls_unspecified)
+    tls = tls_available ? tls_ondemand : tls_no;
+  else if (tls != tls_no && !tls_available)
+    {
+      mu_error (_("TLS is not configured, but requested in the "
+                 "configuration"));
+      tls = tls_no;
+    }
+
+  switch (tls)
+    {
+    case tls_required:
+      imap4d_capability_add (IMAP_CAPA_XTLSREQUIRED);
+    case tls_no:
+      imap4d_capability_remove (IMAP_CAPA_STARTTLS);
+      tls_available = 0;
+    }
+  
+  session.tls_mode = tls;
+  
+  io_setio (ifd, ofd, tls == tls_connection);
+  if (tls == tls_connection)
+    tls_encryption_on (&session);
 
   if (imap4d_preauth_setup (ifd) == 0)
     {
@@ -555,7 +629,7 @@ imap4d_mainloop (int ifd, int ofd, int tls)
       imap4d_readline (tokp);
       /* check for updates */
       imap4d_sync ();
-      util_do_command (tokp);
+      util_do_command (&session, tokp);
       imap4d_sync ();
       io_flush ();
     }
@@ -578,7 +652,7 @@ imap4d_connection (int fd, struct sockaddr *sa, int salen,
   else
     rc = 1;
   
-  imap4d_mainloop (fd, fd, cfg->tls);
+  imap4d_mainloop (fd, fd, cfg->tls_mode);
 
   if (rc == 0)
     clr_strerr_flt ();
@@ -687,10 +761,6 @@ main (int argc, char **argv)
 
   if (login_disabled)
     imap4d_capability_add (IMAP_CAPA_LOGINDISABLED);
-#ifdef WITH_TLS
-  if (tls_required)
-    imap4d_capability_add (IMAP_CAPA_XTLSREQUIRED);
-#endif
 
   namespace_init ();
 
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index bca33df..7345551 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -115,10 +115,13 @@ extern "C" {
 
 typedef struct imap4d_tokbuf *imap4d_tokbuf_t;
 
+struct imap4d_session;
+  
 struct imap4d_command
 {
   const char *name;
-  int (*func) (struct imap4d_command *, imap4d_tokbuf_t);
+  int (*func) (struct imap4d_session *, struct imap4d_command *,
+              imap4d_tokbuf_t);
   int states;
   int failure;
   int success;
@@ -175,6 +178,20 @@ enum imap4d_preauth
     preauth_prog
   };
 
+  /* TLS modes */
+enum tls_mode
+  {
+    tls_unspecified,
+    tls_no,
+    tls_ondemand,
+    tls_required,
+    tls_connection
+  };
+
+struct imap4d_session
+{
+  enum tls_mode tls_mode;
+};
   
 extern struct imap4d_command imap4d_command_table[];
 extern mu_mailbox_t mbox;
@@ -190,7 +207,6 @@ extern const char *program_version;
 extern int mailbox_mode[NS_MAX];
   
 extern int login_disabled;
-extern int tls_required;
 extern enum imap4d_preauth preauth_mode;
 extern char *preauth_program;
 extern int preauth_only;
@@ -207,6 +223,8 @@ extern jmp_buf child_jmp;
 extern int test_mode;
 extern int silent_expunge;
 
+int tls_available;
+
 /* Input functions */
 extern mu_stream_t iostream;
 extern int  io_untagged_response (int, const char *, ...) MU_PRINTFLIKE(2,3);
@@ -271,51 +289,81 @@ int imap4d_with_parsebuf (imap4d_tokbuf_t tok, int arg,
 #define imap4d_parsebuf_data(p) ((p)->data)
 
   /* Imap4 commands */
-extern int  imap4d_append (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_authenticate (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_append (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_authenticate (struct imap4d_session *,
+                                struct imap4d_command *, imap4d_tokbuf_t);
 extern void imap4d_auth_capability (void);
-extern int  imap4d_capability (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_check (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_close (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_unselect (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_copy (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_capability (struct imap4d_session *,
+                              struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_check (struct imap4d_session *,
+                         struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_close (struct imap4d_session *,
+                         struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_unselect (struct imap4d_session *,
+                            struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_copy (struct imap4d_session *,
+                        struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_copy0 (imap4d_tokbuf_t, int isuid, char **err_text);
-extern int  imap4d_create (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_delete (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_examine (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_expunge (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_fetch (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_create (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_delete (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_examine (struct imap4d_session *,
+                           struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_expunge (struct imap4d_session *,
+                           struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_fetch (struct imap4d_session *,
+                         struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char **err_text);
-extern int  imap4d_list (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_login (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_logout (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_noop (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_rename (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_list (struct imap4d_session *,
+                        struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_login (struct imap4d_session *,
+                         struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_logout (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_noop (struct imap4d_session *,
+                        struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_rename (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_preauth_setup (int fd);
-extern int  imap4d_search (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_search (struct imap4d_session *,
+                            struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_search0 (imap4d_tokbuf_t, int isuid, char **repyptr);
-extern int  imap4d_select (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_select (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_select0 (struct imap4d_command *, const char *, int);
 extern int  imap4d_select_status (void);
 #ifdef WITH_TLS
-extern int  imap4d_starttls (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_starttls (struct imap4d_session *,
+                            struct imap4d_command *, imap4d_tokbuf_t);
 extern void starttls_init (void);
-void tls_encryption_on (void);
+void tls_encryption_on (struct imap4d_session *);
 #endif /* WITH_TLS */
-extern int  imap4d_status (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_store (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_status (struct imap4d_session *,
+                          struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_store (struct imap4d_session *,
+                         struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_store0 (imap4d_tokbuf_t, int, char **);
 
 mu_property_t open_subscription (void);
-extern int  imap4d_subscribe (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_unsubscribe (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_lsub (struct imap4d_command *, imap4d_tokbuf_t);
-
-extern int  imap4d_uid (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_namespace (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_version (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_idle (struct imap4d_command *, imap4d_tokbuf_t);
-extern int  imap4d_id (struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_subscribe (struct imap4d_session *,
+                             struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_unsubscribe (struct imap4d_session *,
+                               struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_lsub (struct imap4d_session *,
+                        struct imap4d_command *, imap4d_tokbuf_t);
+
+extern int  imap4d_uid (struct imap4d_session *,
+                       struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_namespace (struct imap4d_session *,
+                             struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_version (struct imap4d_session *,
+                           struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_idle (struct imap4d_session *,
+                        struct imap4d_command *, imap4d_tokbuf_t);
+extern int  imap4d_id (struct imap4d_session *,
+                      struct imap4d_command *, imap4d_tokbuf_t);
   
 extern int imap4d_check_home_dir (const char *dir, uid_t uid, gid_t gid);
 
@@ -364,7 +412,7 @@ extern void imap4d_capability_init (void);
 
 extern int  util_start (char *);
 extern int  util_getstate (void);
-extern int  util_do_command (imap4d_tokbuf_t);
+extern int  util_do_command (struct imap4d_session *, imap4d_tokbuf_t);
 extern char *util_getfullpath (const char *);
 extern struct imap4d_command *util_getcommand (char *, 
                                                struct imap4d_command []);
diff --git a/imap4d/io.c b/imap4d/io.c
index 7adcbf1..9257400 100644
--- a/imap4d/io.c
+++ b/imap4d/io.c
@@ -48,7 +48,6 @@ io_setio (int ifd, int ofd, int tls)
          mu_error (_("failed to create TLS stream: %s"), mu_strerror (rc));
          imap4d_bye (ERR_STREAM_CREATE);
        }
-      tls_encryption_on ();
     }
   else
 #endif
diff --git a/imap4d/list.c b/imap4d/list.c
index 160bf62..957fbeb 100644
--- a/imap4d/list.c
+++ b/imap4d/list.c
@@ -131,7 +131,8 @@ list_fun (mu_folder_t folder, struct mu_list_response 
*resp, void *data)
   but it does not match the hierarchy delimiter.  */
 
 int
-imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_list (struct imap4d_session *session,
+             struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *ref;
   char *wcard;
diff --git a/imap4d/login.c b/imap4d/login.c
index 15c75f5..5221e42 100644
--- a/imap4d/login.c
+++ b/imap4d/login.c
@@ -30,12 +30,13 @@
                BAD - command unknown or arguments invalid
 */  
 int
-imap4d_login (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_login (struct imap4d_session *session,
+              struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *username, *pass;
   int rc;
 
-  if (login_disabled || tls_required)    
+  if (login_disabled || session->tls_mode == tls_required)    
     return io_completion_response (command, RESP_NO, "Command disabled");
 
   if (imap4d_tokbuf_argc (tok) != 4)
diff --git a/imap4d/logout.c b/imap4d/logout.c
index 51c441e..5f6495a 100644
--- a/imap4d/logout.c
+++ b/imap4d/logout.c
@@ -29,7 +29,8 @@
 */
 
 int
-imap4d_logout (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_logout (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/lsub.c b/imap4d/lsub.c
index a84be7c..160f7cd 100644
--- a/imap4d/lsub.c
+++ b/imap4d/lsub.c
@@ -30,7 +30,8 @@
                BAD - command unknown or arguments invalid
 */
 int
-imap4d_lsub (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_lsub (struct imap4d_session *session,
+             struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *ref;
diff --git a/imap4d/namespace.c b/imap4d/namespace.c
index 7a9164f..ba0a5c1 100644
--- a/imap4d/namespace.c
+++ b/imap4d/namespace.c
@@ -112,7 +112,8 @@ namespace_enumerate_all (nsfp_t f, void *closure)
 */
 
 int
-imap4d_namespace (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_namespace (struct imap4d_session *session,
+                  struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/noop.c b/imap4d/noop.c
index b7314fe..82823e0 100644
--- a/imap4d/noop.c
+++ b/imap4d/noop.c
@@ -18,7 +18,8 @@
 #include "imap4d.h"
 
 int
-imap4d_noop (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_noop (struct imap4d_session *session,
+             struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 2)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/rename.c b/imap4d/rename.c
index 3bc2040..b12eef0 100644
--- a/imap4d/rename.c
+++ b/imap4d/rename.c
@@ -101,7 +101,8 @@ make_interdir (const char *name, int delim, int perms)
   of the mailbox.  */
 
 int
-imap4d_rename (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_rename (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *oldname;
   char *newname;
diff --git a/imap4d/search.c b/imap4d/search.c
index 14559d1..ba20e2f 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -258,7 +258,8 @@ static void do_search (struct parsebuf *pb);
 */
 
 int
-imap4d_search (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_search (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *err_text= "";
diff --git a/imap4d/select.c b/imap4d/select.c
index 75f3c7f..92acbf0 100644
--- a/imap4d/select.c
+++ b/imap4d/select.c
@@ -22,7 +22,8 @@ static int select_flags;
 /* select          ::= "SELECT" SPACE mailbox  */
 
 int
-imap4d_select (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_select (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   if (imap4d_tokbuf_argc (tok) != 3)
     return io_completion_response (command, RESP_BAD, "Invalid arguments");
diff --git a/imap4d/starttls.c b/imap4d/starttls.c
index 3b0be65..799bf44 100644
--- a/imap4d/starttls.c
+++ b/imap4d/starttls.c
@@ -16,9 +16,10 @@
 
 #include "imap4d.h"
 
+int tls_available;
+
 #ifdef WITH_TLS
 
-static int tls_available;
 static int tls_done;
 
 /*
@@ -32,7 +33,8 @@ static int tls_done;
                BAD - command unknown or arguments invalid
 */
 int
-imap4d_starttls (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_starttls (struct imap4d_session *session,
+                 struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int status;
 
@@ -48,7 +50,7 @@ imap4d_starttls (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
   io_flush ();
 
   if (imap4d_init_tls_server () == 0)
-    tls_encryption_on ();
+    tls_encryption_on (session);
   else
     {
       mu_diag_output (MU_DIAG_ERROR, _("session terminated"));
@@ -60,7 +62,7 @@ imap4d_starttls (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
 }
 
 void
-tls_encryption_on ()
+tls_encryption_on (struct imap4d_session *session)
 {
   tls_done = 1;
   imap4d_capability_remove (IMAP_CAPA_STARTTLS);
@@ -68,7 +70,7 @@ tls_encryption_on ()
   login_disabled = 0;
   imap4d_capability_remove (IMAP_CAPA_LOGINDISABLED);
 
-  tls_required = 0;
+  session->tls_mode = tls_no;
   imap4d_capability_remove (IMAP_CAPA_XTLSREQUIRED);
 }
 
diff --git a/imap4d/status.c b/imap4d/status.c
index 265a073..38758b7 100644
--- a/imap4d/status.c
+++ b/imap4d/status.c
@@ -65,7 +65,8 @@ status_get_handler (const char *name)
                BAD - command unknown or arguments invalid
 */
 int
-imap4d_status (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_status (struct imap4d_session *session,
+               struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *name;
   char *mailbox_name;
diff --git a/imap4d/store.c b/imap4d/store.c
index 52831d6..43258fa 100644
--- a/imap4d/store.c
+++ b/imap4d/store.c
@@ -164,7 +164,8 @@ imap4d_store0 (imap4d_tokbuf_t tok, int isuid, char **ptext)
 }
 
 int
-imap4d_store (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_store (struct imap4d_session *session,
+              struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *err_text = NULL;
diff --git a/imap4d/subscribe.c b/imap4d/subscribe.c
index 4c324ca..a139761 100644
--- a/imap4d/subscribe.c
+++ b/imap4d/subscribe.c
@@ -54,7 +54,8 @@ open_subscription ()
                BAD - command unknown or arguments invalid
 */
 int
-imap4d_subscribe (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_subscribe (struct imap4d_session *session,
+                  struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *name;
diff --git a/imap4d/uid.c b/imap4d/uid.c
index 75b596d..80486f0 100644
--- a/imap4d/uid.c
+++ b/imap4d/uid.c
@@ -22,7 +22,8 @@
  */
 
 int
-imap4d_uid (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_uid (struct imap4d_session *session,
+            struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   char *cmd;
   int rc = RESP_NO;
diff --git a/imap4d/unsubscribe.c b/imap4d/unsubscribe.c
index 0379347..2983d93 100644
--- a/imap4d/unsubscribe.c
+++ b/imap4d/unsubscribe.c
@@ -34,7 +34,8 @@
       only if the unsubscription is successful.
 */
 int
-imap4d_unsubscribe (struct imap4d_command *command, imap4d_tokbuf_t tok)
+imap4d_unsubscribe (struct imap4d_session *session,
+                    struct imap4d_command *command, imap4d_tokbuf_t tok)
 {
   int rc;
   char *name;
diff --git a/imap4d/util.c b/imap4d/util.c
index badb7db..8c9937b 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -37,7 +37,7 @@ util_getfullpath (const char *name)
 }
 
 int
-util_do_command (imap4d_tokbuf_t tok)
+util_do_command (struct imap4d_session *session, imap4d_tokbuf_t tok)
 {
   char *tag, *cmd;
   struct imap4d_command *command;
@@ -73,7 +73,7 @@ util_do_command (imap4d_tokbuf_t tok)
   if (command->states && (command->states & state) == 0)
     return io_completion_response (command, RESP_BAD, "Wrong state");
 
-  return command->func (command, tok);
+  return command->func (session, command, tok);
 }
 
 struct imap4d_command *


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]