[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bugfix for vacation



Nils,

It's generally better to send fixes for bugs to the bug tracking
system, than directly to me.  Stuff sent directly might get forgotten
about in my inbox.  I'm quoting your whole message and Cc'ing this
message to bug 41168, so you don't need to do it this time.  Also, it's
not very helpful for your mailer to MIME-encode your patch to be
quoted-unreadable, so I've undone that, too.

Thanks for analysing the bug; I'll fix it, together (hopefully) with my
many other outstanding bugs, when my thesis is finished (still several
weeks' worth of work to go...).

Thanks,

-- 
Charles Briscoe-Smith
My web page: <URL:http://www.debian.org/%7Ecpbs/>
PGP public keyprint: 74 68 AB 2E 1C 60 22 94  B8 21 2D 01 DE 66 13 E2


Nils Rennebarth wrote:
>The following patch fixes bug #41168 in bsdmainutils (i.e.: vacation does
>not send the contents of .vacation.msg)
>
>diff -r -u2 bsdmainutils-4.5.2.orig/vacation.c bsdmainutils-4.5.2/vacation.c
>--- bsdmainutils-4.5.2.orig/vacation.c  Thu Mar 25 04:11:53 1999
>+++ bsdmainutils-4.5.2/vacation.c       Thu Jul 15 02:38:05 1999
>@@ -419,5 +419,5 @@
>                exit(1);
>        }
>-       i = vfork();
>+       i = fork();
>        if (i < 0) {
>                syslog(LOG_ERR, "vacation: fork: %s", strerror(errno));
>
>
>
>It took me a crazy 5 hours of debugging to hunt down this one, so I would
>like to explain what happens and where the real source of the problem lies.
>
>This is the relevant code (#define VMSG ".vacation.msg")
>
>        mfp = fopen(VMSG, "r");
>        if (mfp == NULL) {
>                syslog(LOG_NOTICE, "vacation: no ~%s/%s file.\n", myname, VMSG)
>                exit(1);
>        }
>        if (pipe(pvect) < 0) {
>                syslog(LOG_ERR, "vacation: pipe: %s", strerror(errno));
>                exit(1);
>        }
>        i = fork();
>        if (i < 0) {
>                syslog(LOG_ERR, "vacation: fork: %s", strerror(errno));
>                exit(1);
>        }
>        if (i == 0) {
>                dup2(pvect[0], 0);
>                close(pvect[0]);  
>                close(pvect[1]);  
>                fclose(mfp);
>                execl(_PATH_SENDMAIL, "sendmail", "-f", myname, from, NULL);
>                syslog(LOG_ERR, "vacation: can't exec %s: %s",
>                        _PATH_SENDMAIL, strerror(errno));
>                exit(1);
>        }
>        close(pvect[0]);
>        sfp = fdopen(pvect[1], "w");
>        fprintf(sfp, "To: %s\n", from);
>        while (fgets(buf, sizeof buf, mfp))
>                fputs(buf, sfp);
>        fclose(mfp);
>        fclose(sfp);
>
>
>When control reaches the while loop, fgets immediately returns NULL, so
>probably mfp is already closed. Nothing of the message file gets written to
>the pipe connected with sendmail.
>
>Who is the culprit now?
>- Linux vfork implementation
>- vacation.c really should use fork instead of vfork
>- vacation.c closes too much files. It shouldn't do this when using
>  vfork
> 
>
>Nils
>
>--
>Plug-and-Play is really nice, unfortunately it only works 50% of the time.
>To be specific the "Plug" almost always works.            --unknown source


Reply to: