LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-20-2018, 09:27 PM   #1
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Is it possible to get a login shell with kdesu?


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:

Quote:
gksu is being replaced by gksu PolicyKit, please take a look at http://live.gnome.org/gksu.
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?
 
Old 10-20-2018, 10:18 PM   #2
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

Rep: Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435
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.
 
Old 10-20-2018, 10:36 PM   #3
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,902

Rep: Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052
I believe what you want is:

Code:
kdesu -c "/bin/bash --login -c konsole"
The only problem I see with this is if the KDE series is omitted during installation. It might be best to use xterm.

Source: https://forum.kde.org/viewtopic.php?f=66&t=90948

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.

Last edited by mralk3; 10-20-2018 at 10:39 PM.
 
1 members found this post helpful.
Old 10-20-2018, 10:37 PM   #4
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by enorbet View Post
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.
 
Old 10-20-2018, 10:57 PM   #5
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
I haven't used gksu in a long time, but I can get a graphical prompt for a root login shell with ktsuss. I imagine similar would work with gksu?

Code:
$ ktsuss bash -l
http://slackbuilds.org/repository/14.2/system/ktsuss/
 
1 members found this post helpful.
Old 10-20-2018, 11:11 PM   #6
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by montagdude View Post
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
 
2 members found this post helpful.
Old 10-20-2018, 11:24 PM   #7
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by mralk3 View Post
I believe what you want is:

Code:
kdesu -c "/bin/bash --login -c konsole"
The only problem I see with this is if the KDE series is omitted during installation. It might be best to use xterm.

Source: https://forum.kde.org/viewtopic.php?f=66&t=90948
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 View Post
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.
 
1 members found this post helpful.
Old 10-20-2018, 11:42 PM   #8
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by ehartman View Post
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.
 
1 members found this post helpful.
Old 10-20-2018, 11:52 PM   #9
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by orbea View Post
I haven't used gksu in a long time, but I can get a graphical prompt for a root login shell with ktsuss. I imagine similar would work with gksu?

Code:
$ ktsuss bash -l
http://slackbuilds.org/repository/14.2/system/ktsuss/
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:

Code:
kdesu -c "xterm -ls -e /usr/sbin/sboui"
kdesu -c "/bin/bash -l -c 'xterm -e /usr/sbin/sboui'"

Last edited by montagdude; 10-21-2018 at 12:09 AM.
 
1 members found this post helpful.
Old 10-21-2018, 12:04 AM   #10
Gordie
Member
 
Registered: Aug 2007
Location: Nolalu, Ontario, Canada
Distribution: Slackware64-Current
Posts: 871

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
The -ls option works for terminator also

Last edited by Gordie; 10-21-2018 at 12:08 AM.
 
1 members found this post helpful.
Old 10-21-2018, 12:07 AM   #11
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
To add to my confusion, the -l option in bash seems to be doing something, at least judging by the prompt.

Code:
# kdesu -c "/bin/bash -c xterm"
# (Prompt in new terminal window)
bash4.3#
Code:
# kdesu -c "/bin/bash -l -c xterm"
# (Prompt in new terminal window)
root@Thinkpad-T430:/home/dan#
So it definitely does something, but what it is doing, I am not sure.
 
Old 10-21-2018, 12:09 AM   #12
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by Gordie View Post
The ls option works for terminator also
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.
 
1 members found this post helpful.
Old 10-21-2018, 12:24 AM   #13
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Sorry for all the posts in a row, but I think I have found the magic combination:

Code:
kdesu -c "xterm -e /bin/bash -l"
This gives a login shell in a new window even if you substitute xterm with konsole, xfce4-terminal, rxvt, etc. To launch sboui, I can do this:

Code:
kdesu -c "xterm -e /bin/bash -l -c /usr/sbin/sboui"
I apologize if someone intended this method without spelling it out explicitly, and I was too slow to get it the first time.

Last edited by montagdude; 10-21-2018 at 12:31 AM.
 
3 members found this post helpful.
Old 10-21-2018, 05:15 AM   #14
gegechris99
Senior Member
 
Registered: Oct 2005
Location: France
Distribution: Slackware 15.0 64bit
Posts: 1,161
Blog Entries: 5

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
For konsole, I had to add the --nofork option to make it work as per the guidance at end of "konsole --help".

Here's an example to launch sbopkg:
Code:
kdesu -c "konsole --nofork -e /bin/bash -l -c /usr/sbin/sbopkg"
 
1 members found this post helpful.
Old 10-21-2018, 11:32 AM   #15
Gordie
Member
 
Registered: Aug 2007
Location: Nolalu, Ontario, Canada
Distribution: Slackware64-Current
Posts: 871

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
Quote:
Originally Posted by montagdude View Post
Sorry for all the posts in a row, but I think I have found the magic combination:

Code:
kdesu -c "xterm -e /bin/bash -l"
This gives a login shell in a new window even if you substitute xterm with konsole, xfce4-terminal, rxvt, etc. To launch sboui, I can do this:

Code:
kdesu -c "xterm -e /bin/bash -l -c /usr/sbin/sboui"
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
don't run kdesu krusader or kdesu kuser infoslaw Linux - Desktop 7 10-11-2016 03:45 AM
Login Shell / Non-Login shell Clarification needed (RHEL 6.3) kingston Linux - Newbie 1 12-07-2012 12:51 AM
Difference between normal shell and login shell Manish Linux - General 7 11-14-2012 08:30 AM
[SOLVED] strace kdesu konqueror & > ./strace_kdesu (diagnosing failing kdesu) GrapefruiTgirl Linux - Desktop 23 11-02-2009 05:03 PM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 08:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration