I have a question about the PAM-module "pam_exec".
In the file /etc/pam.d/common-session I've put a line that says
'session optional pam_exec /usr/local/bin/test'
so I want the external script 'test' to be run everytime the command 'su <user>' is executed.

I invoke PAM with su <username>, which leads to the program reading the '/etc/pam.d/su' -file.

The 'su' file - (/etc/pam.d/su) in turn source the 'common-session'-file, so that the pam_exec command is executed when I use the su-command.

However I get the output

/usr/local/bin/test failed: exit code 8

I have spent several hours and canīt figure out what is wrong. Help would be greatly appreciated.......