LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-18-2005, 07:16 PM   #1
brenan99
LQ Newbie
 
Registered: Aug 2003
Location: Maryland
Distribution: Debian, Ubuntu, Solaris
Posts: 23

Rep: Reputation: 15
Need Java program to listen on ports < 1024 w/o being root - possible


I am in AP Computer Science 3 on the highschool level and am working on my final project which is a client server chat/poker program written in java. We are not allowed to set up webservers on the school compters, so I trying to use my home linux web server hosting the client applet and also running the poker server program. The poker server listens on port 9999 but it seems that my school blocks outgoing connections to 9999. I know that they do not block ports 80, 21, 22, and 23 (and I assume most ports less than 1024) because I have established connections to my server via telnet.

The problem is: if I am a regular user and I try to run the server on ports less than 1024 I get a java security exception when it tries to bind to the port.

Is there a way to run my server on ports less than 1024 without being root?

Don't apache and other servers do this somehow?

Thanks,

Brenan

PS I have tried setting the SUID bit for a script to run the server but that did not work, and if it did I think the server would still be running as root.
 
Old 02-18-2005, 09:51 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Binding to priviliged ports (as ports < 1024 are called) is an operation only permitted to the root user. What Apache (and like applications) do is actually start out as the root user, and then drop privileges to a normal user (the apache or nobody account, in most cases). I'm not a Java expert ... so I'm not sure if there's a way around this. Doing a google on Java setuid returned a few hits, so those might be where you want to look. Alternatively, you could do SSH port forwarding to try to get around this, or, if you trust your JVM, let the code run as root (to be avoided).
 
Old 02-22-2005, 02:12 PM   #3
brenan99
LQ Newbie
 
Registered: Aug 2003
Location: Maryland
Distribution: Debian, Ubuntu, Solaris
Posts: 23

Original Poster
Rep: Reputation: 15
Talking

Well after performing a google search on java setuid (which returned this thread btw ) I stumbled on something called the java native interface or JNI.

Anyone who has had the same problem as me may want to try the following links:


http://sys-con.com/story/?storyid=36466&DE=1

http://java.sun.com/docs/books/tutor...1.1/index.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allowing non-root to bind to ports < 1024? MWTJ Linux - Networking 8 08-12-2011 07:06 PM
using privileged ports below 1024 not possible AS ROOT??? flipper333 Slackware 2 01-23-2004 07:35 PM
opening ports below 1024 without being root? meks Linux - Networking 2 12-25-2003 06:05 PM
binding <1024 ports with non root account? linuxlouis Linux - Networking 2 08-11-2003 05:55 PM
Ports below 1024 peo66 Linux - Networking 4 06-14-2003 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration