X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FAPI_Linux.cpp;h=2b3ea4566bc8a1d2f7c757ff5b4647983a198cae;hp=45e85190219feab09eb8ddc90411dd640c81eed0;hb=47bcf8ba77fa8011f9be728c23dbe6915d70251b;hpb=1d5c20a335c25ab89adf2e0d3d74c810b679e719 diff --git a/src/API_Linux.cpp b/src/API_Linux.cpp index 45e8519..2b3ea45 100644 --- a/src/API_Linux.cpp +++ b/src/API_Linux.cpp @@ -237,7 +237,7 @@ std::string suPHP::API_Linux::File_getRealPath(const File& file) const std::string resolvedpath = ""; bool failed = true; - if (currentpath.at(0) != '/') { + if ((currentpath.size() == 0) || (currentpath.at(0) != '/')) { currentpath = this->getCwd() + std::string("/") + currentpath; } @@ -452,3 +452,11 @@ void suPHP::API_Linux::setCwd(const std::string& dir) const void suPHP::API_Linux::setUmask(int mode) const throw (SystemException) { ::umask(mode); } + +void suPHP::API_Linux::chroot(const std::string& dir) const + throw (SystemException) { + if (::chroot(dir.c_str())) { + throw SystemException(std::string("chroot() failed: ") + + ::strerror(errno), __FILE__, __LINE__); + } +}