Tuesday, October 12, 2010

Bind a non-root service to port 25 on Ubuntu with Authbind

Ports 1-1024 including 21 (ftp), 22 (ssh), 25 (smtp), 80 (http), 110 (pop3) can only be bound by services running as root.

Error messages indicating you have this problem are "Permission denied", "IOError when attempting to open socket ( constructor ), shutting down! java.net.BindException: Operation not permitted" or "java.net.SocketException: No such file or directory".

I recently developed my own smtp listener (converting e-mail to text/sms messages) and rather run the service as it's own user. Here's how (for port 25):

Install authbind (allows a program which does not or should not run as root to bind to low-numbered ports in a controlled way):
apt-get install authbind

Configure authbind (replace user with your user):
touch /etc/authbind/byport/25
chown user:user /etc/authbind/byport/25
chmod 755 /etc/authbind/byport/25

Start the service (simple test):
authbind nc -l -p 25 -e "/usr/bin/uptime"

Start the service (java):
authbind --deep /bin/bash -c "/usr/bin/java -Djava.net.preferIPv4Stack=true com.cent.texter.TexterServer"

1 comment:

  1. Apartments throughout Alanya stay fairly cheep, inside spite associated with costs growing significantly. even though your own market has become affected by recent financial events, It has proved in order to be much added robust than inside quite a few additional countries. because the new laws came in to The stress allowing foreigners for you to buy land, both involve ALONG WITH fees have increased. Prices, particularly decrease your current coast, tend to be rising rapidly, IN ADDITION TO tend to be required for you to proceed in order to do and so over the and then 5 to be able to 8 years.It doesn't need to utilize a great estate agent find ALONG WITH buy the Apartment inside Alanya. However, quite a few shoppers Decide on to do, and so Just like estate agents cater on the were made Specifications connected with foreigners ALONG WITH are aware associated with the many legal requirements. before committing in order to purchasing a great Apartment, it is advisable to settlement no matter if You will find almost any amazing debts for the property. lägenheter i Alanya

    ReplyDelete