LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 05-28-2017, 03:33 AM   #1
ilansch
LQ Newbie
 
Registered: Feb 2017
Posts: 13

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, 06:08 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by ilansch View Post
Is the a better efficient way to get the ip of the user ?
Code:
lsof -u $LOGNAME  | grep ssh | grep ESTAB
"better" = IDK what's better, or better efficient.
I suppose your own code would be "best", yes?
There are as many ways to execute as there are admins.

Good luck.

Last edited by Habitual; 05-28-2017 at 06:12 AM.
 
Old 05-28-2017, 08:58 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
@OP: also check these: crond, atd, initd, systemd -- they do start programs without any user/client/IP
 
Old 05-28-2017, 09:06 AM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator response

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of https://www.linuxquestions.org/quest...am-4175606810/
 
  


Closed Thread



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Only part of shell script executed from Java program. ashish.ars@gmail.com Linux - Newbie 4 11-02-2011 03:08 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 > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:54 PM.

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
Open Source Consulting | Domain Registration