permission to bind a socket to port 843?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers permission to bind a socket to port 843?
# 1  
Old 05-05-2009
permission to bind a socket to port 843?

I have written a flash socket security file server in PHP. The basic idea is that when Flash Player connects via socket to a server, the first thing it does is connect to port 843 and send a request for a 'socket policy file' by sending the string <policy-file-request/>.

The problem I have is that in order to launch this daemon script, I apparently need root level access in order to bind a socket to any port under 1024.

Can anyone recommend some way to let this php script bind to port 843 without needing root-level access? That seems like a big security risk to me -- especially if I want to launch this daemon using a php page hosted by apache. giving apache root-level access sounds like a VERY BAD idea.
# 2  
Old 05-05-2009
Sadly, you are likely stuck starting up as root.

Other daemons start up as root, then listen to their < 1024 port, then they change user id to the user that they are supposed to be for the rest of the session.

The only other easy alternative is to choose a higher port number.
# 3  
Old 05-05-2009
Thanks for your response.

Unfortunately, Flash is hard-wired to connect to 843 when looking for a socket policy file. If it fails to find a server on that port, it will try to find a policy file on the port it is trying to connect to, so you can build policy file handling into your application. This doesn't really work for me as I have written an AMF3-based protocol for my application server and to get a string that says "<policy-file-request>" rather than a 4-byte length indicator makes things pretty complicated.

That approach you describe sounds like something I eventually must do. I'd like the policy server daemon to be like Apache or MySQL in that it starts up when the machine reboots -- so you don't have to manually start it, etc.

Can you point me toward any resources which might explain how I could set up my script as a startup daemon which runs as root and then relinquishes its permissions?
# 4  
Old 05-06-2009
Does Flash send a full HTTP request surrounding <policy-file-request/> ? Or just the string itself? If it's a full HTTP request, could you configure your Apache to load an additional VHost, which listens on Port 843? If so, create a small CGI script that always returns your policy file.
# 5  
Old 05-06-2009
It is not a full http request. It is only "<policy-file-request>".
# 6  
Old 05-06-2009
Quote:
Originally Posted by sneakyimp
Can anyone recommend some way to let this php script bind to port 843 without needing root-level access?
One way, if you use Solaris or OpenSolaris, would be to grant limited privileges to the process. In your case, that would be PRIV_NET_PRIVADDR.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Get process id and port from the socket

Hello, Please help me in getting the process id and the port number from the socket netstat -Aan|grep -i closed f100050010b133b8 tcp 0 0 *.* *.* CLOSED f1000500119b53b8 tcp4 0 0 *.* *.* ... (3 Replies)
Discussion started by: Vishal_dba
3 Replies

2. Shell Programming and Scripting

Script to bind to socket

i need to come up with a script that when run from the command line, it will bind to a socket, and listen for tcp connections on a certain port. something like: ### ./connection_listener 5666 i found the following script on the web but when i run it, it complains about "accept" not being... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Programming

Using socket to test a TCP port

Hello, I'm trying to write a small c application to test a tcp port. This works fine for the most part but the default timeout on the connect is very long. I have been reading many posts but and it looks like I need to set the socket to be non-blocking and poll for a result. I have been totally... (2 Replies)
Discussion started by: tjones1105
2 Replies

4. Programming

GetLastError API for socket/bind failure in VxWorks 5.4

Can anyone tell what is the system API for VxWorks which is used to find GetLastError() for socket/bind failure. I need to use it in some VxWorks application and need to call GetLastError but I'm not sure about the correct API. Thanks in advance (1 Reply)
Discussion started by: anilgurwara
1 Replies

5. Shell Programming and Scripting

Python: Bind to port 80 as root, then drop privileges?

I have written a small web server in Python, and now I would like to run it on port 80, but in order to be able to bind to a port below 1024 I need to have root privileges. I don't want to run the server as root, though. How can I bind to port 80 as root and then drop root privileges? Thankful... (0 Replies)
Discussion started by: Ilja
0 Replies

6. UNIX for Dummies Questions & Answers

Socket bind fails

Hi, 1 more new comer with a small problem. I have a Java socket program which tries to bind to a particular socket. It works fine with windows. But in Linux, it says 'address in use'. I tried 'netstat' to find if the port is being used. But it is free. Can anyone help plz? (0 Replies)
Discussion started by: ronyantony
0 Replies

7. Programming

Cloning a socket connection, using other port numbers

Hello everybody, I've coded a multi-client server based on internet sockets using the scheme listen on port X-accept-fork, exactly like beej's guide At some point I would like to establish a secondary connection between a client and the server-child serving him. I was considering the... (4 Replies)
Discussion started by: jonas.gabriel
4 Replies

8. UNIX for Dummies Questions & Answers

Socket programming:One server two port

I want my server socket to listen on two ports in my machine. How do i achieve it? I will have two clients one connecting to 1 port and another to a different port. So my server needs to listen to both. Thanks. (1 Reply)
Discussion started by: abc.working
1 Replies

9. Solaris

How to allow nonroot user to bind to port 80

We are making some changes, and are now using Weblogic as the webserver on one of my projects. I would like for the non root user running Weblogic to be able to bind to port 80. (10 Replies)
Discussion started by: 98_1LE
10 Replies

10. Programming

socket on serial port

Does anyone know if it's possible to send socket by a serial port ? If yes, how can I find on Irix the value of my serial ports to use with this function : serverSockAddr.sin_port = ? Thanks for all responses ! Kintoo (2 Replies)
Discussion started by: kintoo
2 Replies
Login or Register to Ask a Question