Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux Port Listen port 43, local whois server

Posted on 2001-09-05
11
Medium Priority
?
704 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 900 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.
Suggested Courses

650 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