Solved

Linux Port Listen port 43, local whois server

Posted on 2001-09-05
11
683 Views
Last Modified: 2012-06-21
Hi,

I configure my linux to receive whois requests.
What I want is,
when a user did
"whois such-a-domain.com@whois.my-domain.com"
This script should be return the value after whois, namely
"such-a-domain.com@whois.my-domain.com".
To do this, I think I need to listen the whois port 43.

Anybody have/know? a C program which returns this...

Waiting for your answers...
0
Comment
Question by:Ege
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 2

Expert Comment

by:bkdc
ID: 6457832
there were tons of questions on socket programming so, please, be more specific.
 What do you need ? a tutorial on sockets,TCP/IP, etc ?
0
 
LVL 1

Author Comment

by:Ege
ID: 6459775
Hi again,
I need the following.
As everybody know, there exists a WHOIS SERVER (not client)

I configure my linux to accept whois requests via the port 43 (default whois port in RedHat).

With this configuration, if a whois request received, linux system runs the code /usr/sbin/in.whoisd
I will put my own executable instead of default one.

I want a C/C++ program to put this in.whoisd executable, such that, it understands the request.

Sample request:
whois subdomain.mydomain.com@whois.mydomain.com

whois.mydomain.com is my machine of course, and

subdomain.mydomain.com is a sub domain of my domain[s].

What I want is understanding the left part of @
(means subdomain.mydomain.com).

Such that, I can process my SQL queries and print the result...

In fact, the function not realy required to be a C code, it can also be a shell script or some other. But I prefer C.

Thanx for your interest...
0
 
LVL 2

Expert Comment

by:bkdc
ID: 6463746
>>What I want is understanding the left part of @
(means subdomain.mydomain.com).

What do you want to understand ?
You mean you need help parsing the "whois subdomain.mydomain.com@whois.mydomain.com" stuff (read string) ?
 Is this what you want:
1. parse the string
2. get the subdomain string
3. search for it somethere
4. return stuff ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Ege
ID: 6464468
Yes.
Absolutuley yes.

Details:

filename: xinetd.d/whois
service whois
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.whoisd
}

And system calls
/usr/sbin/in.whoisd in time a request accepted.

I want to get the string whois subdom@whois.mydom.com

Rest is easy!

I tried with PERL and C using the SOCKET programming.

I got "address already in use" !

have any utility, which gets that string into a variable?

best regards...

0
 
LVL 2

Expert Comment

by:bkdc
ID: 6464751
First of all, I strongly advise you to take a look (a closer look) at the following address:

http://community.roxen.com/developers/idocs/rfc/rfc1714.html

>>I got "address already in use" !

 Whois service is (usually) running on port 43. Since that port is already taken by the default /usr/sbin/in.whoisd
it's normal not to be able to establish a listening socket on that port. In fact, the port is taken up by inetd, which listens for requests and passes the control to in.whoisd when required (that is - when a request comes on port 43).

The inetd daemon forks and executes a copy of in.whoisd, the daemon associated with the whois service, handing the open file descriptor for the incoming socket connection to the new whois daemon.

After you get the handle, first thing you should do is to create a socket using that handle (attach to it).
Read the data after that.

Parsing the text should be no problem but if you have difficulties post the code and we'll help you.
0
 
LVL 2

Accepted Solution

by:
bkdc earned 300 total points
ID: 6464761
Oh, one more thing. I'm not very familiar with Linux (I guess that's what you're using) cause I use QNX which is slightly different but I think that you should make some changes in xinetd.d/whois or whatever.

filename: xinetd.d/whois
service whois
{
       disable         = no
       socket_type     = stream
       wait            = no
       user            = root
       server          = /usr/sbin/in.ege.whoisd
}

That way inetd will call your program instead of the default in.whoisd
0
 
LVL 1

Author Comment

by:Ege
ID: 6465678
well,

it 's clear that, no  socket connection and listenning required... which is already done by standart whois service, via the INET.

(unfortunately, in.whoisd and in.ege.whoisd the same thing in your sample! just changing the filename! here).

--------------- IMPORTANT PART --------------------
in this case, what I need is:
only the getting string into a VARIBLE.
string is the requested one by user, i.e
"whois subdom.mydom.com@whois.mydom.com"
inside the file /usr/sbin/in.whoisd
which is called each time whois request accepted via INET services...
--------------------------------------------------

{ the URL you give talks about the WHOIS, but I do NOT wanna use standart whois process.. I just one to use it as a known process to accept queries! }

thanx for your interest... but still I do not get my answer.

best regards...
0
 
LVL 2

Expert Comment

by:bkdc
ID: 6470170
I understand, but the only way to do that is to write a whois daemon (in.ege.whoisd or whatever name you like) and use it instead of the default one: in.whoisd
0
 
LVL 1

Author Comment

by:Ege
ID: 6473872
:)

yes! but how!?

my problem is already accepting the requested string!

If I can get the string sent by whois command, I have no problem to process it!

How can I get the string which has been sent by whois command?

:)
0
 
LVL 2

Expert Comment

by:bkdc
ID: 6474474
Told ya before. Make a nice little daemon. There's no other way, unless you use a sniffer (and that would be a REAL pain).
 Why do you find it so difficult ? Take some in.whoisd sources (i presume Linux comes with this king of source code) and tweak it to serve your needs. This way you won't have to write a fully compliant whois daemon from scratch.

PS: Sorry but I don't know any other (easy, hocus-pocus, 10 easy steps) way.
0
 
LVL 1

Author Comment

by:Ege
ID: 6702202
sorry that I accept your answer due the personel problems.
Thatks for your interest. Your answer about xinet.d configuration file did help me...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question