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,
--
kouMessage
[PATCH] fix a crash bug by chown socket without group
2013-03-22 by Kouhei Sutou
Attachments
- No local attachments were found for this message.