How to make root owner of an app?

Hi all,

as gparted, I wish to protect gnome-disk-util (gnome-disks) under root control, to protect it with amministrator pswd and make it safer

How can I do?

Hi there :slight_smile:

You can just edit access permissions to the file :

sudo chmod 700 /usr/bin/gnome-disks

Doing a test with mate-calc :

┌─[olek@lenovo_apbook08u]─[~]
└──╼ $ll /usr/bin/mate-calc
-rwxr-xr-x 1 root root 268184 avril  5  2018 /usr/bin/mate-calc*
┌─[olek@lenovo_apbook08u]─[~]
└──╼ $/usr/bin/mate-calc
┌─[olek@lenovo_apbook08u]─[~]
└──╼ $sudo chmod 700 /usr/bin/mate-calc
[sudo] password for olek: 
┌─[olek@lenovo_apbook08u]─[~]
└──╼ $/usr/bin/mate-calc
bash: /usr/bin/mate-calc: Permission denied
┌─[✗]─[olek@lenovo_apbook08u]─[~]
└──╼ $sudo !!
sudo /usr/bin/mate-calc
┌─[olek@lenovo_apbook08u]─[~]
└──╼ $

This should be doing what you are asking for.

There is a other more dangerous way :
You can also restrict access to a program editing the /etc/sudoers file :
(Be very careful with that file - a mistake can do damages)

edit the file with this command :

sudo visudo

and add :

user ALL=(ALL) NOPASSWD: !/usr/bin/gnome-disks

The ! should make the OS to ask the user for password to run the program.

Good luck :slight_smile:

1 Like

infinite thanks, a sorry for my little knowledges

Is there a way to mantain icon-launcher (under accessories) working?

Sure,
Just edit this launcher with a text editor :

sudo nano /usr/share/applications/mate-calc.desktop

and add pkexec in front of the run command, like this :

image

It should now ask for root password to run.

or

You can right click menu launcher > Edit Menus

Next find Disks and edit it with the pkexec like this :

again: thanks for your support

i can't get work it...i tried both method without success....
with
pkexec "/usr/bin/gnome-disks" i get just password but program doesn't start

Hi there :slight_smile:
Yap, it has troubles to work with gnome-disks.

II found a other way :

write this content inside there : /usr/share/applications/gnome-disk-run.desktop

sudo nano /usr/share/applications/gnome-disk-run.desktop

[Desktop Entry]
Name=Disk Image as root
Comment=run disks as root
Exec=sudo gnome-disks
Icon=drive-removable-media
MimeType=application/x-cd-image;application/x-raw-disk-image;application/x-raw-disk-image-xz-compressed;
Terminal=true
StartupNotify=false
Type=Application
X-Ubuntu-Gettext-Domain=gnome-disk-utility

This should make you appear a gnome-disks launcher in your menu "Disk Image as root"
that will open a terminal window asking for password, and if correct, open gnome-disks.

You can next hide the regular Disks app from the menu.

yes but the same result, you could get it simply modifing launcher as "app in terminal" and command "sudo gnome-disks"

my intent was no open terminal windows

This was possible before with gksudo that gone now from ubuntu.
You can install gksudo and use it instead of pkexec. Maybe you will have more chance with that.

Good luck :slight_smile: