Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Feb 2010 13:46:49 GMT
From:      Ming <symingz@foxmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/143698: pkg_add probably behaving incorrectly
Message-ID:  <201002091346.o19DknqE006952@www.freebsd.org>
Resent-Message-ID: <201002091350.o19Do3KZ005341@freefall.freebsd.org>

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

>Number:         143698
>Category:       ports
>Synopsis:       pkg_add probably behaving incorrectly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 09 13:50:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Ming
>Release:        8.0-RELEASE-p2
>Organization:
None
>Environment:
FreeBSD freebsd.hello 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Feb  9 00:16:31 CST 2010     root@freebsd.hello:/usr/obj/usr/src/sys/MINI  i386
>Description:
I think pkg_add has 2 incorrect behaviors: 
1. When using "pkg_add" or "pkg_add -r"to install a package, the installation 
   will continue even when pkg_add failed to find a dependent package , I think 
   this should only be the case when "-f" is used
2. When using "pkg_add -r" to install a package, the installation will 
   continue even when the fetch and extraction of the package are not 
   error free, and then the installation will only stop if the 
   "half-extracted package" triggers further error. I think installation 
   should stop as soon as an error is detected. Otherwise there is a chance 
   to leave the system in a "dirty state".
>How-To-Repeat:
For 1, just install a package without supplying the dependencies.

For 2, may be try to install a package that is a compressed broken tar (not tested, I think I encountered the problem due to network transfer error).
>Fix:
The fixes are not tested, but I think they might work:

For 1, change src/usr.sbin/pkg_install/add/perform.c, line 320 to:
    for (p = Plist.head; p && code == 0; p = p->next) {

For 2, change src/usr.sbin/pkg_install/lib/url.c as follows:
Insert after line 48: 
    int code = 0;
    int tarstat;

Replace line 152 to line 166 with:
    if (ferror(ftp)) {
	warn("warning: error reading from server");
	code++;
    }
    fclose(ftp);
    if (keep_package) {
	close(pkgfd);
    } 
    close(pfd[1]);
    if (w == -1) {
	warn("warning: error writing to tar");
	code++;
    }
    tpid = waitpid(tpid, &pstat, 0);
    tarstat = WEXITSTATUS(pstat);
    if (!tarstat) {
	warn("warning: error extracting package");
	code++;
    }
    if (Verbose)
	printf("tar command returns %d status\n", tarstat);
    if (code) {
        printf(" End with error.\n");
        return NULL;
    }
    if (rp && (isatty(0) || Verbose))
	printf(" Done.\n");
    return rp;

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



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