2

I need to get the get the client IP from a specific connection from proftpd on linux (where I know the pid). I have searched in the /proc/ dir but wasn't able to to get any information about the IP.

Does anyone know a method how to get or where to find this information?

p.s. sorry, but i forgot to mention that all this should happen from inside a FUSE implementation, so is it possible to get that information without using an extern programm or is there maybe a library that could help me doing that ?

Castaglia
  • 3,349
  • 3
  • 21
  • 42

3 Answers3

0

Check the fuser tool. It allows to identify files and sockets opened by a process. That should be a good starting point.

arkascha
  • 168
  • 1
  • 8
0

Try the netstat -tnp command, it will show all TCP connections + IP + PID of process behind that connection. You should also be able to find the client IP in Proftpd logfiles.

anydot
  • 116
  • thank you. i forgot to mention that i need this information in a c-programm. i editet my question to make this clear. thanks you for that fast answer. –  Oct 24 '12 at 09:34
0

As you later added that you want to do that from C program would be to directly ask Proftpd. Just set your Proftpd instance so it's saving scoreboard file. You can then parse that file directly (which made you depending on format of internal file of Proftpd), or you can parse output of command ftpwho -v -o oneline which is Proftpd's command using scoreboard file to output different kinds of information about connected users.

anydot
  • 116