LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2017, 03:59 AM   #1
ilansch
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Rep: Reputation: Disabled
get ip of user executed program


In my kernel module driver, during the execution of program (e.g mkdir) I need to find out the IP of the currently logged in client that executed this program.

One solution is to climb up in the process tree, go to init process, then start going down in the process tree, look for sshd, cross between the user id and the sshd session, perform a netstat and get the Foreign Address.

Is the a better efficient way to get the ip of the user ?
 
Old 05-28-2017, 05:25 AM   #2
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 996
Blog Entries: 11

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
/proc/$$/task/$$/net/ip_conntrack
might be related. Interesting project: "kernel module driver" that ?executes programs?
Let us know (more); best wishes. (a link)
 
Old 05-28-2017, 05:28 AM   #3
ilansch
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
my lkm does not execute programs.
 
Old 05-28-2017, 05:47 AM   #4
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 996
Blog Entries: 11

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Oh, sorry. Maybe lkm related to prior VFS post here.
Might the ip_conntrack be of any value here?

Last edited by Jjanel; 05-28-2017 at 05:52 AM.
 
Old 05-28-2017, 06:22 AM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,495
Blog Entries: 12

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
https://www.linuxquestions.org/quest...am-4175606809/

No comment.

Last edited by Habitual; 05-28-2017 at 06:22 AM. Reason: s/Ho/No
 
Old 05-28-2017, 07:03 AM   #6
ilansch
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
thanks for lsof solution, it does not exist on all machines,
solaris, aix does not have it by default. need to further investigate lsof (or fuser in other OS)
 
Old 05-28-2017, 04:48 PM   #7
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,495
Blog Entries: 12

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Quote:
Originally Posted by ilansch View Post
thanks for lsof solution, it does not exist on all machines,
solaris, aix does not have it by default. need to further investigate lsof (or fuser in other OS)
You didn't specify that

Yeah, that comes up on some closed-sourced stuff I have.
How about pstree ??

Have fun!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
get ip of user executed program ilansch Linux - General 3 05-28-2017 09:06 AM
[SOLVED] Xwindow's program will not run when executed on boot or when executed remotely richman1234 Programming 2 10-08-2010 01:32 PM
is there a way to find out who executed a program? vannguyen0 Linux - Software 1 07-03-2007 01:44 PM
how is my program executed by bash and the kernel aheak123 Programming 2 08-20-2006 05:41 PM
getting output from a program executed from c++ dfuse Programming 6 08-22-2003 02:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration