X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FAPI_Linux.cpp;h=97c1e902902b49acdd16e209ae344ecdc4d0d0dc;hp=45e85190219feab09eb8ddc90411dd640c81eed0;hb=15131cc4552b38de0638fa84164e509b05bb6c11;hpb=873afb00229b8e205345b6895eaad6602d5e10f4 diff --git a/src/API_Linux.cpp b/src/API_Linux.cpp index 45e8519..97c1e90 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; } @@ -336,7 +336,7 @@ bool suPHP::API_Linux::File_hasPermissionBit(const File& file, FileMode perm) break; case FILEMODE_GROUP_EXEC: - if ((temp.st_mode & S_IWGRP) == S_IWGRP) + if ((temp.st_mode & S_IXGRP) == S_IXGRP) return true; break; @@ -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__); + } +}