NetBSD Problem Report #36741
From martin@duskware.de Mon Aug 6 18:47:13 2007
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id CB96563BAB7
for <gnats-bugs@gnats.netbsd.org>; Mon, 6 Aug 2007 18:47:12 +0000 (UTC)
Message-Id: <20070806172024.970E463BAD3@narn.NetBSD.org>
Date: Mon, 6 Aug 2007 17:20:24 +0000 (UTC)
From: tnn@NetBSD.org
Reply-To: tnn@NetBSD.org
To: netbsd-bugs-owner@NetBSD.org
Subject: pkg_admin(8)'s unset command can result in warning message
X-Send-Pr-Version: www-1.0
>Number: 36741
>Category: pkg
>Synopsis: pkg_admin(8)'s unset command can result in warning message
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: joerg
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Aug 06 18:50:00 +0000 2007
>Closed-Date: Sun Jan 20 07:14:09 +0000 2008
>Last-Modified: Sun Jan 20 07:14:09 +0000 2008
>Originator: Tobias Nygren
>Release:
>Organization:
NetBSD
>Environment:
>Description:
pkg_admin(8) unset of a non-existing variable can result in a non-fatal warning message when +INSTALLED_INFO does not exist.
>How-To-Repeat:
# pkg_admin set foo=YES digest
# pkg_admin set bar=YES digest
# pkg_admin unset foo digest
# pkg_admin unset foo digest
# pkg_admin unset bar digest
# pkg_admin unset bar digest
pkg_admin: var_set: cannot remove 'digest-20070803/+INSTALLED_INFO': No such file or directory
>Fix:
joerg@ said he'll look at it.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: pkg-manager->joerg
Responsible-Changed-By: tnn@netbsd.org
Responsible-Changed-When: Mon, 06 Aug 2007 18:52:30 +0000
Responsible-Changed-Why:
Over to maintainer.
From: Dieter Baron <dillo@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/36741
Date: Wed, 8 Aug 2007 08:44:49 +0200
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
hi,
try the appached diff, which should fix the spurious warning. It also
fixes a segfault if opening the temp file doesn't work and no
+INSTALLED_INFO exists (e.g. when trying to set the first variable as
non-root).
Joerg: okay to commit?
yours,
dillo
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pkg_install-unset.diff"
Index: files/lib/var.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/var.c,v
retrieving revision 1.4
diff -u -r1.4 var.c
--- files/lib/var.c 24 Apr 2006 13:52:05 -0000 1.4
+++ files/lib/var.c 8 Aug 2007 06:40:35 -0000
@@ -168,23 +168,31 @@
return 0;
fp = fopen(fname, "r");
- if (!fp && errno != ENOENT) {
- warn("var_set: can't open '%s' for reading", fname);
- return -1;
+ if (fp == NULL) {
+ if (errno != ENOENT) {
+ warn("var_set: can't open '%s' for reading", fname);
+ return -1;
+ }
+ if (value == NULL) {
+ /* no variables are set, so unset is a no-op */
+ return 0;
+ }
}
tmpname = malloc(strlen(fname)+8);
sprintf(tmpname, "%s.XXXXXX", fname);
if ((fd=mkstemp(tmpname)) < 0) {
free(tmpname);
- fclose(fp);
+ if (fp)
+ fclose(fp);
warn("var_set: can't open temp file for '%s' for writing",
fname);
return -1;
}
if (chmod(tmpname, 0644) < 0) {
close(fd);
- fclose(fp);
+ if (fp)
+ fclose(fp);
free(tmpname);
warn("var_set: can't set permissions for temp file for '%s'",
fname);
@@ -194,7 +202,8 @@
close(fd);
remove(tmpname);
free(tmpname);
- fclose(fp);
+ if (fp)
+ fclose(fp);
warn("var_set: can't open temp file for '%s' for writing",
fname);
return -1;
--UlVJffcvxoiEqYs2--
State-Changed-From-To: open->closed
State-Changed-By: tnn@narn.netbsd.org
State-Changed-When: Sun, 20 Jan 2008 07:14:09 +0000
State-Changed-Why:
The suggested patch was committed at 2007-08-09.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.