Logo Search packages:      
Sourcecode: yapet version File versions  Download package

void File::checkFileSecurity (  )  throw (YAPETException) [private]

Checks the permissions and owner of a file for security.

Checks the permission and owner of a file for security.

It throws a YAPETRetryException if the owner of the file does not match the uid of the owner of the process, or if the mode is not (S_IRUSR|S_IWUSR).

Definition at line 120 of file file.cc.

References fd, and filename.

Referenced by openCreate(), and openNoCreate().

#if defined(HAVE_FSTAT) && defined(HAVE_GETUID)
    struct stat buf;
    int err = fstat(fd, &buf);
    if (err == -1)
      throw YAPETException(strerror(errno));

    uid_t uid = getuid();

    if (buf.st_uid != uid) {
      std::string tmp(_("You are not the owner of ") );
      throw YAPETRetryException(tmp + filename);

    if (buf.st_mode != (S_IFREG | S_IRUSR | S_IWUSR) ) {
      std::string tmp1(_("Permissions of "));
      std::string tmp2(_(" not secure."));
      throw YAPETRetryException(tmp1 + filename + tmp2);

Generated by  Doxygen 1.6.0   Back to index