![]() Registered Member ![]()
|
I've run into an odd requirement... I need some of my users to be able to edit text files as root and I can assure you that they are NOT going to learn to use the command line. In short, I need to be able to open Kate with superuser privileges. I'm running Debian Squeeze with KDE 4.3.4.
|
![]() Administrator ![]()
|
Running Kate as follows should work fine. Note that sudo won't work, and will cause all manner of errors. KDESu probably won't work properly either ( haven't tested )
I'm assuming the users can handle entering the password into a command line prompt... You could also try KDESu, not sure if it will probably clear the environment variables.
If you have an operational PolicyKit installation, then you could use that also.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
kdesu doesn't work; I'll try policykit tomorrow morning. How come I can't just open Konqueror as root and open the file from there? It worked fine on Lenny with 3.5. When I do it on Squeeze with 4.3 I get the following:
KDEInit could not launch /usr/bin/kate. I would think the ability to open a file as root using graphical utilities falls under the heading of basic functionality. |
![]() Administrator ![]()
|
It all depends on *how* you run as root. The trick is to have a clean environment so that your root applications do not try to access your normal user D-Bus session bus. Neither sudo or kdesu seem to clean the envrionment properly unfortunately... "su -" however will clean the environment properly.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
No go; here's what I got:
|
![]() Administrator ![]()
|
You may wish to try using the "su -c" solution instead in this case. You could use a setsuid launcher to run that if they don't know the root password, or you could use sudo to run it...
"sudo su -c /usr/bin/kate"...
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
That worked, thanks. I'm setting up a graphical app launcher for it. I have to say, however, that this is a second-best solution. What I really want (and I know this is probably getting to be an old song and dance) is to be able to do what I was able to do in KDE 3.
|
![]() Administrator ![]()
|
This is the primary reason behind motivating for implementation of PolicyKit and KAuth in KDE applications, as it would allow them to gain privileges for the saving and reading parts only, ensuring optimal security.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
I understand, and I'm all about security. But I've also been running Linux systems for other users long enough to know when to budge. The young lady in question is smart, trustworthy, and reasonably adept with computers. But like most modern young computer users she thinks it's absolutely absurd to not be able to get into whatever she wants using the mouse. I think I might have found a solution, though. I can open Kwrite as root using Krusader (and although Kwrite is the default I can probably figure out how to make it Kate), but I'm new to Krusader and not quite ready to install it on a production machine. I'm liking it, however. It's a really cool bit of software.
|
![]() Registered Member ![]()
|
Well, I agree to both sides: there are security issues running editors as root. However, there are also situations where it is inadequate to restrict the possibility of running the editor as root in a hard-coded way. The decision should be up to the respective administrator. if you don't have time to edit the kate sources and recompile it, you can "solve" the problem the hard way by patching kate and kwrite. They have both a few lines of code directly at the start of the "main" function:
OK, so look in the executable binaries where you find the call to getuid():
and search for getuid (by typing /getuid). You'll find some lines like this:
Now search where the address (in this case 275d8) is called, by typing /275d8 (all within 'less'). You'll find it shortly after the start of the main function (or _start):
Here the program calls getuid(), tests the result in %eax, and if it's zero (i.e. the program runs as root) it jumps to the error routine. Open the kate binary in a hex editor and replace the "je" instruction with "nop" instructions (0x90):
Et voilà, kate runs as root again. Patching kwrite works in the same way. |
![]() Registered Member ![]()
|
That check was added only a few months ago though: https://cgit.kde.org/kate.git/commit/?i ... 46b0e12a7e (first included in 17.04.0) Please note that this thread is 7 years old. Kate did not actively refuse to run as root back then. (and btw, I never had problems to run it with kdesu here) |
![]() Registered Member ![]()
|
Thank you for showing how to do this, I learned a lot. However, I could not get a nop instruction to work. Instead, I changed to JNE (0x0F 85) although then only root can run the editor, but that's fine for my use case, and it worked. |
![]() Registered Member ![]()
|
run Kate as root:
SUDO_EDITOR=kate sudoedit /etc/sudoers SUDO_EDITOR=kate sudoedit %f export SUDO_EDITOR=kate |
![]() Registered Member ![]()
|
I use 2 editors, Kate and the, so I tucked this into my .bashrc file:
# Use The Hessling Editor (the) as the default editor- rcb 9/15/07 #export EDITOR="/usr/bin/xthe -X textCursor vertical -w 1200" export EDITOR="/usr/bin/the -w 7000" #export EDITOR="/usr/bin/gedit" #export EDITOR="/usr/bin/kate" export KEDITOR="/usr/bin/kate" # Editor to use with sudoedit command for root files Updated 2017-11-16 @ 12:24:43 MST by rob@fargo export SUDO_EDITOR="/usr/bin/kate" # Use this alias to use the as the editor for root files: Updated 2017-11-16 @ 12:32:49 MST by rob@fargo alias xsudoedit='SUDO_EDITOR=$EDITOR && sudoedit' alias xse=xsudoedit # Use this alias to use kate as the editor for root files: Updated 2017-11-16 @ 12:32:49 MST by rob@fargo alias ksudoedit='SUDO_EDITOR=$KEDITOR && sudoedit' alias kse=ksudoedit So in Konsole I can issue (1) kse file_id or (2) xse file_id. Life is good...
Migrated from Linux Mint 17.3/18.3 KDE to KDE neon User Edition.
|
![]() Registered Member ![]()
|
you don't seem to know what a good life is. in Puppy-Linux, you almost never ever enter a password at all, since all is run as root. So, this should mean they must all have malwares and destruction. But no, those Puppy users really have a good life whereas us KDE folks usually have a PITA system entering passwords 100 times a day and its only getting worse. ![]() ![]() ![]() ![]() ![]() |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]