nicoulaj / cinnamon-applet-wireguard

A simple WireGuard systray applet for the Cinnamon desktop environment.
https://cinnamon-spices.linuxmint.com/applets/view/311
GNU General Public License v3.0
14 stars 5 forks source link

Replacing pkexec with sudo #8

Open k561 opened 1 year ago

k561 commented 1 year ago

If you get tired of entering the password requested by pkexec, you can use sudo. Add in /etc/sudoers: user ALL=NOPASSWD:/usr/bin/wg-quick

and replace in ~/.local/share/cinnamon/applets/wireguard@nicoulaj.net/applet.js:

$diff applet.js.bak applet.js 
124c123
<                 ['pkexec', 'wg-quick', enable ? 'up' : 'down', iface],
---
>                 ['sudo', 'wg-quick', enable ? 'up' : 'down', iface],
pzim-devdata commented 1 year ago

For not entering the password every times you want to connect or disconnect, as @k561 said, replace in ~/.local/share/cinnamon/applets/wireguard@nicoulaj.net/applet.js pkexec by sudo line 123 : Replace :

['pkexec', 'wg-quick', enable ? 'up' : 'down', iface],

by :

['sudo', 'wg-quick', enable ? 'up' : 'down', iface],

Then in sudo visudo add this line : with no empty line :

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
YOUR_USER_NAME ALL=(ALL) NOPASSWD: /usr/bin/wg-quick
# See sudoers(5) for more information on "@include" directives:

Replace YOUR_USER_NAME by your username or ALL

########################

The config files needs to be in /etc/wireguard/ (e.g /etc/wireguard/wg0.conf) And you must let reading access for your username to the folder wiregard : sudo chmod o+r /etc/wireguard

########################

Finally restart Cinnamon to make it works ( Alt+F2, type r and hit enter)

coaperator commented 1 year ago

For not entering the password every times you want to connect or disconnect, as @k561 said, replace in ~/.local/share/cinnamon/applets/wireguard@nicoulaj.net/applet.js pkexec by sudo line 123 : Replace :

['pkexec', 'wg-quick', enable ? 'up' : 'down', iface],

by :

['sudo', 'wg-quick', enable ? 'up' : 'down', iface],

Then in sudo visudo add this line : with no empty line :

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
YOUR_USER_NAME ALL=(ALL) NOPASSWD: /usr/bin/wg-quick
# See sudoers(5) for more information on "@include" directives:

Replace YOUR_USER_NAME by your username or ALL

########################

The config files needs to be in /etc/wireguard/ (e.g /etc/wireguard/wg0.conf) And you must let reading access for your username to the folder wiregard : sudo chmod o+r /etc/wireguard

########################

Finally restart Cinnamon to make it works ( Alt+F2, type r and hit enter)

image

How to fix it?

pzim-devdata commented 1 year ago

Sorry I don't know, I don't use WIregard anymore. Create a new issue and explain what you have done...