From yar@stylish.chem.msu.su  Wed Aug  4 14:55:00 2004
Return-Path: <yar@stylish.chem.msu.su>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4AAEA16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 Aug 2004 14:55:00 +0000 (GMT)
Received: from stylish.chem.msu.su (stylish.chem.msu.su [158.250.32.111])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4A0A943D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 Aug 2004 14:54:59 +0000 (GMT)
	(envelope-from yar@stylish.chem.msu.su)
Received: from stylish.chem.msu.su (localhost [127.0.0.1])
	by stylish.chem.msu.su (8.12.11/8.12.11) with ESMTP id i74Es9eR008260
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 Aug 2004 18:54:09 +0400 (MSD)
	(envelope-from yar@stylish.chem.msu.su)
Received: (from yar@localhost)
	by stylish.chem.msu.su (8.12.11/8.12.11/Submit) id i74Es8s5008259;
	Wed, 4 Aug 2004 18:54:08 +0400 (MSD)
	(envelope-from yar)
Message-Id: <200408041454.i74Es8s5008259@stylish.chem.msu.su>
Date: Wed, 4 Aug 2004 18:54:08 +0400 (MSD)
From: Yar Tikhiy <yar@comp.chem.msu.su>
To: FreeBSD-gnats-submit@freebsd.org
Subject: sysinstall(8) fails to locate FTP dirs if the OS has patchlevel
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         70002
>Category:       bin
>Synopsis:       sysinstall(8): fails to locate FTP dirs if the OS has patchlevel
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-sysinstall
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 04 15:00:37 GMT 2004
>Closed-Date:    
>Last-Modified:  Tue Jul 13 13:37:31 UTC 2010
>Originator:     Yar Tikhiy
>Release:        FreeBSD 4.9-RELEASE-p11 i386
>Organization:
Moscow State University
>Environment:
	Tested in 4.9-RELEASE-p11; seems to affect newer systems, too.

>Description:
	sysinstall(8) uses the local system release string (kern.osrelease)
	to construct the path to the distribution directory on an FTP site.
	However, it doesn't allow for a patchlevel `-pXX' that may appear
	in the release string.  Therefore sysinstall(8) fails to locate
	distribution files (in particular, packages) on FTP if a patchlevel
	is present in the local release string.

	This may appear confusing to beginner users, who are the primary
	consumers of sysinstall(8) as a system maintenance tool.

>How-To-Repeat:

root@bsd:~#uname -sr
FreeBSD 4.9-RELEASE-p11

root@bsd:~#/stand/sysinstall
...
+------------------ User Confirmation Requested ------------------+
| Warning:  Can't find the `4.9-RELEASE-p11' distribution on this |
| FTP server.  You may need to visit a different server for       |
| the release you are trying to fetch or go to the Options        |
| menu and to set the release name to explicitly match what's     |
| available on ftp.freebsd.org (or set to "any").                 |
|                                                                 |
| Would you like to select another FTP server?                    |
+-----------------------------------------------------------------+
|                      [ Yes ]         No                         |
+-----------------------------------------------------------------+

>Fix:

Since the system patchlevel doesn't affect sysinstall(8) actions
in any way, we can just strip it off completely as follows:

--- install.c.diff begins here ---
Index: install.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sysinstall/install.c,v
retrieving revision 1.355
diff -u -p -r1.355 install.c
--- install.c	2 Aug 2004 23:18:48 -0000	1.355
+++ install.c	4 Aug 2004 14:25:57 -0000
@@ -1154,10 +1154,15 @@ static char *
 getRelname(void)
 {
     static char buf[64];
+    char *p;
     size_t sz = (sizeof buf) - 1;
 
     if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) {
 	buf[sz] = '\0';
+	/* Strip off a possible patchlevel, i.e., do s/\(.+\)-p[0-9]+$/\1/. */
+	for (p = buf + strlen(buf) - 1; p > buf + 1 && isdigit(*p); p--);
+	if (p > buf + 1 && p[-1] == '-' && p[0] == 'p')
+	    p[-1] = '\0';
 	return buf;
     }
     else
--- install.c.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-qa 
Responsible-Changed-By: yar 
Responsible-Changed-When: Thu Mar 3 11:11:15 GMT 2005 
Responsible-Changed-Why:  
Over to the maintainers. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=70002 
Responsible-Changed-From-To: freebsd-bugs->freebsd-sysinstall 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Tue Jul 13 13:37:30 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=70002 
>Unformatted:
