This forum has been archived. All content is frozen. Please use KDE Discuss instead.

sudoers or files in sudoers.d are not honored

Tags: None
(comma "," separated)
jonnycache
Registered Member
Posts
47
Karma
0
HI guys,

i try to unload an Module via "modprobe" and then reload it via modprobe. I have written a script and i want it to work without password as sudo.
The script is basic:
Code: Select all
#!/bin/bash
/bin/modprobe -r hid_multitouch
/bin/modprobe hid_multitouch


I putted the script in /sbin and gave the permissions 755 and
Code: Select all
chown root:root script


After that i modified the sudoers with:
Code: Select all
sudo visudo


The new line in the sudoers lookes like

Code: Select all
onny ALL=(root) NOPASSWD: /usr/sbin/modprobe


i also tried

Code: Select all
jonny ALL=(root) NOPASSWD: /sbin/script


but nothing worked for me. If i write in the shell
Code: Select all
script

I get

Code: Select all
/sbin/script: 2: modprobe: Permission denied
/sbin/script: 3: modprobe: Permission denied


I read here, that this is an special issue to KDE Neon.
https://bugs.kde.org/show_bug.cgi?id=407729
https://bugs.launchpad.net/ubuntu/+sour ... ug/1829609

Is there any solution?

Greetings

Jonny
User avatar
claydoh
Registered Member
Posts
1170
Karma
9
OS
jonnycache wrote:HI guys,

i try to unload an Module via "modprobe" and then reload it via modprobe. I have written a script and i want it to work without password as sudo.
The script is basic:
Code: Select all
#!/bin/bash
/bin/modprobe -r hid_multitouch
/bin/modprobe hid_multitouch

This is the wrong path to modprobe.
This will show the correct path to put in your script:
Code: Select all
$ which modprobe
/sbin/modprobe




I putted the script in /sbin and gave the permissions 755 and
Code: Select all
chown root:root script


After that i modified the sudoers with:
Code: Select all
sudo visudo


The new line in the sudoers lookes like

Code: Select all
onny ALL=(root) NOPASSWD: /usr/sbin/modprobe


/usr/sbin/modprobe is a different, but still incorrect path to modprobe. You need to put correct path in sudoers.

i also tried

Code: Select all
jonny ALL=(root) NOPASSWD: /sbin/script


but nothing worked for me. If i write in the shell
Code: Select all
script

I get

Code: Select all
/sbin/script: 2: modprobe: Permission denied
/sbin/script: 3: modprobe: Permission denied


I read here, that this is an special issue to KDE Neon.
https://bugs.kde.org/show_bug.cgi?id=407729
https://bugs.launchpad.net/ubuntu/+sour ... ug/1829609


These reports are about Neon having a different path to a specific command, not the sudoers file.



Greetings

Jonny[/quote]


claydoh, proud to be a member of KDE forums since 2008-Oct, and KDE user since 2001
User avatar
claydoh
Registered Member
Posts
1170
Karma
9
OS
Also, is this something you are trying to use to fix the multitouch after suspend/resume?
There are other ways to do this, without needing to manually run a script.


claydoh, proud to be a member of KDE forums since 2008-Oct, and KDE user since 2001
jonnycache
Registered Member
Posts
47
Karma
0
Hi claydoh

you're right i made a mistake, the right path must be
/sbin/modprobe

and it is in my script, but the permission is not granted at all.

you said:
"Also, is this something you are trying to use to fix the multitouch after suspend/resume?
There are other ways to do this, without needing to manually run a script."

That's the point, is there an other way to fix this? That would be really nice :)

Greeting

Jonny
User avatar
claydoh
Registered Member
Posts
1170
Karma
9
OS
I had to do something similar to this on my laptop, until the 20.04 upgrade, which fixed the issue on my particular hardware.

Open Kate or Kwrite ( or your favorite terminal editor with sudo)
Add this text:
Code: Select all
#!/bin/sh
if [ "${1}" == "pre" ]; then
  # Do the thing you want before suspend here, e.g.:
 modprobe -r hid_multitouch
elif [ "${1}" == "post" ]; then
  # Do the thing you want after resume here, e.g.:
  modprobe hid_multitouch
fi


Save As /lib/systemd/system-sleep/multitouch
Kate and Kwrite will prompt you for your password to save it.
Next, open a terminal and mark the file as executable:

Code: Select all
sudo chmod +x /lib/systemd/system-sleep/multitouch


And give it a try.



Reference:
https://blog.christophersmart.com/2016/ ... nt-page-1/
(note the file used is in a different location in this article than it is for Ubuntu based systems, I have given the correct location above)


claydoh, proud to be a member of KDE forums since 2008-Oct, and KDE user since 2001
jonnycache
Registered Member
Posts
47
Karma
0
THx a lot, I will do this tomorrow and i will report u if it workes. But I think, this will be the better solution!

Maybe i will ask you something, if its ok...

Have a nice day

Jonny
jonnycache
Registered Member
Posts
47
Karma
0
On the first view, it looks like it works. I mean the script.

But the other problem is, that i cant get make a skript with modprobe that works without the password.

Is there a way to unload a module for example in a script without sudo?

Greetings

Jonny
User avatar
claydoh
Registered Member
Posts
1170
Karma
9
OS
jonnycache wrote:On the first view, it looks like it works. I mean the script.

But the other problem is, that i cant get make a skript with modprobe that works without the password.

Is there a way to unload a module for example in a script without sudo?

Greetings

Jonny


It can only be done by setting up sudoers correctly, or having the script run automatically by a system level process, such as my example above, with Systemd.

I see I did not make it clear that my script, placed in the location specified, is run automatically by systemd when suspending and resuming. The reference link does, though.

There is no password needed here. Is this not working?


claydoh, proud to be a member of KDE forums since 2008-Oct, and KDE user since 2001
jonnycache
Registered Member
Posts
47
Karma
0
Hi claydoh,

the script runs fine without any password. I know that the script in the location u gave me is loaded automatically, when system suspends and wakes up.

My other question was, how can i define rules in "sudoers" with
sudo visudo

that the rules will be recognized. I tried that in many different ways line explained on the ubuntuusers Webpage, but nothing happend. If i define my script in sudoers the permission is yet permitted.

Greetings

Jonny


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell