From c189f87d57844a13619ec387916f49aba171c1b3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Jan 2014 08:12:28 +0100 Subject: flock() the file edited in edit-sources --- apt-private/private-sources.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apt-private/private-sources.cc') 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( -- cgit v1.2.3