From: Marcin Niesluchowski Date: Wed, 18 Jun 2014 12:44:24 +0000 (+0200) Subject: Revert "Fix memory leak and add EINTR error handling." X-Git-Tag: submit/rv/20140618.160634~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=712e8555fa8a8f80506e43ea25a9a6320bad2c35;p=platform%2Fcore%2Fsecurity%2Fsecurity-server.git Revert "Fix memory leak and add EINTR error handling." This revert is due to moving security-manager to separate repository This reverts commit 2c9421804005c397d53911199b1817204261ed33. Change-Id: Ia99d6f501291c5ccf6707fa14281366cc8bd2df3 --- diff --git a/src/server/service/installer.cpp b/src/server/service/installer.cpp index 90608d7..92d98ad 100644 --- a/src/server/service/installer.cpp +++ b/src/server/service/installer.cpp @@ -100,25 +100,24 @@ FileDecision labelLinksToExecs(const FTSENT *ftsent) LogSecureDebug("Entering function: " << __func__); struct stat buf; + char *target; // check if it's a link if ( !S_ISLNK(ftsent->fts_statp->st_mode)) return FileDecision::SKIP; - std::unique_ptr> target(realpath(ftsent->fts_path, NULL), free); - - if (!target.get()) { + target = realpath(ftsent->fts_path, NULL); + if (!target) { LogSecureError("Getting link target for " << ftsent->fts_path << " failed (Error = " << strerror(errno) << ")"); return FileDecision::ERROR; } - - if (-1 == stat(target.get(), &buf)) { - LogSecureError("stat failed for " << target.get() << " (Error = " << strerror(errno) << ")"); + if (-1 == stat(target, &buf)) { + LogSecureError("stat failed for " << target << " (Error = " << strerror(errno) << ")"); return FileDecision::ERROR; } // skip if link target is not a regular executable file if (buf.st_mode != (buf.st_mode | S_IXUSR | S_IFREG)) { - LogSecureDebug(target.get() << "is not a regular executable file. Skipping."); + LogSecureDebug(target << "is not a regular executable file. Skipping."); return FileDecision::SKIP; } diff --git a/src/server/service/smack-rules.cpp b/src/server/service/smack-rules.cpp index 687795e..4319ca9 100644 --- a/src/server/service/smack-rules.cpp +++ b/src/server/service/smack-rules.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include @@ -75,7 +74,7 @@ bool SmackRules::loadFromFile(const std::string &path) int fd; bool ret = true; - fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY)); + fd = open(path.c_str(), O_RDONLY); if (fd == -1) { LogError("Failed to open file: %s" << path); return false; @@ -86,11 +85,7 @@ bool SmackRules::loadFromFile(const std::string &path) ret = false; } - if (close(fd) == -1) { - // don't change the return code, the descriptor should be closed despite the error. - LogWarning("Error while closing the file: " << path << ", error: " << strerror(errno)); - } - + close(fd); return ret; } @@ -99,7 +94,7 @@ bool SmackRules::saveToFile(const std::string &path) const int fd; bool ret = true; - fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0644)); + fd = open(path.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0644); if (fd == -1) { LogError("Failed to create file: %s" << path); return false; @@ -111,18 +106,7 @@ bool SmackRules::saveToFile(const std::string &path) const ret = false; } - if (close(fd) == -1) { - if (errno == EIO) { - LogError("I/O Error occured while closing the file: " << path << ", error: " << strerror(errno)); - unlink(path.c_str()); - return false; - } else { - // non critical error - // don't change the return code, the descriptor should be closed despite the error. - LogWarning("Error while closing the file: " << path << ", error: " << strerror(errno)); - } - } - + close(fd); return ret; }