Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show help screen if run from shell #5

Open
kevinreddot opened this issue Jun 19, 2018 · 3 comments
Open

Show help screen if run from shell #5

kevinreddot opened this issue Jun 19, 2018 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@kevinreddot
Copy link
Owner

If accidentaly started by a logged-in user, forsh will log it as login attempt. It should detect this and just print help message.

@kevinreddot
Copy link
Owner Author

The approach might be to detect if SSH_CONNECTION environment variable is set and parent process of forsh is sshd.

For FreeBSD, seems I need to use kvm_getargv90 to find the process name after the getppid(): https://www.freebsd.org/cgi/man.cgi?query=kvm_getprocs&sektion=3&n=1

For Linux, apparently, the only way is to read /proc directly.

@kevinreddot kevinreddot added the help wanted Extra attention is needed label Jun 22, 2018
@kevinreddot
Copy link
Owner Author

Example of process tree of a program when run via ForceCommand:

13437 - /usr/local/bin/get_ppid_and_name
 13436 - sshd: sss@pts/5
 13423 - sshd: sss [priv]
   842 - /usr/sbin/sshd
     1 - /sbin/init

@kevinreddot
Copy link
Owner Author

Wonder, how to do it in a cross-platform way. Also, if run in chroot, /proc might not be available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant