Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 42048

Summary: Bug in the mkdir portion of the sandbox
Product: Portage Development Reporter: Caleb Tennis (RETIRED) <caleb>
Component: SandboxAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal Keywords: InVCS
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 35836    

Description Caleb Tennis (RETIRED) gentoo-dev 2004-02-18 10:33:16 UTC
A while back, Azarah and I worked on resolving a sandbox problem related to making directories.  The fix was to make the sandbox return an EEXIST if the directory exists during a mkdir, even if the mkdir attempt was outside of the sandbox.  This is proper behavior.

However, it doesn't work properly all of the time.  The following is a proposed fix, however, it may need to be thought out a little bit more than what I have:

libsandbox.c, line 477:

-       lstat(canonic, &st);
-       if (0 == errno) {
+       if ((0 == lstat(canonic, &st))) {

Reproducible: Always
Steps to Reproduce:


Actual Results:  
You can see the effects of this at Bug #35836 

Expected Results:  
I would expect the sandbox to always return an EEXIST, and not fail if the 
directory exists (this works most of the time).
Comment 1 Priit Laes (IRC: plaes) 2004-02-18 11:54:56 UTC
I have tried the fix and it worked on my machine.
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2004-03-20 15:56:34 UTC
It's reasonable... You cannot assume errno is valid unless the
system call returns an error condition... you're checking success
in your patch... which would mean that the directory was stat'd.

I'm not sure about returning EEXIST... but non-zero is probably fine
as long as you set errno... which is done.
Comment 3 Jeffry Degrande 2004-04-06 16:59:29 UTC
returning errno is wrong, mkdir should return -1 on failure and set errno. Things really go wrong if not.  e.g. all cvs ebuilds are broken with this patch.  This works:

--- libsandbox.c        2004-03-22 02:40:58.000000000 +0100
+++ /home/jeffrey/libsandbox.c  2004-04-07 01:56:41.000000000 +0200
@@ -476,7 +476,7 @@
        /* Check if the directory exist, return EEXIST rather than failing */
        if (0 == lstat(canonic, &st)) {
                errno = EEXIST;
-               return errno;
+               return -1
        }
        errno = my_errno;
Comment 4 Masatomo Nakano (RETIRED) gentoo-dev 2004-04-06 19:21:07 UTC
I tried cvs ebuild with your patched sandbox
But it failed(same error).

Any idea?
Comment 5 Jeffry Degrande 2004-04-07 02:15:19 UTC
the 'cvs is not creating directories one at a time' warning followed by ther 'there is already a version in foobar' error? In that case, weird, works fine here, kde-cvs is emerging fine here right now.

If you get another error, try to remove your cvs repository first and check it out again.. In my case cvs had completely messed up the CVS/* directories
Comment 6 Masatomo Nakano (RETIRED) gentoo-dev 2004-04-07 02:29:48 UTC
I encountered the error.
Hmm, I'll try it again..

can anyone try it too?
Comment 7 Nicholas Jones (RETIRED) gentoo-dev 2004-10-22 08:48:05 UTC
Bug has been fixed and released in stable portages on or before 2.0.51-r2