Solved

passwd routine

Posted on 1997-02-01
1
266 Views
Last Modified: 2013-12-26
how can i write a login/passwd prog in ANSI C in unix where
when the user type in the passwd, it is not echoed and the cursor doesn't even move? just like login on to a unix system? all i know is that termios.h must be included? thanx
0
Comment
Question by:wilddream
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
ian010997 earned 50 total points
ID: 1292181
#define _POSIX_SOURCE 1

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/wait.h>


/*
 * Prototypes
 */

int getpswd(char *, unsigned);

/*************************************************************************/

int getpswd(char *buff, unsigned size)
{
struct termios attr;
int     n;

printf("Password: ");
fflush(stdout);
if(tcgetattr(STDIN_FILENO, &attr) != 0) return(-1);
attr.c_lflag &= ~(ECHO);
if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr) != 0) return(-1);
n = read(STDIN_FILENO, buff, size);
attr.c_lflag |= ECHO;
if(tcsetattr(STDIN_FILENO, TCSANOW, &attr) != 0) return(-1);
printf("\n");
return(n);
} /* getpswd */

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 197
maxBlock challenge 30 151
Prevent this page from creating additional dialogs. 3 794
building a service to accessed via telnet client, want colors ? 4 109
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question