From owner-freebsd-bugs@FreeBSD.ORG Mon May 14 23:40:05 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0C2F616A417 for ; Mon, 14 May 2007 23:40:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id DF1A113C480 for ; Mon, 14 May 2007 23:40:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l4ENe4De021474 for ; Mon, 14 May 2007 23:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l4ENe4Wb021473; Mon, 14 May 2007 23:40:04 GMT (envelope-from gnats) Resent-Date: Mon, 14 May 2007 23:40:04 GMT Resent-Message-Id: <200705142340.l4ENe4Wb021473@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "John E. Hein" Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8364B16A400 for ; Mon, 14 May 2007 23:30:09 +0000 (UTC) (envelope-from jhein@timing.com) Received: from Daffy.timing.com (w.timing.com [206.168.13.218]) by mx1.freebsd.org (Postfix) with ESMTP id 44A4C13C45E for ; Mon, 14 May 2007 23:30:09 +0000 (UTC) (envelope-from jhein@timing.com) Received: from gromit.timing.com (gromit.timing.com [206.168.13.209]) by Daffy.timing.com (8.13.1/8.13.1) with ESMTP id l4ENU69o080255 for ; Mon, 14 May 2007 17:30:06 -0600 (MDT) (envelope-from jhein@timing.com) Received: from gromit.timing.com (localhost [127.0.0.1]) by gromit.timing.com (8.13.8/8.13.8) with ESMTP id l4ENU3xr037187; Mon, 14 May 2007 17:30:03 -0600 (MDT) (envelope-from jhein@gromit.timing.com) Received: (from jhein@localhost) by gromit.timing.com (8.13.8/8.13.8/Submit) id l4ENU3qr037186; Mon, 14 May 2007 17:30:03 -0600 (MDT) (envelope-from jhein) Message-Id: <200705142330.l4ENU3qr037186@gromit.timing.com> Date: Mon, 14 May 2007 17:30:03 -0600 (MDT) From: "John E. Hein" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/112673: [patch] pkg_add -S leaks the temp dir X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 May 2007 23:40:05 -0000 >Number: 112673 >Category: bin >Synopsis: [patch] pkg_add -S leaks the temp dir >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 14 23:40:04 GMT 2007 >Closed-Date: >Last-Modified: >Originator: John E. Hein >Release: FreeBSD 6.2-STABLE i386 >Organization: Symmetricom, Inc. >Environment: System: FreeBSD gromit.timing.com 6.2-STABLE FreeBSD 6.2-STABLE #2: Wed Mar 21 09:48:47 MDT 2007 jhein@gromit.timing.com:/usr/obj/usr/src/sys/GROMIT i386 7-current has the same problem. >Description: pkg_add -S doesn't clean up the temp dir created by pkg_add -M. I found this because pkg_add -p was not working because of a package that had multiple @cwd's - and plenty of packages do have these days due to USE_RC_SUBR. But that's another bug for another day. >How-To-Repeat: ls /var/tmp/instmp.* pkg_add -v -M pkg.tbz | pkg_add -v -S ls /var/tmp/instmp.* Note temp dir left uncleaned. >Fix: This patch works fine, but I'm not that pleased with it. But that's mostly because I wanted to rewrite more of pkg_* as I dug into the code. Rather than do that (which someone else may be undertaking already for SoC?), I figured a simple patch would do the trick for now. Alternate suggestions welcome. Index: src/usr.sbin/pkg_install/add/perform.c =================================================================== RCS file: /base/FreeBSD-CVS/src/usr.sbin/pkg_install/add/perform.c,v retrieving revision 1.80 diff -u -p -r1.80 perform.c --- src/usr.sbin/pkg_install/add/perform.c 9 Mar 2006 14:49:19 -0000 1.80 +++ src/usr.sbin/pkg_install/add/perform.c 14 May 2007 23:20:15 -0000 @@ -91,6 +91,7 @@ pkg_do(char *pkg) if (!pkg) { fgets(playpen, FILENAME_MAX, stdin); playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */ + note_playpen(playpen); if (chdir(playpen) == FAIL) { warnx("pkg_add in SLAVE mode can't chdir to %s", playpen); return 1; Index: src/usr.sbin/pkg_install/lib/lib.h =================================================================== RCS file: /base/FreeBSD-CVS/src/usr.sbin/pkg_install/lib/lib.h,v retrieving revision 1.60 diff -u -p -r1.60 lib.h --- src/usr.sbin/pkg_install/lib/lib.h 28 Mar 2007 05:33:52 -0000 1.60 +++ src/usr.sbin/pkg_install/lib/lib.h 14 May 2007 23:20:15 -0000 @@ -152,6 +152,7 @@ char *vpipe(const char *, ...); void cleanup(int); char *make_playpen(char *, off_t); char *where_playpen(void); +void note_playpen(const char *); void leave_playpen(void); off_t min_free(const char *); Index: src/usr.sbin/pkg_install/lib/pen.c =================================================================== RCS file: /base/FreeBSD-CVS/src/usr.sbin/pkg_install/lib/pen.c,v retrieving revision 1.42 diff -u -p -r1.42 pen.c --- src/usr.sbin/pkg_install/lib/pen.c 28 Jul 2004 16:03:13 -0000 1.42 +++ src/usr.sbin/pkg_install/lib/pen.c 14 May 2007 23:20:15 -0000 @@ -140,6 +140,17 @@ make_playpen(char *pen, off_t sz) return Previous; } +/* + * Just record an already created playpen, so we can clean it later. + */ +void +note_playpen(const char *pen) +{ + if (PenLocation[0]) + pushPen(PenLocation); + strcpy(PenLocation, pen); +} + /* Convenience routine for getting out of playpen */ void leave_playpen() >Release-Note: >Audit-Trail: >Unformatted: