[SOLVED] Is it possible to get a login shell with kdesu?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you do, for example, `kdesu -c xterm`, you get a shell with root privileges that seems to have the same environment as just typing `su` from a regular shell. On the other hand, gksu (available on SBo) has a login shell option, which seems to work as advertised, but I don't see any option like that with kdesu.
The reason I ask is that I would like to add a .desktop file for sboui that will allow it to be launched from the menu as a regular user, with something like kdesu or gksu to give root privileges. As I understand it, it is recommended to run SBo scripts as root with a login shell. If kdesu can do this, then I won't have to add gksu as a dependency. Also, the gksu homepage has this in bold letters at the top:
which doesn't give me a warm fuzzy feeling about depending on it. The link points to nothing, by the way, which makes me even more uneasy about it. Are there any other tools like this that support login shells?
There are several apps that I need to run as root fairly often and I do this with kdesu in two different ways, depending I suppose on how often I need such things. For example I use Dolphin in root mode very often, some days many times in that day so I have a Launcher on the Taskbar Panel where I've set the command as "kdesu dolphin". Other items that I might need a little less often I use Krunner so that after it's been run once it is kept in Command History and readily accessible. I don't prefer xterm so I don't know about it but I do know that both Konsole and Eterm work properly with kdesu.
BTW daughter apps called by a parent launched by kdesu also have root privileges so for example if I launch "kdesu dolphin" and view a text file like /etc/fstab even the "Open With..." menuitem launches my choice as root so calling KWrite will allow edits of (in this example) fstab.
I use sudo since I do not install KDE. I know it's probably better to design sboui to expect a full slackware installation. I think in any case, sudo is almost always installed for most people.
There are several apps that I need to run as root fairly often and I do this with kdesu in two different ways, depending I suppose on how often I need such things. For example I use Dolphin in root mode very often, some days many times in that day so I have a Launcher on the Taskbar Panel where I've set the command as "kdesu dolphin". Other items that I might need a little less often I use Krunner so that after it's been run once it is kept in Command History and readily accessible. I don't prefer xterm so I don't know about it but I do know that both Konsole and Eterm work properly with kdesu.
BTW daughter apps called by a parent launched by kdesu also have root privileges so for example if I launch "kdesu dolphin" and view a text file like /etc/fstab even the "Open With..." menuitem launches my choice as root so calling KWrite will allow edits of (in this example) fstab.
Hi, thanks for the response, but I think you misunderstood the question. The question is not whether xterm or any other particular terminal emulator can be run with kdesu; I already know that they work fine. I am looking specifically for an option with kdesu that will run the application as root in a login shell. I don't think such an option exists, but maybe there is another way to achieve the same effect? Otherwise, I think gksu is my only choice.
If you do, for example, `kdesu -c xterm`, you get a shell with root privileges that seems to have the same environment as just typing `su` from a regular shell. On the other hand, gksu (available on SBo) has a login shell option, which seems to work as advertised, but I don't see any option like that with kdesu.
As kdesu is just a front over su, it doesn't run a "shell" to make into a login shell, it just executes its argument(s).
So the "login shell" option is to be specified for whatever kdesu will be executing.
I.e. with kdesu xterm, you use the -ls (login shell) option to xterm, not anything special to kdesu, as there xterm will be starting a shell (so:
kdesu -> xterm -> shell
Okay, that sounds promising. I'm not totally sure if it is giving me a proper login shell, however. For example, shopt seems to indicate it's not a login shell:
Code:
# shopt | grep login_shell
login_shell off
But then again, according to that test gksu with the -l option is also not a login shell, so maybe that's not the right way to check. Perhaps a more fundamental question to ask is, why do SBo scripts need to be run from a login shell?
Quote:
Originally Posted by mralk3
It might be good to consider this as well:
Code:
sudo -i xterm
I use sudo since I do not install KDE. I know it's probably better to design sboui to expect a full slackware installation. I think in any case, sudo is almost always installed for most people.
Does sudo work for launching graphical applications? The point here is to put this in a .desktop file so that users can launch sboui from the application menu or application launcher. If I were going to use sudo (not my preference anyway) I think it would have to be something like kdesudo or gksudo. The command I had in mind is something like this:
Code:
gksu -l 'xterm -e /usr/sbin/sboui'
The terminal emulator to use could be configured as an option when during build time.
As kdesu is just a front over su, it doesn't run a "shell" to make into a login shell, it just executes its argument(s).
So the "login shell" option is to be specified for whatever kdesu will be executing.
I.e. with kdesu xterm, you use the -ls (login shell) option to xterm, not anything special to kdesu, as there xterm will be starting a shell (so:
kdesu -> xterm -> shell
Okay, this option definitely seems to work. Executing `kdesu -c "xterm -ls"` opens an xterm window that prints out a quote from fortune (a good sign) and passes the shopt login_shell test. Looks like the -ls option is at least available in xterm, rxvt, and rxvt-unicode, but not in konsole or xfce4-terminal, unfortunately.
Thank you for the clarification as well.
I would mark this as solved, but I would still like to find out if there is a method that will also work for konsole and xfce4-terminal.
Last edited by montagdude; 10-20-2018 at 11:54 PM.
Okay, so this does work to get me a login shell in the existing terminal window. However, for the purposes of launching a new terminal window from a .desktop file, I need something like this:
Code:
ktsuss "bash -l -c xterm"
When I do that, the resulting terminal window does not seem to be in a login shell. At least, shopt reports login_shell off and I don't get a fortune. So far, ehartman's approach is the only one that seems to work.
By the way, I hope this is not too confusing, but the eventual command that will go in sboui.desktop will of course have to invoke sboui, so it would be something like one of these variants:
Okay, that is good to know. Worst case scenario, I can make the terminal emulator an option at build time and write in the README that it needs to be one that supports the -ls option in order to launch it using the .desktop file. Of course, the .desktop file is only intended to be a convenience anyway, so I don't think it's critical to support every terminal emulator.
Last edited by montagdude; 10-21-2018 at 12:12 AM.
I apologize if someone intended this method without spelling it out explicitly, and I was too slow to get it the first time.
Well, somewhere along the line terminator got left behind in all this. I substitute terminator and nothing happens. Oh well, that is my preferred terminal emulator
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.