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
Password input with no echo is not working #21731
Comments
Emscripten's TTY support is very basic. I would recommend completely avoiding Altneratively if you would like to work on improving the TTY support that would be most welcome. BTW, do the |
Thanks a lot for this very quick feedback. Looks like tcgetattr and tcsetattr are not implemented when compiled with "-lnodefs.js -lnoderawfs.js" as I get a runtime error. No error otherwise, it runs but skips user input. By the way, do you have any guideline on how to implement this in JavaScript? I would like to avoid -sASYNCIFY and I believe this functionality would require async/await calls which would only work from a worker thread. And this would mean redirecting stdin and stdout to the worker. Does it make sense for you or am I missing a simple and straightforward solution? Thanks again for your help! Kind regards, |
Is you final target nodejs rather than the web? If that is the case I think we can make When I suggested implementing this yourself in JS I was assuming you were targeting the web. |
Yes indeed, I am only targeting nodejs (not the Web). Are you suggesting that I need to modify emcc itself, or that I should write some kind of hook to implement tcgetattr and tcsetattr to work with -lnoderawfs.js? Any example, pointer or direction would be much appreciated as I think that I am stuck right now. Thanks a lot! |
Yes, I think we (you?) can modify noderawfs (part of emscripten) so that this should work. |
Can I ask what you use case is for using emscripten-built modules inside of node js? |
OK, thank you, I will look into "library_noderawfs.js" to try to make it work as expected. I would have preferred not to do so, as I will then need to port this patch on newer versions of emcc, but if this is the best way to go, I’ll do this :-). Sorry I do not understand your question. I am just porting a C program (which is asking for a password) to JavaScript (nodejs) so that it can be portable. I managed to get it to work with echo of the password to the terminal but I would really prefer to hide this echo as it would be better for security reasons. |
I see, so you choosing wasm over a native node extension for portability reasons. BTW I wasn't suggesting you carry a local patch to |
OK, thanks a lot for your feedback, I have started to look into this, and I think that the chance I succeed is quite low as I am neither proficient in emscripten’s internals nor in TTY… Have a nice day! |
Hi,
I am trying to compile the simple program below which works fine with gcc but does not work with emcc.
The objective is to input a password with no echo on terminal for security reasons.
When compiled with emcc, getchar() is not blocking for user input, always leading to an empty password.
Is there any way to make this work with emscripten? (maybe with another method?)
Thanks a lot for your help and feedback.
Kind regards,
Maurice
Failing command lines in full:
emcc pass.c -o pass.js
Same question with:
emcc -lnodefs.js -lnoderawfs.js pass.c -o pass.js
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114b)
clang version 19.0.0git (https://github.com/llvm/llvm-project febb4c42b192ed7c88c17f91cb903a59acf20baf)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
The text was updated successfully, but these errors were encountered: