On Tue, Oct 16, 2012 at 09:33:38PM -0500, Stan Hoeppner wrote: > On 10/16/2012 9:17 PM, Neil Aggarwal wrote: > > > I am trying to execute a java program from postfix using > > a pipe alias. > > > > When I send an email to the alias, I get this back from postfix: > > > > Command died with status 1: > > "/root/webapps/cbsweb/WEB-INF/bin/mdcm/mailHandler". Command output: > > Exception in thread "main" java.lang.NoClassDefFoundError: > > mdcm/MailHandler > > Caused by: java.lang.ClassNotFoundException: mdcm.MailHandler at > > java.net.URLClassLoader$1.run(URLClassLoader.java:217) at > > java.security.AccessController.doPrivileged(Native Method) at > > java.net.URLClassLoader.findClass(URLClassLoader.java:205) at > > java.lang.ClassLoader.loadClass(ClassLoader.java:321) at > > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at > > java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the > > main class: mdcm.MailHandler. Program will exit. > > > > Obviously, it is invoking the java vm, but for some reason it is > > not finding my main class. > > Postfix doesn't run as root.
Well, master(8) does, but you are probably on the right track. > > I can execute my script file from the command line and it works fine. As what user? With what environment? > > Here is my alias in /etc/aliases: > > # Forward mdcm messages to mail handler > > mdcm: |"/root/webapps/cbsweb/WEB-INF/bin/mdcm/mailHandler" > > You're running the script as root. No, it won't run as root. Assuming /etc/aliases is owned by root, this command is run by $default_privs user (default: "nobody".) http://www.postfix.org/local.8.html http://www.postfix.org/aliases.5.html http://www.postfix.org/postconf.5.html#default_privs Why this would be in a subdirectory under /root is entirely another question. /root should be private, for the superuser only. If "nobody" can access this file, directory permissions are wrong. I would definitely suggest moving this to a better location. > > Any ideas? > > Run the script in the context of the Postfix user, assigning > necessary permissions to the script and all related files. Oh, my, no! The $mail_owner user (default: "postfix") should never be used for this; not for *anything* other than internal processes of the Postfix MTA itself. But as I said, you were on the right track. If "nobody" can access the script and files it needs, it might work. http://www.postfix.org/OVERVIEW.html http://www.postfix.org/postconf.5.html#default_privs[1] http://www.postfix.org/postconf.5.html#mail_owner [1] Quote: "DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER." -- http://rob0.nodns4.us/ -- system administration and consulting Offlist GMX mail is seen only if "/dev/rob0" is in the Subject: