Bug#374705: [Pkg-shadow-devel] Bug#374705: tentative patch
Nicolas François
nicolas.francois at centraliens.net
Wed Jun 21 19:57:04 UTC 2006
Tomasz,
On Wed, Jun 21, 2006 at 10:55:36AM +0100, Stephen Gran wrote:
> Hey all,
>
> I think I might have found the problem. The mail spool is open()ed, and
> then the fd is checked to see if there is an error (as is proper). The
> problem is, the fchown/fchmod calls happen in the same logic path as
> error handling, not in an else block. The attached patch should fix it.
What I don't understand, is why the mail box is created if this bloc of
code cannot be reached (due to the issue described below).
> I have to note in passing, though, that I had to change the line
>
> if (strcasecmp (create_mail_spool, "yes") == 0) {
>
> to
>
> if (strcasecmp (def_create_mail_spool, "yes") == 0) {
Tomasz, create_mail_spool is never set. It should either be removed, or
set somewhere (e.g. like the other similar variables in process_flags,
even if there is no flags for this value).
> to even enter this block in the first place - is there an incomplete
> variable name transition, or am I doing something wrong?
>
> --- src/useradd.c~ 2006-06-21 10:51:01.000000000 +0100
> +++ src/useradd.c 2006-06-21 10:51:17.000000000 +0100
> @@ -1599,6 +1599,7 @@
> if (fd < 0) {
> perror (_("Creating mailbox file"));
> return;
> + } else {
>
> gr = getgrnam ("mail");
> if (!gr) {
Thanks for the patch. This also looks correct.
I'm attaching another patch, which fixes this issue, the other issue
mentionned by Stephen and another issue (def_create_mail_spool should
never be set to CREATE_MAIL_SPOOL).
Note: I still don't understand the Debian bug and can't reproduce it. I
will look closer later.
Kind Regards,
--
Nekral
-------------- next part --------------
Index: src/useradd.c
===================================================================
RCS file: /cvsroot/shadow/src/useradd.c,v
retrieving revision 1.97
diff -u -r1.97 useradd.c
--- src/useradd.c 20 Jun 2006 20:00:04 -0000 1.97
+++ src/useradd.c 21 Jun 2006 19:29:56 -0000
@@ -343,9 +343,6 @@
* Create by default user mail spool or not ?
*/
else if (MATCH (buf, CREATE_MAIL_SPOOL)) {
- if (*cp == '\0')
- cp = CREATE_MAIL_SPOOL; /* XXX warning: const */
-
def_create_mail_spool = xstrdup (cp);
}
}
@@ -1247,6 +1244,8 @@
if (!sflg)
user_shell = def_shell;
+
+ create_mail_spool = def_create_mail_spool;
}
/*
@@ -1600,7 +1599,7 @@
if (fd < 0) {
perror (_("Creating mailbox file"));
return;
-
+ } else {
gr = getgrnam ("mail");
if (!gr) {
fprintf (stderr,
More information about the Pkg-shadow-devel
mailing list