This question is similar to this one, but should hopefully be more clearly expressed.Assume that /home is an NFS-mounted directory, and the NFS server has root squashing enabled.Consider the following script, which requires root privileges to read a file, and normal user privileges to write a file.#!/bin/bashcat /etc/shadowtouch ~/shadowIf this script is run without sudo, then the user cannot read /etc/shadow. However, if the script is run with sudo, root cannot write to ~/shadow, due to root squashing.Is it possible to grant user privileges to root when running this script, so that it can work successfully as one script without needing to include sudo on each of the commands that need it?I am trying to avoid using sudo inside the script for reasons mentioned here.
Is it possible to retain the union of user privileges and root privileges when using sudo?
root;nfs