bash script fails with 'Permission denied' error due to IMA policy.

Solution Verified - Updated -

Issue

  • A bash script fails to execute with a Permission denied error, despite having the necessary permissions.
    • The issue specifically happens after loading IMA policy appraise func=BPRM_CHECK appraise_type=imasig
    • Or executing ima-setup --policy=/usr/share/ima/policies/01-appraise-executable-and-lib-signatures command.
  • Example:
# ls -lZ sleep.sh 
-rwxr-xr-x. 1 root root unconfined_u:object_r:admin_home_t:s0 20 Jul  6 22:57 sleep.sh

# cat sleep.sh 
#!/bin/bash
sleep 2

# ./sleep.sh 
-bash: ./sleep.sh: /bin/bash: bad interpreter: Permission denied

# cat sleep.sh 
sleep 2

# ./sleep.sh 
-bash: ./sleep.sh: Permission denied

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • IMA (Integrity Measurement Architecture)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content