Author Topic: [SOLVED] Running command as root on KDE user login?  (Read 1619 times)

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
[SOLVED] Running command as root on KDE user login?
« on: June 09, 2011, 06:24:03 AM »
Seems simple, but I cannot seem to work it out:

How do I run a command with root privileges on KDE start-up, when a normal user logs on to KDE - without the user being prompted for the user password?
(Obviously, this should be the only exception and the user should not have root privileges in general.)

Cheers!
CJ
« Last Edit: June 12, 2011, 10:57:31 AM by CJ »

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8821
  • Aurum nostrum non est aurum vulgi.
Re: Running command as root on KDE user login?
« Reply #1 on: June 09, 2011, 06:33:35 AM »
The command on a konsole is $ su - followed by your root password.

HTH
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #2 on: June 09, 2011, 06:57:39 AM »
The command on a konsole is $ su - followed by your root password.

HTH

I think you misunderstood.... I need an autostart under KDE - not a root login.

Cheers!
CJ

Offline menotu

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 15506
  • ┌∩┐(◕_◕)┌∩┐
Re: Running command as root on KDE user login?
« Reply #3 on: June 09, 2011, 07:07:22 AM »
The command on a konsole is $ su - followed by your root password.

HTH

I think you misunderstood.... I need an autostart under KDE - not a root login.

Cheers!
CJ



Do you mean auto login - i.e. straight to the desktop by-passing the login screen?  If so go to

PCC (Configure Your Computer) >> Boot >> Setup Autologin..........

Select the Yes "radio" button and also choose which User to autologin
« Last Edit: June 09, 2011, 07:09:04 AM by menotu »
PCLinuxOS 32bit KDE 4.10.4; kernel-3.4.11-pclos1.bfs & 64bit 3.4.38bfs; NVidia GeForce 8400GS 1GB 310.19 driver

Sony Vaio SVE1513A4ESI Laptop, Intel Core i5, 2.6GHz, 6GB RAM, 750GB, 15.6" Intel HD Graphics 4000

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #4 on: June 09, 2011, 07:15:13 AM »
Ok, it seems that I have an issue explaining what I wish for...  ::)

Let me try again:
You know how you can simply put a command in ~/.kde/Autostart, right...?
I would like to have a command in there, though instead of running the command as the user logging in, it should be run as root. So far so easy... my stumbling block is to somehow suppress the need for the user logging in supplying a root password (in this instance only).

How can I set this up? Or is there a better way?
(rc.d won't do for me as I need it run on KDE start-up.)

Hope this is clearer...
Cheers!
CJ

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: Running command as root on KDE user login?
« Reply #5 on: June 09, 2011, 07:32:01 AM »
Hi CJ,

the simplest way is to set the stikcky bit on the executable: let the program you need to start is test-program:

chown root:root test-program
chmod 4777 test-program

ls -l test-program:
-rwsrwxrwx 1 root root 0 Jun  9 15:25 test-program

the above, may be a security risk, that's the reason it's normally not used.

AS

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #6 on: June 09, 2011, 07:49:11 AM »
as, than you so much for this, it seemed to have done the trick nicely.

... BUT ... (and isn't there always one?)

strange things are happening with root after this:
If I try to run e.g. 'kdesu dolphin', nothing happens.

I can su fine, but trying to start dolphin from the terminal fails too:
Code: [Select]
[root@MEDIA media]# dolphin
unnamed app(11468): KUniqueApplication: Cannot find the D-Bus session server:  "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken."

unnamed app(11467): KUniqueApplication: Pipe closed unexpectedly.

I can run other apps from su, e.g. firefox. The issue seems to be specific to dolphin, although only as root (it runs fine as user).

Any ideas on this one?

Cheers!
CJ

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: Running command as root on KDE user login?
« Reply #7 on: June 09, 2011, 08:07:52 AM »
as, than you so much for this, it seemed to have done the trick nicely.

... BUT ... (and isn't there always one?)

strange things are happening with root after this:
If I try to run e.g. 'kdesu dolphin', nothing happens.

CJ,

please expand "after this", or explain what you are trying to do.

as far as I can tell dolphin run quite well on my system, I don't see any relation between the sticky command and dolphin,
unless ... unless you are doing strange things inside the command (i.e. disabling services ... or don't know what).

AS

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #8 on: June 09, 2011, 10:29:10 AM »
Whatever the issue might have been, I have not been able to re-create after a reboot, so I shall chance it and assume that it was a glitch.

as, you have, again, been most helpful, cheers for that!
CJ

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: [SOLVED] Running command as root on KDE user login?
« Reply #9 on: June 09, 2011, 10:44:19 AM »
Glad to help!  ;)

AS

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: [SOLVED] Running command as root on KDE user login?
« Reply #10 on: June 11, 2011, 09:20:39 AM »
as, seems like I spoke too soon, as it will not run it with root permissions.
Code: [Select]
FATAL: Error removing rt61pci (/lib/modules/2.6.38.8-pclos1.bfs/kernel/drivers/net/wireless/rt2x00/rt61pci.ko.gz): Operation not permitted
Code: [Select]
ls -l
total 4
-rwsrwxrwx 1 root root 327 Jun 11 16:18 rt61pci.desktop*

(For your information, I am trying to get it to run 'modprobe -r rt61pci'.)

Any ideas as to what I am doing wrong?

Cheers!
CJ

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: [SOLVED] Running command as root on KDE user login?
« Reply #11 on: June 11, 2011, 09:31:27 AM »
as, seems like I spoke too soon, as it will not run it with root permissions.
Code: [Select]
FATAL: Error removing rt61pci (/lib/modules/2.6.38.8-pclos1.bfs/kernel/drivers/net/wireless/rt2x00/rt61pci.ko.gz): Operation not permitted
Code: [Select]
ls -l
total 4
-rwsrwxrwx 1 root root 327 Jun 11 16:18 rt61pci.desktop*

(For your information, I am trying to get it to run 'modprobe -r rt61pci'.)

Any ideas as to what I am doing wrong?

Cheers!
CJ


it doesn't work because probably the module is in use, or other modules depends from that modules ...
what you need to do ? to change wireless device ?

AS

Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #12 on: June 11, 2011, 10:34:16 AM »
That cannot be the whole story as I can sign in as root and do it without the error.

(For what I want to to, see this thread - I have all but given up getting a solution to that, bar what I am trying to do here, as that work: http://www.pclinuxos.com/forum/index.php?topic=91513.new;topicseen#new).

Cheers!
CJ

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: Running command as root on KDE user login?
« Reply #13 on: June 11, 2011, 10:44:11 AM »
From  the link seems you are using kernel 2.6.38.6 ?
- did you tried to upgrade kernel ?

- how about the wireless signal ? low ? have you tried to lower the card rate ?
   iwconfig wlan2 rate 12M


Offline CJ

  • Sr. Member
  • ****
  • Posts: 456
Re: Running command as root on KDE user login?
« Reply #14 on: June 11, 2011, 12:57:17 PM »
From  the link seems you are using kernel 2.6.38.6 ?
- did you tried to upgrade kernel ?

- how about the wireless signal ? low ? have you tried to lower the card rate ?
   iwconfig wlan2 rate 12M

as, thank you for your suggestions. To answer, I have tried with different newer and older kernels, same same.
As for the rate, yes - but I cannot think it relevant as this card works fine - just in periods is does not 'stick'.
Actually, since my last post on that thread, I have done a complete reinstall, with no improvement to the situation.

Also, don't miss the elephant in the room: a simple 'modprobe -r rt61pci' always works, so...:

If you wouldn't mind, I would like to keep this thread confined to the subject of running my modprobe command on KDE start-up (with the needed root priviledges). You are most welcome to post in the other thread if you have any of your usual good ideas, but frankly, I am so fed-up with this card by now that if I can just get this command to work, it shall settle it for me and be done with!

Once again, thanks for taking the time to help, as - you are always so helpful!
CJ