]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added separate %{gid} expansion to mail_user.
authorTimo Sirainen <tss@iki.fi>
Sat, 10 Dec 2011 06:41:01 +0000 (08:41 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 10 Dec 2011 06:41:01 +0000 (08:41 +0200)
The default %{gid} probably works also, but it's more reliable to do this
explicitly.

src/lib-storage/mail-storage-service.c
src/lib-storage/mail-user.c
src/lib-storage/mail-user.h

index fc8932359a6fe390f8d0aaf1d58ef8e3ee04d272..bb894378385b000532564130c2964f74dfef2815 100644 (file)
@@ -484,7 +484,7 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx,
        mail_user = mail_user_alloc(user->input.username, user->user_info,
                                    user->user_set);
        mail_user_set_home(mail_user, *home == '\0' ? NULL : home);
-       mail_user_set_vars(mail_user, geteuid(), ctx->service->name,
+       mail_user_set_vars(mail_user, geteuid(), getegid(), ctx->service->name,
                           &user->input.local_ip, &user->input.remote_ip);
 
        mail_set = mail_user_set_get_storage_set(mail_user);
index 860cb1ef77ef0e155ee81694ab10392d16487976..b50806dee3662bf0917c390003c4904040f360c1 100644 (file)
@@ -159,11 +159,12 @@ struct mail_user *mail_user_find(struct mail_user *user, const char *name)
        return NULL;
 }
 
-void mail_user_set_vars(struct mail_user *user, uid_t uid, const char *service,
-                       const struct ip_addr *local_ip,
+void mail_user_set_vars(struct mail_user *user, uid_t uid, gid_t gid,
+                       const char *service, const struct ip_addr *local_ip,
                        const struct ip_addr *remote_ip)
 {
        user->uid = uid;
+       user->gid = gid;
        user->service = p_strdup(user->pool, service);
        if (local_ip != NULL && local_ip->family != 0) {
                user->local_ip = p_new(user->pool, struct ip_addr, 1);
@@ -188,6 +189,7 @@ mail_user_var_expand_table(struct mail_user *user)
                { 'r', NULL, "rip" },
                { 'p', NULL, "pid" },
                { 'i', NULL, "uid" },
+               { '\0', NULL, "gid" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
index a9307c0592924ed2141d433b68cf1156e5bd0a59..c626c8b71bb29ceda521a704b60f2d75c8425025 100644 (file)
@@ -20,6 +20,7 @@ struct mail_user {
        const char *_home;
 
        uid_t uid;
+       gid_t gid;
        const char *service;
        struct ip_addr *local_ip, *remote_ip;
        const struct var_expand_table *var_expand_table;
@@ -77,8 +78,8 @@ void mail_user_unref(struct mail_user **user);
 struct mail_user *mail_user_find(struct mail_user *user, const char *name);
 
 /* Specify mail location %variable expansion data. */
-void mail_user_set_vars(struct mail_user *user, uid_t uid, const char *service,
-                       const struct ip_addr *local_ip,
+void mail_user_set_vars(struct mail_user *user, uid_t uid, gid_t gid,
+                       const char *service, const struct ip_addr *local_ip,
                        const struct ip_addr *remote_ip);
 /* Return %variable expansion table for the user. */
 const struct var_expand_table *