Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2007 08:19:40 GMT
From:      "G. Paul Ziemba" <p-fbsd-bugs@treehouse.napa.ca.us>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/114375: [patch] news/nn 6.7.3 From: header broken when posting via nntp
Message-ID:  <200707070819.l678JeFg041139@www.freebsd.org>
Resent-Message-ID: <200707070820.l678K3t9089192@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         114375
>Category:       ports
>Synopsis:       [patch] news/nn 6.7.3 From: header broken when posting via nntp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 07 08:20:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     G. Paul Ziemba
>Release:        6.2-STABLE
>Organization:
>Environment:
FreeBSD hairball.treehouse.napa.ca.us 6.2-STABLE FreeBSD 6.2-STABLE #0: Sun Jun  3 19:55:09 PDT 2007     root@hairball:/usr/obj/usr/src/sys/GPZ-070603  i386

>Description:
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@example.com>
 
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().

Proposed patch to the port's file/patch-an below.
>How-To-Repeat:
0. Configure nn to use nntp
1. Ensure no From: header is set explicitly in user configuration (e.g., via news-header in ~/.nn/init)
2. nnpost
3. observe resulting From: header
>Fix:
Proposed patch (to patch-an 1.5) attached

Patch attached with submission follows:

--- patch-an.orig	Sat Jul  7 00:48:41 2007
+++ patch-an	Sat Jul  7 00:34:32 2007
@@ -1,5 +1,5 @@
---- nntp.c.orig	Tue Apr 19 18:06:51 2005
-+++ nntp.c	Sat Sep  3 14:34:49 2005
+--- nntp.c.orig	Tue Apr 19 16:06:51 2005
++++ nntp.c	Sat Jul  7 00:30:15 2007
 @@ -76,6 +76,7 @@
  static int      connect_server(void);
  static void     debug_msg(char *prefix, char *str);
@@ -59,31 +59,28 @@
  /*
   * get_server_line: get a line from the server.
   *
-@@ -1492,15 +1537,24 @@
- gen_frompath(void)
- {
-     struct passwd  *passwd;
-+    char           *domain;
-+    const char     *fromFormat = "From: <%s@%s>\r\n";
+@@ -848,6 +893,16 @@
  
-     passwd = getpwuid(getuid());
+ #else				/* DOMAIN */
  
-     fprintf(nntp_out, "From: ");
-     fprintf(nntp_out, "%s ", full_name());
- 
--    fprintf(nntp_out, "<%s@%s>\r\n",
--	    passwd->pw_name,
--	    domain);
-+    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);
++    /*
++     * if domain is defined in DOMAIN_FILE, use it
++     */
++    cp = find_domain(DOMAIN_FILE);
++    if (cp) {
++	strncpy(domain, cp, MAXHOSTNAMELEN);
++	domain[MAXHOSTNAMELEN-1] = 0;	/* ensure nul-terminated */
++	return;
 +    }
++
+     domain[0] = '\0';
  
- #ifdef HIDDENNET
-     /* Only the login name - nntp server will add uucp name */
+     cp = index(host_name, '.');
+@@ -882,6 +937,7 @@
+ #endif
+     }
+ #endif				/* DOMAIN */
++    domain[MAXHOSTNAMELEN-1] = 0;	/* ensure nul-terminated */
+ }
+ 
+ /*


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707070819.l678JeFg041139>