summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-06 08:12:28 +0100
committerMichael Vogt <mvo@debian.org>2014-01-06 08:12:28 +0100
commitc189f87d57844a13619ec387916f49aba171c1b3 (patch)
tree350522c67a1657c609073fff9d5521d4c3cb05ed /apt-private
parent74d4bb26e09146b9d5f01889a676dc58ff5d63cd (diff)
flock() the file edited in edit-sources
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-sources.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
index 65706e785..41cf6b313 100644
--- a/apt-private/private-sources.cc
+++ b/apt-private/private-sources.cc
@@ -32,6 +32,10 @@ bool EditSources(CommandLine &CmdL)
if (FileExists(sourceslist))
before.FromFile(sourceslist);
+ int lockfd = GetLock(sourceslist);
+ if (lockfd < 0)
+ return false;
+
do {
EditFileInSensibleEditor(sourceslist);
_error->PushToStack();
@@ -46,6 +50,7 @@ bool EditSources(CommandLine &CmdL)
}
_error->RevertToStack();
} while (res == false);
+ close(lockfd);
if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
strprintf(