xenoscopic / xeno

Synchronous remote file editing using SSH and Git
Other
94 stars 11 forks source link

Running $ sudo xeno edit $ always fails #7

Closed Miladiir closed 10 years ago

Miladiir commented 10 years ago

Here is what I did and what I got:

miladiir@server ~$ sudo edit some-file.txt
Warning: unknown mime-type for "some-file.txt" -- using "application/octet-stream"
Error: no "edit" mailcap rules found for type "application/octet-stream"

I tried messing around with my setup, however I couldn't get it working. As I have no root permissions but am able to sudo, it would be nice if xeno would allow this.

xenoscopic commented 10 years ago

I think you meant to type

sudo xeno edit some-file.txt

edit is something different on Linux and other systems which tries to open files using mailcap (see man edit). Anyway, try using xeno edit.

Also, you should not run xeno as root using sudo because it won't work for a variety of reasons (in particular, the synchronization won't work unless you normally log into the remote machine as root, which you should not do).

xenoscopic commented 10 years ago

I've closed this for now, but reopen if that doesn't help.

Miladiir commented 10 years ago

Oh sorry, I forgot to mention that I aliased edit to xeno edit.

xenoscopic commented 10 years ago

Well, judging by the error that it spit out, I would assume the original edit command is still coming through, because xeno knows nothing of mailcap and the original command would produce precisely the error you're seeing. What's probably happening is that when you type sudo, your alias is not respected (which is the default behavior) so it's going to the original edit command. Anyway, as I mentioned, there should be no need to run as root, and in fact you shouldn't, so try just using the edit alias you've created.

Miladiir commented 10 years ago

Well, now I feel stupid. But how would I use xeno and my text editor to edit files that require higher permission? For example, if I wanted to edit the configuration files of nginx, what would I need to configure additionally to make it work?

xenoscopic commented 10 years ago

Ah, I see your question. To be honest, I hadn't considered the use case of elevated privileges. The main issue is that xeno uses Git's SSH protocol as its synchronization mechanism, which requires being able to connect directly to the machine as root, not just initializing the sync as root. If you can log into the machine as root (which it sounds like you can't) then it would work. Given that you can't do that, the only thing I could think of doing would be adding yourself to a group that has permission on the file you want to access (probably root or wheel in your case) then you can just run xeno as your normal user and it should work.

Other than that, I'm afraid it's somewhat of a limitation of Git to be able to do cross-user (especially as root) synchronization. Perhaps one could do some SSH key magic, but I think that would lead to a really insecure setup...

xenoscopic commented 10 years ago

Just note that if you do add yourself to a group like that, you'll have to log-out and log-in before the effect will take place.

Miladiir commented 10 years ago

Thanks, I will look into doing something like that.