Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.mail.sendmail Subject: Re: sendmail generates bogus error messages Keywords: errno fprintf error ENOTTY network host Message-ID: <13864@mimsy.UUCP> Date: 4 Oct 88 19:41:53 GMT References: <3153@hermes.ai.mit.edu> <30999@uunet.UU.NET> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 36 -In article <3153@hermes.ai.mit.edu> wisner@zug.AI.MIT.EDU (Bill Wisner) writes: ->... I should be seeing error messages like -> Deferred: Connection timed out during user open with basel.ai.mit.edu ->Instead, I get this: -> Deferred: Not a typewriter In article <30999@uunet.UU.NET> dsc@izimbra.CSS.GOV (card carrying aclu member) writes: -i believe the problem you are seeing is that errno gets clobbered -during a fprintf() call in usersmtp.c. look in smtpinit() for the -fprintf() call where one of the arguments is errstring(errno) and add -two assignments to save & restore errno before calling fprintf, ala - - r = errno; - fprintf(CurEnv->e_xfp, - "421 %s.%s... Deferred: %s\n", - pvp[1], m->m_name, errstring(errno)); - errno = r; This will work, but there are other fixes. -of course, why errno is getting set to ENOTTY or some other value by -fprintf is in itself an interesting question ... fprintf calls isatty when printing the first character to a FILE. isatty calls ioctl(fd, TIOCGETP) and checks for errors. TIOCGETP succeeds only on terminals. The error, of course, is ENOTTY. I fixed(?) this by changing the C library routine isatty() to itself save and restore errno; but a proper program should never check errno except immediately after a failing system call. A better fix to sendmail itself (with or without the change in the C library) is to have it retain the error number (or string) in the envelope structure. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris