maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Cannot open a listening socket on low port numbers: The address is protected (https://talk.maemo.org/showthread.php?t=47107)

cjard 2010-03-11 11:45

Cannot open a listening socket on low port numbers: The address is protected
 
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?

hqh 2010-03-11 11:49

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Your app must run as root to be able to bind to a low port number.

rambo 2010-03-11 11:49

Re: Cannot open a listening socket on low port numbers: The address is protected
 
On all unix-style systems binding to "low ports" requires root privileges.

Edit: was too slow it seems...

rambo 2010-03-11 11:51

Re: Cannot open a listening socket on low port numbers: The address is protected
 
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...

cjard 2010-03-11 12:07

Re: Cannot open a listening socket on low port numbers: The address is protected
 
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!

chainreaction 2010-03-11 12:09

Re: Cannot open a listening socket on low port numbers: The address is protected
 
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.

rambo 2010-03-11 12:14

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Quote:

Originally Posted by cjard (Post 563627)
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).

Quote:

Originally Posted by cjard (Post 563627)
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...

rash.m2k 2010-03-11 12:22

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Port 0-1024 are reserved for well defined processes, eg. http is port 80.

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

cjard 2010-03-11 15:13

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Quote:

Originally Posted by rambo (Post 563638)
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..

Quote:

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 :)

Quote:

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!

cjard 2010-03-11 15:15

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Quote:

Originally Posted by rash.m2k (Post 563641)
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 :)

rambo 2010-03-17 20:20

Re: Cannot open a listening socket on low port numbers: The address is protected
 
Quote:

Originally Posted by cjard (Post 563838)
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 :)

Python programs I just edit directly on device (sshfs mount) and they run fine in the user session even when started via ssh.

Otherwise I use scratchbox for the iterative stuff, old skool... Haven't got around to MADDE/QtC yet.

cjard 2010-03-18 02:45

Re: Cannot open a listening socket on low port numbers: The address is protected
 
be aware that youre officially stuck on qt4.5 if you want the qtc+madde+clickplaytodeploy route; qt46 hack exists but qtc cannot use it directly to build armel binaries due to some errors in the mkspecs folder, possibly other errors too


All times are GMT. The time now is 22:22.

vBulletin® Version 3.8.8