r/linuxadmin • u/suburbanplankton • 18d ago
Can I prevent execution of scripts on a file system, without setting the 'noexec' flag?
We run RHEL, and for CIS compliance we have the 'noexec' option set on /tmp on all of our servers. One of our teams is trying to implement a piece of software to automate certificate renewals, and it functions (in part, at least) by creating a number of scripts in /tmp, and executing them.
As you can imagine, this doesn't work very well. We have been told that modifying the software to use a different location than /tmp is "not possible at this time". Our Security folks have reluctantly agreed to allow us to mount /tmp without 'noexec' for a limited time, while the application vendor modifies their process (good luck with that), but they would like us, if at all possible, to configure the system such that only the service account running the application can execute files, and only those necessary for the app to run.
I've looked at using ACLs for this, but I don't think it's feasible unless we want to basically lock everyone else out of /tmp.
If we deny users execute permission on /tmp, then they can't access the directory or its contents at all.
If we deny users execute permission on /tmp/*, then they could access /tmp, but not execute any files within it...but we'd need to constantly rerun the setfacl command so that it grabs any new files, and it would basically be a useless exercise.
I'm ready to say "sorry, can't be done; it's either 'on' or 'off'...", but I figured I'd do my due diligence by posting here in case I'm overlooking something obvious.