pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones



>Number:         45289
>Category:       pkg
>Synopsis:       Using pkg_add command from pkgsrc on Solaris 10 zones
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 24 11:55:00 +0000 2011
>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 = '/';



Home | Main Index | Thread Index | Old Index