commit-mailutils
[Top][All Lists]
Advanced

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

[SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-263-gb1594c2
Date: Tue, 14 Apr 2009 06:37:42 +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=b1594c2aaaaf49641fa93d568a41613c6d8de9aa

The branch, master has been updated
       via  b1594c2aaaaf49641fa93d568a41613c6d8de9aa (commit)
      from  5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e (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 b1594c2aaaaf49641fa93d568a41613c6d8de9aa
Author: Sergey Poznyakoff <address@hidden>
Date:   Tue Apr 14 09:36:41 2009 +0300

    Allow to set user's personal namespace in imap4d.
    
    * imap4d/imap4d.c (homedir): Remove variable.
    (real_homedir, imap4d_homedir, modify_homedir): New variables.
    (imap4d_cfg_param): New statements: homedir, personal-namespace.
    (imap4d_session_setup0): Initialize real_homedir and imap4d_homedir.
    * imap4d/imap4d.h (homedir, rootdir): Remove declarations.
    (real_homedir, imap4d_homedir, modify_homedir): New declarations.
    Include mailutils/vartab.h.
    * imap4d/list.c, imap4d/lsub.c, imap4d/namespace.c,
    imap4d/subscribe.c, imap4d/unsubscribe.c,
    imap4d/util.c: Use imap4d_homedir and real_homedir, where appropriate.
    * NEWS: Update.
    
    * imap4d/preauth.c: Remove inclusion of mailutils/vartab.h

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

Summary of changes:
 NEWS                 |    7 ++++-
 imap4d/imap4d.c      |   68 +++++++++++++++++++++++++++++++++++++++----------
 imap4d/imap4d.h      |    6 +++-
 imap4d/list.c        |    6 ++--
 imap4d/lsub.c        |    4 +-
 imap4d/namespace.c   |   14 ++++++----
 imap4d/preauth.c     |    3 +-
 imap4d/subscribe.c   |    4 +-
 imap4d/unsubscribe.c |    4 +-
 imap4d/util.c        |   12 ++++----
 10 files changed, 88 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index ae078c9..832d30f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2009-04-07
+GNU mailutils NEWS -- history of user-visible changes. 2009-04-14
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 
 2008, 2009 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -13,6 +13,11 @@ Version 2.0.90 (Git)
 All MU client utilities make use of the user ticket file,
 ~/.mu-tickets, if it is present.
 
+* Imap4d
+
+New configuration file entities allow to modify user's personal
+namespace and visible home directory.
+
 * API
 
 * New mailbox formats
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 04b8a88..dc5cc90 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2004, 
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -28,10 +28,12 @@ mu_m_server_t server;
 unsigned int idle_timeout;
 int imap4d_transcript;
 
-mu_mailbox_t mbox;
-char *homedir;
-int state = STATE_NONAUTH;
-struct mu_auth_data *auth_data;
+mu_mailbox_t mbox;              /* Current mailbox */
+char *real_homedir;             /* Homedir as returned by user database */
+char *imap4d_homedir;           /* Homedir as visible for the remote party */
+char *modify_homedir;           /* Expression to produce imap4d_homedir */
+int state = STATE_NONAUTH;      /* Current IMAP4 state */
+struct mu_auth_data *auth_data; 
 
 int login_disabled;             /* Disable LOGIN command */
 int tls_required;               /* Require STARTTLS */
@@ -297,6 +299,11 @@ cb_mailbox_mode (mu_debug_t debug, void *data, 
mu_config_value_t *val)
 }
 
 static struct mu_cfg_param imap4d_cfg_param[] = {
+  { "homedir", mu_cfg_string, &modify_homedir, 0, NULL,
+    N_("Modify home directory") },
+  { "personal-namespace", MU_CFG_LIST_OF(mu_cfg_string), 
&namespace[NS_PRIVATE],
+    0, NULL, 
+    N_("Set personal namespace.") },
   { "other-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_OTHER],
     0, NULL, 
     N_("Set other users' namespace.") },
@@ -342,15 +349,48 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
 int
 imap4d_session_setup0 ()
 {
-  homedir = mu_normalize_path (mu_strdup (auth_data->dir));
-  if (imap4d_check_home_dir (homedir, auth_data->uid, auth_data->gid))
+  real_homedir = mu_normalize_path (mu_strdup (auth_data->dir));
+  if (imap4d_check_home_dir (real_homedir, auth_data->uid, auth_data->gid))
     return 1;
+
+  if (modify_homedir)
+    {
+      int rc;
+      mu_vartab_t vtab;
+      char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir);
+
+      mu_vartab_create (&vtab);
+      mu_vartab_define (vtab, "user", auth_data->name, 0);
+      mu_vartab_define (vtab, "home", real_homedir, 0);
+      rc = mu_vartab_expand (vtab, expr, &imap4d_homedir);
+      mu_vartab_destroy (&vtab);
+      free (expr);
+      if (rc)
+       {
+         free (real_homedir);
+         mu_diag_output (MU_DIAG_ERR,
+                         _("Error expanding %s: %s"),
+                         modify_homedir, mu_strerror (rc));
+         return 1;
+       }
+    }
+  else
+    imap4d_homedir = strdup (real_homedir);
+
+  if (strcmp (imap4d_homedir, real_homedir)
+      && imap4d_check_home_dir (imap4d_homedir,
+                               auth_data->uid, auth_data->gid))
+    {
+      free (imap4d_homedir);
+      free (real_homedir);
+      return 1;
+    }
   
   if (auth_data->change_uid)
     setuid (auth_data->uid);
 
-  util_chdir (homedir);
-  namespace_init_session (homedir);
+  util_chdir (imap4d_homedir);
+  namespace_init_session (imap4d_homedir);
   mu_diag_output (MU_DIAG_INFO,
                  _("User `%s' logged in (source: %s)"), auth_data->name,
                  auth_data->source);
@@ -447,23 +487,23 @@ imap4d_check_home_dir (const char *dir, uid_t uid, gid_t 
gid)
 {
   struct stat st;
 
-  if (stat (homedir, &st))
+  if (stat (dir, &st))
     {
       if (errno == ENOENT && create_home_dir)
        {
          mode_t mode = umask (0);
-         int rc = mkdir (homedir, home_dir_mode);
+         int rc = mkdir (dir, home_dir_mode);
          umask (mode);
          if (rc)
            {
              mu_error ("Cannot create home directory `%s': %s",
-                       homedir, mu_strerror (errno));
+                       dir, mu_strerror (errno));
              return 1;
            }
-         if (chown (homedir, uid, gid))
+         if (chown (dir, uid, gid))
            {
              mu_error ("Cannot set owner for home directory `%s': %s",
-                       homedir, mu_strerror (errno));
+                       dir, mu_strerror (errno));
              return 1;
            }
        }
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index c2705e3..3de5fee 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -102,6 +102,7 @@
 #include <mailutils/server.h>
 #include <mailutils/argcv.h>
 #include <mailutils/alloc.h>
+#include <mailutils/vartab.h>
 
 #include <mu_asprintf.h>
 #include <mu_umaxtostr.h>
@@ -175,8 +176,9 @@ enum imap4d_preauth
   
 extern struct imap4d_command imap4d_command_table[];
 extern mu_mailbox_t mbox;
-extern char *homedir;
-extern char *rootdir;
+extern char *imap4d_homedir;
+extern char *real_homedir;  
+extern char *modify_homedir;
 extern int state;
 extern size_t children;
 extern int is_virtual;
diff --git a/imap4d/list.c b/imap4d/list.c
index 7d0c69e..e19091f 100644
--- a/imap4d/list.c
+++ b/imap4d/list.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2005, 2006,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ list_fun (mu_folder_t folder, struct mu_list_response *resp, 
void *data)
   name = resp->name;
   size = strlen (name);
   if (size == refinfo->homelen + 6
-      && memcmp (name, homedir, refinfo->homelen) == 0
+      && memcmp (name, imap4d_homedir, refinfo->homelen) == 0
       && memcmp (name + refinfo->homelen + 1, "INBOX", 5) == 0)
     return 0;
      
@@ -251,7 +251,7 @@ imap4d_list (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
       refinfo.refptr = ref;
       refinfo.reflen = strlen (ref);
       refinfo.pfxlen = strlen (cwd);
-      refinfo.homelen = strlen (homedir);
+      refinfo.homelen = strlen (imap4d_homedir);
 
       /* The special name INBOX is included in the output from LIST, if
         INBOX is supported by this server for this user and if the
diff --git a/imap4d/lsub.c b/imap4d/lsub.c
index de9d3f7..3ab3416 100644
--- a/imap4d/lsub.c
+++ b/imap4d/lsub.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ imap4d_lsub (struct imap4d_command *command, imap4d_tokbuf_t 
tok)
   if (!pattern)
     return util_finish (command, RESP_NO, "Not enough memory");
   
-  asprintf (&file, "%s/.mailboxlist", homedir);
+  asprintf (&file, "%s/.mailboxlist", real_homedir);
   if (!file)
     {
       free (pattern);
diff --git a/imap4d/namespace.c b/imap4d/namespace.c
index f5581dd..63636cf 100644
--- a/imap4d/namespace.c
+++ b/imap4d/namespace.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2005, 2007, 2008,
+   2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,9 +26,9 @@ mu_list_t namespace[NS_MAX];
 static char *
 printable_pathname (char *str)
 {
-  if (strncmp (str, homedir, strlen (homedir)) == 0)
+  if (strncmp (str, imap4d_homedir, strlen (imap4d_homedir)) == 0)
     {
-      str += strlen (homedir);
+      str += strlen (imap4d_homedir);
       if (str[0] == '/')
        str++;
     }
@@ -244,9 +245,10 @@ namespace_getfullpath (const char *name, const char 
*delim, int *nspace)
 int
 namespace_init_session (char *path)
 {
-  mu_list_create (&namespace[NS_PRIVATE]);
-  mu_list_append (namespace[NS_PRIVATE],
-                 mu_strdup (mu_normalize_path (path)));
+  if (!namespace[NS_PRIVATE])
+    mu_list_create (&namespace[NS_PRIVATE]);
+  mu_list_prepend (namespace[NS_PRIVATE],
+                  mu_strdup (mu_normalize_path (path)));
   return 0;
 }
 
diff --git a/imap4d/preauth.c b/imap4d/preauth.c
index 7ee250e..06eb231 100644
--- a/imap4d/preauth.c
+++ b/imap4d/preauth.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2004, 
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
 /* Preauth support for imap4d */
 
 #include "imap4d.h"
-#include <mailutils/vartab.h>
 #include "des.h"
 
 
diff --git a/imap4d/subscribe.c b/imap4d/subscribe.c
index 50874d0..7cc1b3d 100644
--- a/imap4d/subscribe.c
+++ b/imap4d/subscribe.c
@@ -1,5 +1,5 @@
 /* GNU mailutils - a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ imap4d_subscribe (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
 
   name = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1);
 
-  asprintf (&file, "%s/.mailboxlist", homedir);
+  asprintf (&file, "%s/.mailboxlist", real_homedir);
   fp = fopen (file, "a");
   free (file);
   if (fp)
diff --git a/imap4d/unsubscribe.c b/imap4d/unsubscribe.c
index 1bc9659..5b8a46a 100644
--- a/imap4d/unsubscribe.c
+++ b/imap4d/unsubscribe.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -100,7 +100,7 @@ imap4d_unsubscribe (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
 
   name = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1);
 
-  asprintf (&file, "%s/.mailboxlist", homedir);
+  asprintf (&file, "%s/.mailboxlist", real_homedir);
   sd.result = 0;
   sd.name = name;
 
diff --git a/imap4d/util.c b/imap4d/util.c
index f63fc90..f798d54 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -30,7 +30,7 @@ static const char *sc2string (int);
 char *
 util_tilde_expansion (const char *ref, const char *delim)
 {
-  return mu_tilde_expansion (ref, delim, homedir);
+  return mu_tilde_expansion (ref, delim, imap4d_homedir);
 }
 
 /* Get the absolute path.  */
@@ -42,8 +42,8 @@ util_getfullpath (char *name, const char *delim)
   if (*p != delim[0])
     {
       char *s =
-       calloc (strlen (homedir) + strlen (delim) + strlen (p) + 1, 1);
-      sprintf (s, "%s%s%s", homedir, delim, p);
+       calloc (strlen (imap4d_homedir) + strlen (delim) + strlen (p) + 1, 1);
+      sprintf (s, "%s%s%s", imap4d_homedir, delim, p);
       free (p);
       p = s;
     }
@@ -1085,12 +1085,12 @@ util_run_events (int old_state, int new_state)
 }
   
 void
-util_chdir (const char *homedir)
+util_chdir (const char *dir)
 {
-  int rc = chdir (homedir);
+  int rc = chdir (dir);
   if (rc)
     mu_error ("Cannot change to home directory `%s': %s",
-             homedir, mu_strerror (errno));
+             dir, mu_strerror (errno));
 }
 
 int


hooks/post-receive
--
GNU Mailutils




reply via email to

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