Reply
Thread Tools
Posts: 225 | Thanked: 64 times | Joined on Feb 2010
#1
Hi All

Binding to a listening port 25 (for example) works when I run my Qt app in windows, but fails on the device, with error code 3: The address is protected

Can anyone advise how to allow opening this socket?
 
Posts: 388 | Thanked: 842 times | Joined on Sep 2009 @ Finland
#2
Your app must run as root to be able to bind to a low port number.
 

The Following User Says Thank You to hqh For This Useful Post:
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#3
On all unix-style systems binding to "low ports" requires root privileges.

Edit: was too slow it seems...
 

The Following User Says Thank You to rambo For This Useful Post:
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#4
Much better question: Why do you want to bind your GUI application to the SMTP (or any other) port, which usually is inhabitated by a daemon...

Last edited by rambo; 2010-03-11 at 11:56. Reason: minor typo fix
 

The Following User Says Thank You to rambo For This Useful Post:
Posts: 225 | Thanked: 64 times | Joined on Feb 2010
#5
this app will, eventually, not be gui but will be a daemon. I'm jsut using a gui right now because I'm struggling to get the app to work as a daemon for different reasons:

when I develop windows services, because debugging them is a pain in the arse, its easier to just make a dummy gui that does nothing but embodies the service code. essentially rather than using the SCM to launch the app and call start() (and then struggle to attacha debugger to it) it is easier to open a blank window and start its message loop then have a button on the window call start().

same goes here, I'm doing a service/daemon, but I'm using the gui aspect first so that the phone shows me something i can interact with so I know its working/have a text panel to send debug messages to. eventually the app will not have a gui and will probably be configured using the browser

i think, therefore, it may be wiser to just run a high port number in the future; it doesnt really matter - the clients of this app (smtp capable programs) can always change the port number to match the app, and it may be more sensible from an exploit point of view not to have the program running as root..

thanks to all!

Last edited by cjard; 2010-03-11 at 12:10.
 
Posts: 162 | Thanked: 79 times | Joined on Jan 2010 @ Finland
#6
As people have said before, you should run in the higher port ranges as low port ranges require root priviliges. It also could be considered more secure as port scanners tend to check the lower ports for common services. Higher ports are also often unused.
 

The Following User Says Thank You to chainreaction For This Useful Post:
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#7
Originally Posted by cjard View Post
I'm doing a service/daemon, and I'm using the gui aspect so that the phone shows me something i can interact with so I know its working. eventually the app will not have a gui and will probably be configured using the browser
You could make a separate small GUI app for the configuration (GConf can notify about key changes do your daemon can automagically react to changed configs).

Anyways, I would run the app in terminal in foreground while debugging, shorter way to a real daemon from there (and many of the daemons in linux/unix world have an option to start in foreground for exactly this reason).

Originally Posted by cjard View Post
i think, therefore, it may be wiser to just run a high port number in the future; it doesnt really matter - the clients of this app (smtp capable programs) can always change the port number to match the app, and it may be more sensible from an exploit point of view not to have the program running as root..
Definitely the way to go as a general precaution, of course on single user device like the N900 the privilege separation does not help as much as all the important bits for the user (user data, photos, contacts etc) are accessible/messable with the users privileges...
 
Posts: 642 | Thanked: 486 times | Joined on Aug 2008
#8
Port 0-1024 are reserved for well defined processes, eg. http is port 80.

Use a port that's between 1025 and 65,535.
 

The Following User Says Thank You to rash.m2k For This Useful Post:
Posts: 225 | Thanked: 64 times | Joined on Feb 2010
#9
Originally Posted by rambo View Post
You could make a separate small GUI app for the configuration (GConf can notify about key changes do your daemon can automagically react to changed configs).
I was thinking of making the app have a web page for the few bits of configuration it would need, but I may take a look at other options including its own gui..

Anyways, I would run the app in terminal in foreground while debugging, shorter way to a real daemon from there (and many of the daemons in linux/unix world have an option to start in foreground for exactly this reason).
Using MADDE/QtC, I just click the "play" buttona nd it transfers the app to the device and runs it, hence the reason I chucked a GUI together; didnt want to build, then run a script to delopy, then run a terminal session to start the app, and do that 200 times a day

on single user device like the N900 the privilege separation does not help as much as all the important bits for the user (user data, photos, contacts etc) are accessible/messable with the users privileges...
which, curiosuly enough in this case, will actually be a blessing!
 
Posts: 225 | Thanked: 64 times | Joined on Feb 2010
#10
Originally Posted by rash.m2k View Post
Port 0-1024 are reserved for well defined processes, eg. http is port 80.

Use a port that's between 1025 and 65,535.
Indeed, and the process I'm creating responds to SMTP commands so it is, in effect, an SMTP server.. No matter though, it can be run on a different port, because it's not as though the world is full of mail clients that cannot specify an alternate SMTP port
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:08.