Date: Mon, 14 May 2007 17:30:03 -0600 (MDT) From: "John E. Hein" <jhein@timing.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/112673: [patch] pkg_add -S leaks the temp dir Message-ID: <200705142330.l4ENU3qr037186@gromit.timing.com> Resent-Message-ID: <200705142340.l4ENe4Wb021473@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705142330.l4ENU3qr037186>