From: Michael Vogt Date: Mon, 6 Jan 2014 07:12:28 +0000 (+0100) Subject: flock() the file edited in edit-sources X-Git-Tag: 0.9.14.3.exp3~4^2~6 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/c189f87d57844a13619ec387916f49aba171c1b3?ds=inline flock() the file edited in edit-sources --- 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(