readpass(3)
β¨ readpass(3) β¨
okay bestie, so this one is readpass from the Library Functions Manual and it's literally just... a password reader. that's the whole vibe. let's go π
π NAME π
readpass β read password
π LIBRARY π
Readpass library (librpass, -lrpass) π«Ά
πΈ SYNOPSIS πΈ
#include <readpass.h>
char * readpass(const char * prompt, char display, size_t len);
π DESCRIPTION π
so the way readpass() works is it reads a password in from standard input. like, it's the main character of your little password prompt moment β¨
here's the tea, step by step:
- it displays the
promptso your user knows what's up - it turns off character echo β no peeking π
- it reads the password string of up to
lennumber of characters, or till it hits a newline character, whichever occurs first
and while it's reading the password, readpass shows the display character instead of the actual input the user typed in (you know, the classic * situation π), and then it turns the character echo back on when it's done. slay.
π₯ RETURN VALUE π₯
readpass returns a pointer to a dynamically allocated buffer holding the password, or NULL otherwise. that's it, that's the return π
β οΈ NOTE β οΈ
okay listen, two things, and they matter:
the pointer it returns points to the password in its clear text form. so like... it is not encrypted, it is not hidden, it's just sitting there in plain text. user should take care of its confidentiality. protect it with your life bestie π
secondly β and this is the one everyone forgets β don't forget to release the memory (free(3)) that readpass allocated to store the password. if you don't free it, that's a leak, and leaks are not cute. π¦
π BUGS π
if you encounter any problems/bugs in working of readpass(), please send an email to <pj.pandit AT yahoo.co.in> mentioning about the problem/bug. and while doing so, do include the string 'readpass()' in the subject line β like, actually do it, that's how they know what you're on about π
π SEE ALSO π
tlock(1) Β· free(3) Β· crypt(3)
π AUTHOR π
Prasad J Pandit <pj.pandit AT yahoo.co.in>
so yeah, that's readpass(3) from the Library Functions Manual β go read some passwords responsibly, free your memory, and stay iconic. periodt. ππβ¨
π¦ where this page comes from
- fedora 43: tlock-devel 1.6-25.fc43 Β· GPL-2.0-or-later
- fedora 43: tlock-devel 1.6-25.fc43 Β· GPL-2.0-or-later
- fedora 44: tlock-devel 1.6-26.fc44 Β· GPL-2.0-or-later
- fedora 44: tlock-devel 1.6-26.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms