bin/70002: sysinstall(8) fails to locate FTP dirs if the OS has patchlevel

Yar Tikhiy yar at comp.chem.msu.su
Wed Aug 4 08:00:38 PDT 2004


>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-bugs
>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:
>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 at bsd:~#uname -sr
FreeBSD 4.9-RELEASE-p11

root at 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:
>Unformatted:


More information about the freebsd-bugs mailing list