porting 1.4.4. rev. 1926 (SF#3478665: Permission checks in Poco::File not correct for root)

This commit is contained in:
Aleksandar Fabijanic 2012-08-22 03:44:30 +00:00
parent 801b2485f4
commit 0ca3bbc848

View File

@ -100,14 +100,12 @@ bool FileImpl::canReadImpl() const
struct stat st;
if (stat(_path.c_str(), &st) == 0)
{
if (geteuid() == 0)
return true;
else if (st.st_uid == geteuid())
if (st.st_uid == geteuid())
return (st.st_mode & S_IRUSR) != 0;
else if (st.st_gid == getegid())
return (st.st_mode & S_IRGRP) != 0;
else
return (st.st_mode & S_IROTH) != 0;
return (st.st_mode & S_IROTH) != 0 || geteuid() == 0;
}
else handleLastErrorImpl(_path);
return false;
@ -121,14 +119,12 @@ bool FileImpl::canWriteImpl() const
struct stat st;
if (stat(_path.c_str(), &st) == 0)
{
if (geteuid() == 0)
return true;
else if (st.st_uid == geteuid())
if (st.st_uid == geteuid())
return (st.st_mode & S_IWUSR) != 0;
else if (st.st_gid == getegid())
return (st.st_mode & S_IWGRP) != 0;
else
return (st.st_mode & S_IWOTH) != 0;
return (st.st_mode & S_IWOTH) != 0 || geteuid() == 0;
}
else handleLastErrorImpl(_path);
return false;