NetBSD Problem Report #45289
From www@NetBSD.org Wed Aug 24 11:54:15 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 0618963BED9
for <gnats-bugs@gnats.NetBSD.org>; Wed, 24 Aug 2011 11:54:15 +0000 (UTC)
Message-Id: <20110824115414.384E263BAC3@www.NetBSD.org>
Date: Wed, 24 Aug 2011 11:54:14 +0000 (UTC)
From: tlusty@vse.cz
Reply-To: tlusty@vse.cz
To: gnats-bugs@NetBSD.org
Subject: Using pkg_add command from pkgsrc on Solaris 10 zones
X-Send-Pr-Version: www-1.0
>Number: 45289
>Category: pkg
>Synopsis: Using pkg_add command from pkgsrc on Solaris 10 zones
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: agc
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 24 11:55:00 +0000 2011
>Closed-Date: Sat May 20 19:19:45 +0000 2017
>Last-Modified: Sat May 20 19:19:45 +0000 2017
>Originator: Zdenek Tlusty
>Release:
>Organization:
University of Economics, Prague
>Environment:
SunOS host 5.10 Generic_144488-17 sun4v sparc SUNW,SPARC-Enterprise-T5120
>Description:
In default Solaris zones configuration are directories /lib, /platform, /usr and /sbin are inherited from global (master) zone. Non-global zones have only read-only access into these directories.
Typical instalation directory of pkgsrc is /usr/pkg or something in /usr.
There is posibility to mount another filesystem in /usr/pkg directory of non-global zone. This /usr/pkg directory is read-write.
Using current pkg_add command the mkdir_p () tries to make even the existing /usr/pkg directory. This operation failed with "Read-only filesystem" error and pkg_add fails.
The pkg_add should not try to create existing directories. The handling of EEXIST error is not enough in this case.
>How-To-Repeat:
Make /usr read-only and into directory /usr/pkg mount read-write filesystem. Try to install some packages with pkgdir /usr/pkg
>Fix:
The pkg_add should test in some way the existence of directory before try to create it.
Below is some dirty patch of pkgsrc/pkgtools/pkg_install/files/add/perform.c file. With this patch the pkg_add works fine in default Solaris zones configuration:
--- perform.c?rev=1.99 2010-12-12 14:18:38.000000000 +0100
+++ perform.c 2011-08-19 15:40:06.000000000 +0200
@@ -59,7 +59,9 @@
#include "lib.h"
#include "add.h"
#include "version.h"
+#include <dirent.h>
+DIR *dir_pointer;
struct pkg_meta {
char *meta_contents;
char *meta_comment;
@@ -175,11 +177,14 @@
* Handle the easy case of direct success or
* pre-existing directory first.
*/
- if (mkdir(path, 0777) == 0 || errno == EEXIST)
- return 0;
- if (errno != ENOENT)
- return -1;
-
+ dir_pointer = opendir (path);
+ if (dir_pointer == NULL) {
+ if (mkdir(path, 0777) == 0 || errno == EEXIST)
+ return 0;
+ if (errno != ENOENT)
+ return -1;
+ }
+ (void) closedir (dir_pointer);
cur_end = p = xstrdup(path);
for (;;) {
@@ -202,10 +207,14 @@
* ENOENT can only happen if something else races us,
* in which case we should better give up.
*/
- if (mkdir(p, 0777) == -1 && errno != EEXIST) {
- free(p);
- return -1;
+ dir_pointer = opendir (p);
+ if (dir_pointer == NULL) {
+ if (mkdir(p, 0777) == -1 && errno != EEXIST) {
+ free(p);
+ return -1;
+ }
}
+ (void) closedir (dir_pointer);
if (done)
break;
*cur_end = '/';
>Release-Note:
>Audit-Trail:
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Wed, 24 Aug 2011 16:34:24 +0200
On Wed, Aug 24, 2011 at 11:55:00AM +0000, tlusty@vse.cz wrote:
> The pkg_add should not try to create existing directories. The handling
> of EEXIST error is not enough in this case.
Just to make sure:
mkdir /usr/pkg
fails with EROFS on Solaris if /usr/pkg already exists and the
filesystem it is on is read-only? If yes, please fill a bug with Solaris
first as this is a serious POSIX compliance issue.
Joerg
From: Zdenek Tlusty <tlusty@vse.cz>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
pkg-manager@netbsd.org,
pkgsrc-bugs@netbsd.org,
tlusty@vse.cz
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Wed, 24 Aug 2011 17:04:33 +0200
Yes,
bash-4.2# mkdir /usr/pkg
mkdir: Failed to make directory "/usr/pkg"; Read-only file system
bash-4.2# mkdir /usr/pkg/bin
mkdir: Failed to make directory "/usr/pkg/bin"; File exists
Are there something like "error code reporting precedence" - so the EEXIST
error has the precedence before EROFS in POSIX?
BR,
Zdenek
Joerg Sonnenberger <joerg@britannica.bec.de> napsal dne 24.08.2011
16:35:02:
> The following reply was made to PR pkg/45289; it has been noted by GNATS.
>
> From: Joerg Sonnenberger <joerg@britannica.bec.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10
zones
> Date: Wed, 24 Aug 2011 16:34:24 +0200
>
> On Wed, Aug 24, 2011 at 11:55:00AM +0000, tlusty@vse.cz wrote:
> > The pkg_add should not try to create existing directories. The
handling
> > of EEXIST error is not enough in this case.
>
> Just to make sure:
>
> mkdir /usr/pkg
>
> fails with EROFS on Solaris if /usr/pkg already exists and the
> filesystem it is on is read-only? If yes, please fill a bug with Solaris
> first as this is a serious POSIX compliance issue.
>
> Joerg
>
From: Zdenek Tlusty <tlusty@vse.cz>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
pkg-manager@netbsd.org,
pkgsrc-bugs@netbsd.org
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Wed, 24 Aug 2011 23:09:06 +0200
Hello Joerg,
the command mkdir /usr/pkg should fail with two errors - EEXIST and EROFS.
Regarding of POSIX XSH Section 2.3 Error Numbers
(http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_03.html)
there is no precedence if more than one error occurs:
"If more than one error occurs in processing a function call, any one of
the possible errors may be returned, as the order of detection is
undefined."
The EROFS is correct error and this behaviour is POSIX compliant.
Please, correct me if I am wrong.
Best Regards,
Zdenek
Joerg Sonnenberger <joerg@britannica.bec.de> napsal dne 24.08.2011
16:35:02:
> The following reply was made to PR pkg/45289; it has been noted by GNATS.
>
> From: Joerg Sonnenberger <joerg@britannica.bec.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10
zones
> Date: Wed, 24 Aug 2011 16:34:24 +0200
>
> On Wed, Aug 24, 2011 at 11:55:00AM +0000, tlusty@vse.cz wrote:
> > The pkg_add should not try to create existing directories. The
handling
> > of EEXIST error is not enough in this case.
>
> Just to make sure:
>
> mkdir /usr/pkg
>
> fails with EROFS on Solaris if /usr/pkg already exists and the
> filesystem it is on is read-only? If yes, please fill a bug with Solaris
> first as this is a serious POSIX compliance issue.
>
> Joerg
>
From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc:
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Fri, 26 Aug 2011 10:18:56 +0200
On Wed, Aug 24, 2011 at 11:55:00AM +0000, tlusty@vse.cz wrote:
> --- perform.c?rev=1.99 2010-12-12 14:18:38.000000000 +0100
> +++ perform.c 2011-08-19 15:40:06.000000000 +0200
> @@ -59,7 +59,9 @@
> #include "lib.h"
> #include "add.h"
> #include "version.h"
> +#include <dirent.h>
>
> +DIR *dir_pointer;
> struct pkg_meta {
> char *meta_contents;
> char *meta_comment;
> @@ -175,11 +177,14 @@
> * Handle the easy case of direct success or
> * pre-existing directory first.
> */
> - if (mkdir(path, 0777) == 0 || errno == EEXIST)
> - return 0;
> - if (errno != ENOENT)
> - return -1;
> -
> + dir_pointer = opendir (path);
> + if (dir_pointer == NULL) {
> + if (mkdir(path, 0777) == 0 || errno == EEXIST)
> + return 0;
> + if (errno != ENOENT)
> + return -1;
> + }
> + (void) closedir (dir_pointer);
> cur_end = p = xstrdup(path);
>
> for (;;) {
I think you should only call closedir if dir_pointer is != NULL, i.e.
move it in the if statement.
Thomas
From: Zdenek Tlusty <tlusty@vse.cz>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
pkg-manager@netbsd.org,
pkgsrc-bugs@netbsd.org
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Fri, 26 Aug 2011 10:26:16 +0200
Thanks for the hint. Below is updated diff.
BR,
Zdenek
--- perform.c?rev=1.99 2010-12-12 14:18:38.000000000 +0100
+++ perform.c 2011-08-26 10:23:51.000000000 +0200
@@ -59,7 +59,9 @@
#include "lib.h"
#include "add.h"
#include "version.h"
+#include <dirent.h>
+DIR *dir_pointer;
struct pkg_meta {
char *meta_contents;
char *meta_comment;
@@ -175,11 +177,16 @@
* Handle the easy case of direct success or
* pre-existing directory first.
*/
- if (mkdir(path, 0777) == 0 || errno == EEXIST)
- return 0;
- if (errno != ENOENT)
- return -1;
-
+ dir_pointer = opendir (path);
+ if (dir_pointer == NULL) {
+ if (mkdir(path, 0777) == 0 || errno == EEXIST)
+ return 0;
+ if (errno != ENOENT)
+ return -1;
+ }
+ else {
+ (void) closedir (dir_pointer);
+ }
cur_end = p = xstrdup(path);
for (;;) {
@@ -202,9 +209,15 @@
* ENOENT can only happen if something else races us,
* in which case we should better give up.
*/
- if (mkdir(p, 0777) == -1 && errno != EEXIST) {
- free(p);
- return -1;
+ dir_pointer = opendir (p);
+ if (dir_pointer == NULL) {
+ if (mkdir(p, 0777) == -1 && errno != EEXIST) {
+ free(p);
+ return -1;
+ }
+ }
+ else {
+ (void) closedir (dir_pointer);
}
if (done)
break;
Thomas Klausner <wiz@NetBSD.org> napsal dne 26.08.2011 10:20:06:
> I think you should only call closedir if dir_pointer is != NULL, i.e.
> move it in the if statement.
> Thomas
Responsible-Changed-From-To: pkg-manager->agc
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Fri, 26 Aug 2011 08:41:43 +0000
Responsible-Changed-Why:
Over to maintainer.
From: Zdenek Tlusty <tlusty@vse.cz>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Mon, 9 Jan 2012 22:44:39 +0100
Toto je zpr va s v。ce 泛stmi ve form tu MIME.
--=_alternative 00776EAAC1257980_=
Content-Type: text/plain; charset="US-ASCII"
Hello,
will be my patch accepted or will be the bug resolved by any other way?
BR,
Zdenek
Zdenek Tlusty <tlusty@vse.cz> napsal dne 26.08.2011 10:30:04:
> Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10
zones
> Date: Fri, 26 Aug 2011 10:26:16 +0200
>
> Thanks for the hint. Below is updated diff.
>
> BR,
>
> Zdenek
>
>
> --- perform.c?rev=1.99 2010-12-12 14:18:38.000000000 +0100
> +++ perform.c 2011-08-26 10:23:51.000000000 +0200
> @@ -59,7 +59,9 @@
> #include "lib.h"
> #include "add.h"
> #include "version.h"
> +#include <dirent.h>
>
> +DIR *dir_pointer;
> struct pkg_meta {
> char *meta_contents;
> char *meta_comment;
> @@ -175,11 +177,16 @@
> * Handle the easy case of direct success or
> * pre-existing directory first.
> */
> - if (mkdir(path, 0777) == 0 || errno == EEXIST)
> - return 0;
> - if (errno != ENOENT)
> - return -1;
> -
> + dir_pointer = opendir (path);
> + if (dir_pointer == NULL) {
> + if (mkdir(path, 0777) == 0 || errno == EEXIST)
> + return 0;
> + if (errno != ENOENT)
> + return -1;
> + }
> + else {
> + (void) closedir (dir_pointer);
> + }
> cur_end = p = xstrdup(path);
>
> for (;;) {
> @@ -202,9 +209,15 @@
> * ENOENT can only happen if something else races us,
> * in which case we should better give up.
> */
> - if (mkdir(p, 0777) == -1 && errno != EEXIST) {
> - free(p);
> - return -1;
> + dir_pointer = opendir (p);
> + if (dir_pointer == NULL) {
> + if (mkdir(p, 0777) == -1 && errno != EEXIST) {
> + free(p);
> + return -1;
> + }
> + }
> + else {
> + (void) closedir (dir_pointer);
> }
> if (done)
> break;
--=_alternative 00776EAAC1257980_=
Content-Type: text/html; charset="US-ASCII"
<font size=2 face="sans-serif">Hello,</font>
<br>
<br><font size=2 face="sans-serif">will be my patch accepted or will be
the bug resolved by any other way?</font>
<br>
<br><font size=2 face="sans-serif">BR,</font>
<br>
<br><font size=2 face="sans-serif">Zdenek</font>
<br>
<br><font size=2>Zdenek Tlusty <tlusty@vse.cz> napsal dne 26.08.2011
10:30:04:<br>
<br>
> Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris
10 zones<br>
> Date: Fri, 26 Aug 2011 10:26:16 +0200<br>
> <br>
> Thanks for the hint. Below is updated diff.<br>
> <br>
> BR,<br>
> <br>
> Zdenek<br>
> <br>
> <br>
> --- perform.c?rev=1.99 2010-12-12 14:18:38.000000000 +0100<br>
> +++ perform.c 2011-08-26 10:23:51.000000000 +0200<br>
> @@ -59,7 +59,9 @@<br>
> #include "lib.h"<br>
> #include "add.h"<br>
> #include "version.h"<br>
> +#include <dirent.h><br>
> <br>
> +DIR *dir_pointer;<br>
> struct pkg_meta {<br>
> char *meta_contents;<br>
> char *meta_comment;<br>
> @@ -175,11 +177,16 @@<br>
> * Handle the easy case of direct
success or<br>
> * pre-existing directory first.<br>
> */<br>
> - if (mkdir(path, 0777) == 0 || errno ==
EEXIST)<br>
> - return 0;<br>
> - if (errno != ENOENT)<br>
> - return -1;<br>
> -<br>
> + dir_pointer = opendir (path);<br>
> + if (dir_pointer == NULL) {<br>
> + if (mkdir(path, 0777) ==
0 || errno == EEXIST)<br>
> +
return 0;<br>
> + if (errno != ENOENT)<br>
> +
return -1;<br>
> + }<br>
> + else {<br>
> + (void) closedir (dir_pointer);<br>
> + }<br>
> cur_end = p = xstrdup(path);<br>
> <br>
> for (;;) {<br>
> @@ -202,9 +209,15 @@<br>
> * ENOENT
can only happen if something else races us,<br>
> * in
which case we should better give up.<br>
> */<br>
> - if (mkdir(p,
0777) == -1 && errno != EEXIST) {<br>
> -
free(p);<br>
> -
return -1;<br>
> + dir_pointer
= opendir (p);<br>
> + if (dir_pointer
== NULL) {<br>
> +
if (mkdir(p, 0777) == -1 && errno != EEXIST) {<br>
> +
free(p);<br>
> +
return -1;<br>
> +
}<br>
> + }<br>
> + else {<br>
> +
(void) closedir (dir_pointer);<br>
> }<br>
> if (done)<br>
>
break;<br>
</font>
--=_alternative 00776EAAC1257980_=--
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Sun, 22 Jan 2012 18:11:33 +0000
On Mon, Jan 09, 2012 at 09:45:02PM +0000, Zdenek Tlusty wrote:
> Hello,
>
> will be my patch accepted or will be the bug resolved by any other way?
>
> BR,
>
> Zdenek
It looks more or less ok to me (although I'd probably check for the
dir existing with stat(), not opendir()) but it really wants an
official thumbs-up or thumbs-down from the package maintainer.
--
David A. Holland
dholland@netbsd.org
From: "Joerg Sonnenberger" <joerg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45289 CVS commit: pkgsrc/pkgtools/pkg_install/files
Date: Sat, 28 Jan 2012 12:33:05 +0000
Module Name: pkgsrc
Committed By: joerg
Date: Sat Jan 28 12:33:05 UTC 2012
Modified Files:
pkgsrc/pkgtools/pkg_install/files/add: perform.c
pkgsrc/pkgtools/pkg_install/files/lib: opattern.c version.h
Log Message:
pkg_install-20120128:
- Explicitly stat(2) if mkdir failed. errno detection doesn't work e.g.
on Solaris (PR 45289)
- Provide a stable order for package names that only differe in the base
name, not the version number.
To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 pkgsrc/pkgtools/pkg_install/files/add/perform.c
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/pkg_install/files/lib/opattern.c
cvs rdiff -u -r1.162 -r1.163 pkgsrc/pkgtools/pkg_install/files/lib/version.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 17 Mar 2012 12:52:19 +0000
State-Changed-Why:
Stuff was committed; does it work for you now?
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 20 May 2017 19:19:45 +0000
State-Changed-Why:
5-year feedback timeout
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.