• Post Reply Bookmark Topic Watch Topic
  • New Topic

password on command line  RSS feed

 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am writing a little module in C that requires the user type in a password like with the su command. My problem is that unlike the su command, my module shows the password as they type it. I don't want to get into using the PAM modules to verify anything, I just want to make the password not show up when they type it.
I am open to using other languages or even shell scripts, I just thought C would be the easiest to get the command line responses I require. Does anyone know how this can be done?
Thanks!
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easier than you might think. I/O should just do its thing without requiring programmer intervention: that's the premise. But it's still totally controllable by you if you choose to intervene.
Your program knows file descriptor values for stdin, stdout and stderr (0, 1, 2, respectively) through macros in <stdio.h>. Read characters from stdin but don't echo it. That's all there is to it.
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite. There's this little thing called "stty echo".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!