martinkostolny updated this revision to Diff 12309.
martinkostolny added a comment.


  Good point! I was about to say that the target folder is in most cases 
non-writable without elevated privileges. But we can actually use KAuth action 
twice, for 2 simple jobs:
  
  1. Create temporary file right next to target file, set current user as 
owner, so it is writable without root privileges.
  2. And after storing file contents outside kauth helper binary. atomically 
rename the temporary file.
  
  Any objections against using 2 actions? KAuth action session ensures that 
user is asked for password only first time using a KAuth action.
  
  I've used QTemporaryFile(filename) (instead of "xxx.tmp") so Qt took care of 
uniqueness of filename.
  
  Another note: I didn't call windows specific atomic rename method because I 
cannot test it on my machine. So on windows QSaveFile fallback is used for now.

REPOSITORY
  R39 KTextEditor

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D4847?vs=12272&id=12309

REVISION DETAIL
  https://phabricator.kde.org/D4847

AFFECTED FILES
  autotests/src/katetextbuffertest.cpp
  autotests/src/katetextbuffertest.h
  src/CMakeLists.txt
  src/buffer/katesecuretextbuffer.cpp
  src/buffer/katesecuretextbuffer_p.h
  src/buffer/katetextbuffer.cpp
  src/buffer/katetextbuffer.h
  src/buffer/org.kde.ktexteditor.katetextbuffer.actions

To: martinkostolny, dhaumann, #ktexteditor
Cc: apol, dfaure, anthonyfieroni, cullmann, ltoscano, dhaumann, graesslin, 
davidedmundson, palant, kwrite-devel, #frameworks, head7, kfunk, sars

Reply via email to