DeltaEscher / editra

Automatically exported from code.google.com/p/editra
Other
0 stars 0 forks source link

Feature Request : Ability to edit readonly files by authenticating #509

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open a file that is readonly 
2. You cannot make changes and save them

What is the expected output? What do you see instead?
I would not consider this a bug per say, but rather a feature request.  I am on 
Mac OSX, but I 
know Linux has a keychain system of sorts, I can't speak with any detail about 
windows.  On the 
Mac for instance, when a resource is locked, often the system will popup an 
authentication 
window to allow the user to authenticate as an admin acct.  I would assume that 
this feature is 
built into the OSX SDK APIS, though if I had to guess this is not an xcode app, 
so I don't know if 
this would be possible based on the chosen platform.  

For a bit of background on why I bring this up, I am often in the command line 
editing config 
files in various locations.  I liked the idea of being able to setup projets in 
Editra that would allow 
me to more efficiently manage and edit files such as apache conf files, php ini 
files, files in the 
/etc folder like the hosts, profile files etc.  Unfortunately since these files 
are readonly by default I 
can't use Editra for this without changing the rights on the files, which is in 
general not a good 
idea.

So, my suggestion would be to hook into the OSX auth mechanism that other apps 
make use of to 
authenticate for higher access to the resource.  I would imagine once the API 
function is found, 
it's probably not much more than calling it and inspecting the return result.

Thanks!

Great editor by the way...

Original issue reported on code.google.com by dlangh@gmail.com on 30 Apr 2010 at 3:42

GoogleCodeExporter commented 8 years ago
I am not sure about the authentication part of this as it may be difficult/not
possible to support it on all platforms. Nor do I know what apis are needed to
interface with that. 

Its possible that on Linux/OSX I could just prompt for the password and do an 
'su
chmod' when the file is first attempted to be modified and then change it back 
to its
original values when the buffer is destroyed. That seems to leave a few hazards 
open
though because if the program crashed or something they files would be left 
open.

I think that the best solution for files that require access to files owned by
another user is to run Editra as that user. If it is possible to elevate what 
user
the program is run as briefly it would be optimal, though again not sure on how 
this
is handled.

When I need to edit root owned files I usually start the program as root.

Original comment by CodyPrec...@gmail.com on 1 May 2010 at 3:12

GoogleCodeExporter commented 8 years ago
Your comments got me thinking and looking.  The best solution I found was to 
use sudo to execute Editra.

by doing this : 

echo "sudo password" | sudo -S /Applications/Editra.app/Contents/MacOSX/Editra

it will run editra as root.

What I haven't done yet is wrap that up into it's own script or executable so I 
am able to simply click on an 
icon in either Applications folder or elsewhere, but I know that is possible, 
possibly by using AppleScript to 
finish things up...

FYI, for anyone who may try this, you cannot do the following:

echo "sudo password" | sudo -S "open /Applications/Editra.app" 

it appears the open command ignores sudo and runs it as the default GUI user.  
You must dril into the app 
directly as my first example shows...

Thanks!  

Original comment by dlangh@gmail.com on 1 May 2010 at 5:26