[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kde2.2 open 1 port



On Tue, 4 Sep 2001, Tao Liu wrote:

> When kde2.2 is startup,
> I find that port 18300 is opened.
> what service listen on that port?

Hmm, I also found that after firing up kde there was a new port opened
on my system. I my case that consistently was a port just above 1024.

lsof -i TCP:<portnr> showed that this was kdeinit's doing.

To make this stop I adjusted the file

/usr/share/services/kxmlrpcd.desktop

If remember correctly I had to comment the last three lines in that
file.

I have written a small, crude perl script to monitor just this sort of
situation, maybe it's of some use to you. Remember to run it as root, since
normally lsof can't be invoked by a plain user.

-----------------

#!/usr/bin/perl

use Sys::Hostname;

#Show open TCP ports on this system

$hostname = hostname();
($sec, $min, $hour, $day, $month, $year) = (localtime)[0..5];
printf "Open ports found at %02d-%02d-%04d %02d:%02d:%02d on $hostname:\n", $day, $month + 1, $year + 1900, $hour, $min, $sec;
@lines = `netstat -a`;
foreach $line (@lines){
  if ($line =~ /LISTEN\s*$/){
    chomp $line;
    push @listening, $line;
    print $line;
  }
}

#Now find out who owns the ports

foreach $line (@listening){
  $nonr = 0;
  ($port = $line) =~ s/^.*?:(\w+).*$/$1/;
  if ($port =~ /^[A-Za-z]+/){
    open(PORTS, "/etc/services") || die "Could not read from /etc/services: $!\n";
    @ports = (<PORTS>);
    @portnrs = grep /^$port/, @ports;
    if ($#portnrs >= 0){
      $portnr = $portnrs[0];
      chomp $portnr;
      $portnr =~ s/^.+?(\d+)\/.*$/$1/;
      print "Port $port ($portnr) is owned by: ";
      $port = $portnr;
    }
    else{
      print "Port $port was not found in /etc/services (Can't use lsof on this one).\n";
      $nonr++;
    }
  }
  else{
    print "Port $port is owned by: ";
  }
  if (! $nonr){
    $padding = ' ' x (length($port) + 19);
    @lines = `lsof -i TCP:$port`;
    $owner = '';
    for ($i = 1; $i <= $#lines; $i++){
      @owner = split /\s+/, $lines[$i];
      $owner .= "$owner[0] (PID = $owner[1], USER = $owner[2])\n$padding";
    }
    $owner =~ s/\n$padding$//m;
    print "$owner\n";
  }
}
exit 0;

-----------------

HTH

Grx HdV

-- 
Support bacteria -
they're the only culture some people have.

J.A. de Vries aka HdV
Delft University of Technology
Computing Centre

Email: J.A.deVries@DTO.TUDelft.NL
Email: HdV@DTO.TUDelft.NL



Reply to: