Hi Mike,
At 17:14 23-06-2007, Mike Markley wrote:
Is there a Good Way to force ownership (both user and group) on a milter
socket? I see that smfi_opensocket() honors umask, but that doesn't help
with the GID, and dkim-filter doesn't seem to be picking up the primary
GID of its -u argument:

Try the attached patch. dkim-filter will pick the primary GID of its -u argument with it.

Regards,
-sm  
--- dkim-filter/dkim-filter.c.orig      Sat Jun 23 21:19:21 2007
+++ dkim-filter/dkim-filter.c   Sun Jun 24 01:41:49 2007
@@ -4997,6 +4998,34 @@
 
                (void) endpwent();
 
+               if (setgroups(1, &pw->pw_gid) != 0)
+               {
+                       if (dolog)
+                       {
+                               syslog(LOG_ERR, "setgroup(): %s",
+                                      strerror(errno));
+                       }
+
+                       fprintf(stderr, "%s: setgroup(): %s\n", progname,
+                               strerror(errno));
+
+                       return EX_NOPERM;
+               }
+
+               if (setgid(pw->pw_gid) != 0 || setegid(pw->pw_gid) != 0)
+               {
+                       if (dolog)
+                       {
+                               syslog(LOG_ERR, "setgid(): %s",
+                                      strerror(errno));
+                       }
+
+                       fprintf(stderr, "%s: setgid(): %s\n", progname,
+                               strerror(errno));
+
+                       return EX_NOPERM;
+               }
+
                if (setuid(pw->pw_uid) != 0)
                {
                        if (dolog)

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
dkim-milter-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dkim-milter-discuss

Reply via email to