Are there still any C programmers alive out there? I have an odd puzzle. I am trying to customize a program called passwordcheck.c (http://cr.yp.to/checkpwd/interface.html
). For some crazy reason, it expects input on file descriptor 3. I have the following C code:
cnt = read(3, buffer, sizeof(buffer));
printf("%d: %s\n", buffer);
fprintf(stderr, "ERROR %s\n", strerror(errno));
the 'read' is pretty much the same as the original version. This program compiles OK. The problem is how to pass something on fd 3?!
there are no test examples for the C version, but some comments in a python version show testing with the command line:
printf "%s\0%s\0%s\0" unknown bloggs Y123456 | ./checkpassword-phpbb.py id 3<&0
So, I've tried:
echo pete | ./checkpassword 3<&0
but that gives a segmentation fault.
> echo pete >&3 | ./checkpassword
-bash: 3: Bad file descriptor
Any ideas on how to send something to fd 3 so I can test this program?