In Lubuntu Linux 22.04, I need to make a binary file that is owned by root and is in the root group executable by a normal user. This is easy enough to achieve using:
sudo chmod o+x /path/to/binary/binary-executable
The binary also needs to read some configuration from a JSON file in the same directory. I don't want the normal user to be able to read the contents of the JSON file. It appears that I need to make the JSON configuration file readable by the normal user, so that they can run the binary, but I need the JSON file to be private to root.
To summarise:
The binary executable is here: /opt/my-progs/prog, owner:group is root:root, permissions: 755
The configuration file that is read by the executable is here: /opt/my-progs/config.json, owner:group is root:root, permissions: 660
Root can cd to /opt/my-progs and run the program ok.
The user can do
cd /opt/my-progs
, but when they try to run the program, there is a permission error for the configuration file.The binary executable assumes the configuration file is in the same directory as the binary executable.
Is it possible the make it so the user can execute the binary and not be able to read the config file?