On Tue, Jan 12, 2010 at 08:02:31PM -0500, Sam Varshavchik wrote:
>> % id testmaildrop
>> uid=1006(testmaildrop) gid=1006(testmaildrop) groups=1006(testmaildrop)
>> uid=1006(testmaildrop) gid=0(root) groups=0(root)
>> That's the problem. After using -d, it changes the user but not the group.
>> Can you reproduce that?
>
> So, invoking maildrop gives it root privileges, and groupid mail. 
> maildrop checks the -d option, changes its userid as specified, leaves 
> the group id at its acquired "mail" uid, then it can create stuff in 
> /var/spool/mail appropriately.
>
> That's what it looks like is happening here, to me. The missing link in 
> your situation, apparently, is maildrop binary's setgroupid bit being 
> set.

We use this by default:

% ls -l =maildrop
-rwxr-sr-x 1 root mail 162676 2008-01-20 23:23 /usr/bin/maildrop

I think we're suffering from the fact that the +s bit sets the effective
gid, but that gets ignored later. I'm not sure, but it sounds like we may
need an explicit setgid or something, to make sure we really honor the
+s bit rather than root's real gid?

% cat gid.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
       
int main(void) {

  gid_t mygid;

  mygid = getgid();
  printf("getgid returned: %d\n", mygid);
  mygid = getegid();
  printf("getegid returned: %d\n", mygid);

  setgid(getegid());

  mygid = getgid();
  printf("getgid returned: %d\n", mygid);
  mygid = getegid();
  printf("getegid returned: %d\n", mygid);

}
% gcc -o gid gid.c
% sudo chgrp mail ./gid; sudo chmod g+s ./gid
% ./gid
getgid returned: 1000
getegid returned: 8
getgid returned: 1000
getegid returned: 8
% sudo ./gid
getgid returned: 0
getegid returned: 8
getgid returned: 8
getegid returned: 8

-- 
     2. That which causes joy or happiness.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to