Operating System - Linux
1832928 Members
2463 Online
110048 Solutions
New Discussion

Re: why can not add new service to xinetd

 
SOLVED
Go to solution

why can not add new service to xinetd

i tried to add one new service to xinetd, but failed.procedure as below:

i add one line to /etc/service as :
test 20001/tcp
and edit one programm as the simplest line in main():
test.c:
printf("hello world");

edit file test in /etc/xinetd.d/
service test
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /test
log_on_success += USERID
log_on_failure += USERID
}

then run
/etc/init.d/xinetd restart

i can view new service add in /var/log/messages.
but while i nmap localhost, no output from port 20001.

what wrong i made?

thanks,
Frederick
frederick van targero
3 REPLIES 3
Stuart Browne
Honored Contributor
Solution

Re: why can not add new service to xinetd

What shows up in /var/log/messages regarding the new service 'test' ?

What dose:

netstat -ntlp | grep 20001

show up?

does "/test" have the executable bit set ?

In any case, you'll need to learn a bit more about socket programming. Using tcp wrappers doesn't mean you can just spit stuff out to STDOUT, and expect it to come out of the socket at the other end.

You can get away with that with some shell languages, but for the most part, it's more complicated than that.
One long-haired git at your service...

Re: why can not add new service to xinetd

yes!!!
i found it and i also can telnet hostname 20001 to get response.

however the other question came out: why nmap can not scan all the ports?

the other question: although i can add service with simply by printf, but seems the stdout gone instead of remote socket output, do you know how to identify the local(stdin,stdout,stderr) Vs remote(1,2,3)? in other words, since the xinetd can provide network service even if none socket coding available, how to do use xinetd to provide service without socket operation?

could you give me some tips?

thanks,
Frederick
frederick van targero
U.SivaKumar_2
Honored Contributor

Re: why can not add new service to xinetd

Hi,

Thats because you may have run nmap to scan only well known ports. Instead go for a complete scan.

Your program 'text' does not need to have any socket programming routines in your case.

What happens is xinetd daemon listens on port 20001 for connection requests. If any connection comes it spawns your test program and redirects the output of your program to the network connection. Here xinetd will act like a proxy between your network client and your C program.

since xinetd daemon is the one who directly interacts with sockets , it is not nessecary to have your program defined in server = /test to be sockets programmed.

Eg:

You can write server = /bin/sh and telnet to that port and find shell prompt directly without authentication. This is used as backdooring unix systems.

Where programs like sendmail can be both used with xinetd and can also as standalone daemon in which sendmail program directly listens for conenction requests.

regards,

U.SivaKumar

Innovations are made when conventions are broken