Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Masking the password entered by the user Date: Tue, 07 Feb 2017 12:16:46 -0800 Organization: None to speak of Lines: 32 Message-ID: References: <6fb9a4db-5cba-479c-8ee6-82b7146a2e38@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="04056ce4c9c7dd85ee7ce897aab9f52a"; logging-data="23918"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/slZHzyoe0b/h7gHL4R9g/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:w+MC1V3o2t6KQffZivg7zh2Hnc0= sha1:0s0SMvv7qn9O/qQFnZQa+lw0q4o= Xref: csiph.com comp.lang.c:103415 Alla _ writes: [...] > I see. Then I just leave it as it is, keeping in mind that I have to constantly > change my root password, as the one I have now I have used numerous > times and it's there on the Terminal. Not really a C issue, but I personally would avoid anything that leaves a password, particularly a root password, on the screen in plain text. If your application needs to ask for a password, I suggest finding a way to do it using POSIX features. Some of the methods suggested in FAQ 19.1 are probably POSIX-compliant. The most straightforward approach is probably something like: fputs("Enter password: ", stdout); fflush(stdout); system("stty -echo"); fgets(password, sizeof password, stdin); system("stty echo"); /* deal with '\n' */ It might be better to do something a bit lower level. comp.unix.programmer would be a good place to ask (check for a FAQ list first, this kind of thing would likely be covered). [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"