news/nn: proposed fix to "From:" header

freebsd-ports-redist at treehouse.napa.ca.us freebsd-ports-redist at treehouse.napa.ca.us
Sat Jul 7 07:07:42 UTC 2007


[I wonder if there are more than three users of the nn port...]
 
The nn-6.7.3 port generates broken From: headers because of 
patch-an to nntp.c. I'm not certain, but I think it's because
some ifdefs in earlier versions of the base code were removed 
before 6.7.3 was released, and the patch was not updated to
take that into account.
 
Here's the result of patch-an as it stands today:
 
    static void
    gen_frompath(void)
    {
        struct passwd  *passwd;
        char           *domain;
        const char     *fromFormat = "From: <%s@%s>\r\n";
 
        passwd = getpwuid(getuid());
 
        fprintf(nntp_out, "From: ");
        fprintf(nntp_out, "%s ", full_name());
 
        domain = find_domain(DOMAIN_FILE);
        if (domain == NULL) {
            fprintf(nntp_out, fromFormat,
                    passwd->pw_name,
                    host_name);
        } else {
            fprintf(nntp_out, fromFormat,
                    passwd->pw_name,
                    domain);
        }
 
        [...]
 
    }
  
As you can see, this results in a From: line that looks like:
 
    From: Some User From: <someuser at example.com>
    
(It's likely this problem will be evident in the From: line of 
this very message)
 
The find_domain() code (to obtain the domain name from a file)
seems to have been added as part of the FreeBSD port and is not 
part of the base nn distribution. The use of "char *domain;" in 
gen_frompath() obscures the global of the same name, which is 
already set via set_domain().
 
set_domain() already has provisions for obtaining the local
domain name in various ways (local hostname, resolv.conf, etc.)
and respects HIDDENNET for those cases. (yes, I realize HIDDENNET
doesn't have a knob in the port Makefile, yet)
 
While I'm fixing the immediate problem (incorrect From: line format),
I'd like to modify the FreeBSD-specific implementation of find_domain()
and make it part of set_domain(), so that if a domain is not specified
in the domain file it can fall back to the assortment of mechanisms
in set_domain().

Does anyone have thoughts on this approach?
-- 
G. Paul Ziemba
FreeBSD unix:
11:46PM  up 4 days, 14:09, 13 users, load averages: 0.20, 0.21, 0.21


More information about the freebsd-ports mailing list