Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
- index dca468c..394bc77 100644
- --- a/apt-pkg/contrib/fileutl.cc
- +++ b/apt-pkg/contrib/fileutl.cc
- @@ -946,9 +946,6 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
- if ((Mode & Atomic) == Atomic)
- {
- Flags |= Replace;
- - char *name = strdup((FileName + ".XXXXXX").c_str());
- - TemporaryFileName = string(mktemp(name));
- - free(name);
- }
- else if ((Mode & (Exclusive | Create)) == (Exclusive | Create))
- {
- @@ -974,8 +971,20 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
- else if_FLAGGED_SET(Atomic, O_EXCL);
- #undef if_FLAGGED_SET
- - if (TemporaryFileName.empty() == false)
- - iFd = open(TemporaryFileName.c_str(), fileflags, Perms);
- + if ((Mode & Atomic) == Atomic)
- + {
- + char *name = strdup((FileName + ".XXXXXX").c_str());
- +
- + TemporaryFileName = string(name);
- +
- + // The file is created with permissions 0600, that is,
- + // read plus write for owner only.
- + if((iFd = mkostemp(name, fileflags)) == -1)
- + {
- + return FileFdError("Could not create temporary file for %s", FileName.c_str());
- + }
- + free(name);
- + }
- else
- iFd = open(FileName.c_str(), fileflags, Perms);
Advertisement
Add Comment
Please, Sign In to add comment