Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 38452 - mismatch of permissions with vpopmail
Summary: mismatch of permissions with vpopmail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Qmail Team (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-16 14:33 UTC by SpanKY
Modified: 2007-07-12 17:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SpanKY gentoo-dev 2004-01-16 14:33:21 UTC
vpopmail-5.2.2-r1:
0600 vpopmail:vpopmail /etc/vpopmail.conf
0711 root:root /var/vpopmail/bin/vchkpw

vpopmail-5.4.0_rc1:
0640 root:vpopmail /etc/vpopmail.conf
0711 root:root /var/vpopmail/bin/vchkpw

the problem here is that when using qmail + vpopmail to auth over smtp, vchkpw isnt given permissions to read /etc/vpopmail.conf thus it'll always fail.  you dont exactly notice this when using courier-imap-ssl because courier runs as root so it has access to the vpopmail.conf file

solution here i think is this:
5.2.2-r1: chown vpopmail:vpopmail /var/vpopmail/bin/vchkpw
5.4.0_rc1: chown root:vpopmail /var/vpopmail/bin/vchkpw
and then set the binary +s right after chown -R root:root on the /var/vpopmail dirs

another note, in the ebuild, a call is made to 'fowner' ... it should actually be 'fowners'

here is the debugging i used:
nano /etc/passwd
<give qmaild a valid shell like /bin/bash>
su qmaild -
printf "user\0pass\0blah\0" | /var/vpopmail/bin/vchkpw `which id` 3<&0

if the permissions are wrong, you'll either get no output or you'll get:
vmysql: can't read settings from /var/vpopmail/etc/vpopmail.mysql

if the permissions are right, you'll get:
uid=89(vpopmail) gid=89(vpopmail) groups=200(nofiles)
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-16 17:28:21 UTC
better solution, as i'd strongly like to avoid setuid root.

chmod -R root:root /var/vpopmail/{etc,bin,lib,include}
chmod root:vpopmail /var/vpopmail/vchkpw /etc/vpopmail.conf
chmod g+s /var/vpopmail/vchkpw
chmod 0640 /etc/vpopmail.conf

however vchkpw should undergo some code review before this...
Comment 2 SpanKY gentoo-dev 2004-01-16 18:09:13 UTC
right, i tried the same thing (root:vpopmail 0640 on the .conf file and g+s on the binary) but couldnt get it to work for the life of me ... perhaps i was just doing something stupid heh
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-16 18:52:31 UTC
hmm, you're right. it doesn't seem to work.
i'm even more relucant to make vchkpw in as setuid or setgid root after looking at the code.
i'm wondering if the best route is a known secure wrapper instead or if there are any other possibilities.
Comment 4 SpanKY gentoo-dev 2004-01-16 19:13:04 UTC
well what about looking into modifying the code in vchkpw to run setuid as root buuuuuuuut drop root as soon as it's read the mysql conf file ?

perhaps as a hack, make a global file description and in the very beginning of main, run open() on the conf file, drop uid to vpopmail, and then let the rest of the code run as vpopmail
Comment 5 Davide Rebeccani 2004-07-19 11:02:34 UTC
If you want to fix this problem you havo to make qmail-smtd run ad vpopmail user. To make this you have to modify the /var/qmail/supervise/qmail-smtpd/run and sobstitue the ${QMAILUID} with 89.
With this "fix" you will be able ti authenticate your vpopmail users on smtp correctly.
Comment 6 Travis Morgan 2004-09-17 04:39:06 UTC
Ok, I ran into problems too, hopefully it's the same issue.

I installed sqwebmail as well and it requires vpopmail to read /etc/vpopmail.conf but no matter what I did I could not get it to read that file without it being world readable.

I created a test domain with a user and group that I had created. I then added that user to all of the groups for qmail and the vpopmail group in an attempt to give it access to that conf file. Nothing worked.

I ended up making some changes to the vpopmail package. I found the error where it says that permission was denied reading that file and added a bit of code that would write the uid and gid of the running vpopmail to a file in /tmp.

The result that I got was that it was running as the user and group that I created the domain under. While this does make sense, I did some more digging and found that vpopmail changes UID and GID _before_ reading the conf file. I would say this is a pretty big bug and maybe the vpopmail team needs to be notified about this oversite. 

I was able to have everything run smoothly if I either

a) made /etc/vpopmail.conf world readable (which I'm not willing to do)
b) created the domains without their own UID and GID (leave them as vpopmail)
Comment 7 Jory A. Pratt 2005-01-21 18:40:06 UTC
Travis what you didnt do was run your webserver as user/group vpopmail which is were your problem lies I know for a fact that you dont have to have nothin but 0640 on /etc/vpopmail.conf. As for the rest of you I would suggest you use everything like Johnson said
chmod -R root:root /var/vpopmail/{etc,bin,lib,include}
chmod root:vpopmail /var/vpopmail/vchkpw /etc/vpopmail.conf
chmod 0411 /var/vpopmail/vchkpw
chmod 0640 /etc/vpopmail.conf

instead of the chmod g+s as stated before. This is basic info that is in the gentoo qmail/vpopmail docs on site just so you all know. I will try to get some new info submitted to DOCS team on using relay-ctrl with qmail for those that are needing it.
Comment 8 Jory A. Pratt 2005-01-21 20:09:44 UTC
chown -R root:root /var/vpopmail/{etc,bin,lib,include}
chown root:vpopmail /var/vpopmail/vchkpw /etc/vpopmail.conf
chmod 0411 /var/vpopmail/vchkpw
chmod 0640 /etc/vpopmail.conf

might help if we all use the right command here LOL chmod isnt gonna get it for our user/group ownership.
Comment 9 Jory A. Pratt 2005-01-21 20:22:41 UTC
grrrrrr I just realized when putting up the ebuild for vpopmail 5.4.9 that the permissions I said to use were incorrect LOL the correct permissions for vchkpw should be 4711 sorry folks I am tired 
Comment 10 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-11-14 03:41:07 UTC
is this still a problem for anybody, or can the bug be closed?
Comment 11 Benedikt Böhm (RETIRED) gentoo-dev 2007-07-12 17:44:40 UTC
fixed for a long time ...