Bash sudo script without prompting for password – Manjaro NFS mounting

Bash sudo script without prompting for password – Manjaro NFS mounting



I’ve been searching for some time why my sudo configuration is not working to mount a local NAS server via NFS, without prompting for password – all the more that it has worked for years under Fedora and seems not to work with the same configuration under Manjaro.
The idea is simply to allow my wife to mount files at will, without remembering complex passwords and in order to avoid relying on fstab, so as not to slow boot time when not on the local network.
The script is simple enough and consists of a list of folder like this :


```bash
#!/bin/bash
mount -t nfs 192.168.X.X:/volume1/manon /mnt/NAS/manon -o auto,user,rw,noatime
# more folders…
exit 0
```



It is of course working as intended when used with sudo, and giving user password (also with a convenient bashrc alias).
Then, I’ve followed the arch wiki (https://wiki.archlinux.org/index.php/Sudo#Example_entries) to apply the NOPASSWD to my user on the intended script with this line (I also tried to add the pacman system update for our purpose here) :


```
manon ALL=(ALL) NOPASSWD: /home/manon/.script/NASNFS.sh,/usr/bin/pacman -Syyu
```



which is confirmed by sudo -lu :


```console
[manon@manonPC ~]$ sudo -lU manon
L'utilisateur manon peut utiliser les commandes suivantes sur manonPC :
(ALL) NOPASSWD: /home/manon/.script/NASNFS.sh, /usr/bin/pacman -Syyu
(ALL) ALL
```



However, it still asks for password – mounting for files or updating system – whatever I do… I also tried to add the hostname to visudo, or use %wheel group (which manon belongs to), without result.



Has anyone any idea of the step I missed and why this is not working like in Fedora ?
Thanks for having read, and all the best,




1 Answer
1



I’ve finally found the answer to my question – I’ll post in case it might be useful to anyone stumbling over the same blunder.
As stated in the wiki(https://wiki.archlinux.org/index.php/Sudo#Example_entries):



The most customized option should go at the end of the file, as the
later lines overrides the previous ones.



The problem is thus not to rely on the default comments in the visudo file, since there is a final command which could easily be mistaken for a comment – but is not:


#includedir /etc/sudoers.d



This includes a directory which indeed contains a 10-installer file, applying a default behaviour on the wheel group, overriding my custom command:


%wheel ALL=(ALL) ALL



That was why I had sudo -lU manon outputing:


[manon@manonPC ~]$ sudo -lU manon
L'utilisateur manon peut utiliser les commandes suivantes sur manonPC :
(ALL) NOPASSWD: /home/manon/.script/NASNFS.sh, /usr/bin/pacman -Syyu
(ALL) ALL



instead of now:


[manon@manonPC ~]$ sudo -lU manon
L'utilisateur manon peut utiliser les commandes suivantes sur manonPC :
(ALL) ALL
(ALL) NOPASSWD: /home/manon/.script/NASNFS.sh



In conclusion: beware to add your custom rule in visudo at the very end of the file, or create a new file in the sudoers.d folder, incrementing file name.



Sorry for the noise if that was obvious, and hoping being helpful for others.
All the best,



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ