OpenVZ Forum


Home » General » Support » *SOLVED* getcwd dows not work on vps after chroot
*SOLVED* getcwd dows not work on vps after chroot [message #4760] Tue, 25 July 2006 17:54 Go to next message
disaster is currently offline  disaster
Messages: 158
Registered: February 2006
Senior Member
Hello!

I've a little C Script which works perfectly with Kernel from 2.4 - 2.6.17.x on every normal system.

On a VPS getcwd returns always NULL.

Here is some code - like the script works:

chroot("/home");

getcwd(cwd, MAX_LENGTH);

on the a normal hardware server getcwd works correkt - on a VPS (same installation / same image) it always returns NULL and cwd is empty.

Stefan

[Updated on: Wed, 26 July 2006 20:07] by Moderator

Report message to a moderator

Re: getcwd dows not work on vps after chroot [message #4768 is a reply to message #4760] Wed, 26 July 2006 06:13 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
1. To use chroot inside VPS you must grant this capability to VE:
vzctl set 200 --capability sys_chroot:on --save


2. However your "testcase" doesn't work even on the host node.
So it seems to be a bug. I've posted it in bugzilla:
http://bugzilla.openvz.org/show_bug.cgi?id=209
Thanks for report!
Re: getcwd dows not work on vps after chroot [message #4777 is a reply to message #4760] Wed, 26 July 2006 07:44 Go to previous messageGo to next message
disaster is currently offline  disaster
Messages: 158
Registered: February 2006
Senior Member
Hi!

I stopped the VPS, turned sys_chroot on and started the vps again. But the Script still does not work.

It works perfectly if i do:

chroot("/home");
chdir("/ABC");
getcwd(cwd, MAX_LENGTH);

but without chdir it does not work on a VPS.

So thanks for the bug report.
Re: getcwd dows not work on vps after chroot [message #4797 is a reply to message #4777] Wed, 26 July 2006 14:09 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
This isn't a bug.
In OpenVZ such scenario is deliberately prohibited for security
reasons: isolation of VEs.
This is rather mainstream BUG and the decent patch will be sent to kernel.org soon.
One more thing is that such scenario is questionable: you don't get consistent information from getcwd after chroot.
Re: getcwd dows not work on vps after chroot [message #4800 is a reply to message #4760] Wed, 26 July 2006 15:57 Go to previous message
disaster is currently offline  disaster
Messages: 158
Registered: February 2006
Senior Member
Mhm you're right - but it works normally Smile So i've not modified the script.
Previous Topic: *SOLVED* debian venet0 is always 127.0.0.1
Next Topic: *SOLVED* copying files from HN to VEs
Goto Forum:
  


Current Time: Sat Aug 17 14:18:11 GMT 2024

Total time taken to generate the page: 0.02758 seconds