I'm need build a shell-wrapper for logging any input on a shell.
The only problem I have is that i cant read stdin twice.
My wrapper creates a pthread executing the given shell and waits until the thread is terminated.
In this period of waiting I need to know what is going on on stdin.
I'm searching now for more than 2 days to solve this. With first attemp with python I got in the same problem.
Has anyone an Idea or even better a solution to get this working ?
Don't know how I have not seen this before :/ Anyway this one works but not as intended. First one: the shell prompt is not forwarded. Second one: striking ctrl+c terminates the wrapper.
>> First one: the shell prompt is not forwarded
I don't understand what you mean.
>> Second one: striking ctrl+c terminates the wrapper.
¿Isn't that expected?
You could code a parent-child with all the signals forwarded. (fork() exec*() sigaction() pipe() popen()
>>>> Second one: striking ctrl+c terminates the wrapper.
>>¿Isn't that expected?
If I would cancel a process in the shell, it would kill the wrapper not the process I started. In general the wrapper should behave exactly like the shell started inside it. Except for the logging.
>>>> First one: the shell prompt is not forwarded
>>I don't understand what you mean.
As i wrote obove - the wrapper should behave like the shell.
I already tried to pass stdin as a pipe, but thats the same effect as piping with tee.
For both, C and Python it does work but not as intended :(
I got it working now. It was a bit tricky because I needed to modify script from util-linux first. My version now has a new Switch to log input only. In conjunction with my already existing wrapper in python I'm able to log the input to a file or to a Graylog2-Server.
Does anyone know where I can send the patch for script.c ?
Were you able to post your modifications to script.c? Did you put any measures in place to ensure passwords aren't captured? Comparing stdin to stdout and only then recording that character?