OpenVZ Forum - RDF feed
type: channel
items: *SOLVED* getcwd dows not work on vps after chroot
items: Re: getcwd dows not work on vps after chroot

*SOLVED* getcwd dows not work on vps after chroot
type: item
description: 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
creator: disaster
date: 2006-07-25T17:54:46-00:00

Re: getcwd dows not work on vps after chroot
type: item
description: 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!
creator: Vasily Tarasov
date: 2006-07-26T06:13:07-00:00

Re: getcwd dows not work on vps after chroot
type: item
description: 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.
creator: disaster
date: 2006-07-26T07:44:47-00:00

Re: getcwd dows not work on vps after chroot
type: item
description: 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.
creator: Vasily Tarasov
date: 2006-07-26T14:09:50-00:00

Re: getcwd dows not work on vps after chroot
type: item
description: Mhm you're right - but it works normally So i've not modified the script.
creator: disaster
date: 2006-07-26T15:57:45-00:00