Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the Linux world, masking isn't usually done with asterisks, normally echoing is just turned off and the terminal displays blanks E.g. if you use <code>su</code> or log into a virtual terminal etc.</p> <p>There is a library function to handle getting passwords, it won't mask the password with asterisks but will disable echoing of the password to terminal. I pulled this out of a linux book I have. I believe its part of the posix standard </p> <blockquote> <pre><code>#include &lt;unistd.h&gt; char *getpass(const char *prompt); /*Returns pointer to statically allocated input password string on success, or NULL on error*/ </code></pre> <p>The getpass() function first disables echoing and all processing of terminal special characters (such as the interrupt character, normally Control-C). </p> <p>It then prints the string pointed to by prompt, and reads a line of input, returning the null-terminated input string with the trailing newline stripped, as its function result.</p> </blockquote> <p>A google search for getpass() has a reference to the GNU implementation (should be in most linux distros) and some sample code for implementing your own if need be </p> <p><a href="http://www.gnu.org/s/hello/manual/libc/getpass.html" rel="noreferrer">http://www.gnu.org/s/hello/manual/libc/getpass.html</a></p> <p>Their example for rolling your own:</p> <pre><code>#include &lt;termios.h&gt; #include &lt;stdio.h&gt; ssize_t my_getpass (char **lineptr, size_t *n, FILE *stream) { struct termios old, new; int nread; /* Turn echoing off and fail if we can't. */ if (tcgetattr (fileno (stream), &amp;old) != 0) return -1; new = old; new.c_lflag &amp;= ~ECHO; if (tcsetattr (fileno (stream), TCSAFLUSH, &amp;new) != 0) return -1; /* Read the password. */ nread = getline (lineptr, n, stream); /* Restore terminal. */ (void) tcsetattr (fileno (stream), TCSAFLUSH, &amp;old); return nread; } </code></pre> <p>If need be you could use this as the basis as modify it to display asterisks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload