[Gllug] apt-get failing in chrooted python script...

general_email at technicalbloke.com general_email at technicalbloke.com
Sun Sep 12 04:20:08 UTC 2010


On 09/09/10 16:59, Bruce Richardson wrote:
> On Thu, Sep 09, 2010 at 02:35:21PM +0200, Christof Meerwald wrote:
>    
>>> OK, that explains the error message.  As I said in my other e-mails, the
>>> getcwd() function is returning a broken value.  Now you have to find out
>>> why os.chroot isn't setting up the chroot entirely correctly (why the
>>> pre-chroot value for the cwd is leaking in).
>>>        
>> see http://www.kernel.org/doc/man-pages/online/pages/man2/chroot.2.html
>>
>>    "This call does not change the current working directory, so that
>>     after the call '.' can be outside the tree rooted at '/'."
>>
>> So you'll probably want to do a os.chdir('/') after the chroot.
>>      
> That would have been my next suggestion, but was waiting for feedback
> from the first tests.
>
>    


Yep, you're both right...

os.chroot(squashfs)
print os.getcwd()
 >>> /home/r0g/AAA_BACKED_UP/Code/projects/Techbench/remaster/workspace
os.chdir("/")
print os.getcwd()
 >>> /

It seems happy now, thanks a lot for your help :) I think I'll hop over 
to comp.lang.python and see if that's a deliberate behaviour or whether 
I need to file a bug!

Cheers,

Roger.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list