[PATCH] fix a crash bug by chown socket without group [1 Attachment]
Kouhei Sutou <
kou@...>
2013-03-22 14:23:57 GMT
<*>[Attachment(s) from Kouhei Sutou included below]
Hi,
I attach a patch that fixes a crash.
The crash can reproduce with the following greylist.conf:
...
socket "inet:30025"
user "nobody"
...
Run milter-greylist as root user:
% sudo milter-greylist
milter-greylist will be crashed.
Points:
* "socket" is not file path. (e.g. inet:XXX, unix:XXX and so on)
* "user" has only user. Group should not be included like
* Run milter-greylist as root user.
Cause:
If we run milter-greylist as root user and "user"
parameter value is specified, "socket" parameter value
is chown-ed to "user" parameter value. If "socket"
parameter value is not path like "inet:30025", chown()
is always failed. And error message is logged by the
following code:
mg_log(LOG_WARNING, "%s: cannot change \"%s\""
" ownership to %s/%s: %s", argv[0],
conf.c_socket, pw->pw_name, gr->gr_name,
strerror(errno));
"gr->gr_name" is a problem. "gr" is NULL when "user"
parameter value doesn't have group such as "nobody".
Solutions:
(a) Don't chown() when "socket" parameter value has scheme
such as "inet", "inet6", "unix" and "local".
(b) Set "gr" even if "user" parameter value doesn't have
group. (The attached patch uses this solution.)
I think that we should apply both solutions but I attach
only (b) solution. Because (b) solves more effected
problem. "gr" is used other location too. (See
code around chown(conf.c_pidfile, ...).) (a) doesn't solve
the problem.
So I think that (b) should be fixed at first. I will send a
patch for (a) after this patch is applied.
Thanks,
--
kou
<*>Attachment(s) from Kouhei Sutou:
<*> 1 of 1 File(s)
http://groups.yahoo.com/group/milter-greylist/attachments/folder/1126162638/item/list
<*> milter-greylist-4.4.3-fix-crash-by-chown-without-group.diff
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/milter-greylist/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/milter-greylist/join
(Yahoo! ID required)
<*> To change settings via email:
milter-greylist-digest@...
milter-greylist-fullfeatured@...
<*> To unsubscribe from this group, send an email to:
milter-greylist-unsubscribe@...
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/