/*
- * Copyright (c) [2004-2012] Novell, Inc.
+ * Copyright (c) [2004-2013] Novell, Inc.
*
* All Rights Reserved.
*
AsciiFileReader::AsciiFileReader(const string& filename)
: file(NULL), buffer(NULL), len(0)
{
- file = fopen(filename.c_str(), "r");
+ file = fopen(filename.c_str(), "re");
if (file == NULL)
{
y2war("open for '" << filename << "' failed");
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino))
return true;
- int fd1 = file1.open(O_RDONLY | O_NOFOLLOW | O_NOATIME);
+ int fd1 = file1.open(O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC);
if (fd1 < 0)
{
y2err("open failed path:" << file1.fullname() << " errno:" << errno);
return false;
}
- int fd2 = file2.open(O_RDONLY | O_NOFOLLOW | O_NOATIME);
+ int fd2 = file2.open(O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC);
if (fd2 < 0)
{
y2err("open failed path:" << file2.fullname() << " errno:" << errno);
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
SDir info_dir = SDir(infos_dir, decString(num2));
int fd = info_dir.open("filelist-" + decString(num1) + ".txt", O_RDONLY | O_NOATIME |
- O_NOFOLLOW);
+ O_NOFOLLOW | O_CLOEXEC);
if (fd == -1)
return false;
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
bool
File::createFile(mode_t mode, uid_t owner, gid_t group) const
{
- int src_fd = open(getAbsolutePath(LOC_PRE).c_str(), O_RDONLY | O_LARGEFILE);
+ int src_fd = open(getAbsolutePath(LOC_PRE).c_str(), O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (src_fd < 0)
{
y2err("open failed errno:" << errno << " (" << stringerror(errno) << ")");
}
int dest_fd = open(getAbsolutePath(LOC_SYSTEM).c_str(), O_WRONLY | O_LARGEFILE |
- O_CREAT | O_TRUNC, mode);
+ O_CREAT | O_TRUNC | O_CLOEXEC, mode);
if (dest_fd < 0)
{
y2err("open failed errno:" << errno << " (" << stringerror(errno) << ")");
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
SDir::SDir(const string& base_path)
: base_path(base_path), path()
{
- dirfd = ::open(base_path.c_str(), O_RDONLY | O_NOATIME);
+ dirfd = ::open(base_path.c_str(), O_RDONLY | O_NOATIME | O_CLOEXEC);
if (dirfd < 0)
{
y2err("open failed path:" << base_path << " error:" << stringerror(errno));
SDir::SDir(const SDir& dir, const string& name)
: base_path(dir.base_path), path(dir.path + "/" + name)
{
- dirfd = ::openat(dir.dirfd, name.c_str(), O_RDONLY | O_NOFOLLOW | O_NOATIME);
+ dirfd = ::openat(dir.dirfd, name.c_str(), O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC);
if (dirfd < 0)
{
y2err("open failed path:" << dir.fullname(name) << " (" << stringerror(errno) << ")");
v /= 62;
}
- int fd = open(name, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ int fd = open(name, O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, S_IRUSR | S_IWUSR);
if (fd >= 0)
return fd;
else if (errno != EEXIST)
/*
- * Copyright (c) [2004-2012] Novell, Inc.
+ * Copyright (c) [2004-2013] Novell, Inc.
*
* All Rights Reserved.
*
boost::lock_guard<boost::mutex> lock(mutex);
- FILE* f = fopen(filename->c_str(), "a");
+ FILE* f = fopen(filename->c_str(), "ae");
if (f)
{
string tmp = text;
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
try
{
SDir info_dir(infos_dir, *it1);
- int fd = info_dir.open("info.xml", O_NOFOLLOW);
+ int fd = info_dir.open("info.xml", O_NOFOLLOW | O_CLOEXEC);
XmlFile file(fd, "");
const xmlNode* root = file.getRootElement();