login_prompt: Simplify login_prompt API
The only user of login_prompt is the login tool. This implies that the first argument is always the same. It is much easier to verify printf's format string and its argument if both are next to each other. Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
This commit is contained in:
parent
3010ec11ae
commit
7109b7c066
@ -233,7 +233,7 @@ extern void dolastlog (
|
|||||||
extern int login_access (const char *user, const char *from);
|
extern int login_access (const char *user, const char *from);
|
||||||
|
|
||||||
/* loginprompt.c */
|
/* loginprompt.c */
|
||||||
extern void login_prompt (const char *, char *, int);
|
extern void login_prompt (char *, int);
|
||||||
|
|
||||||
/* mail.c */
|
/* mail.c */
|
||||||
extern void mailcheck (void);
|
extern void mailcheck (void);
|
||||||
|
@ -32,7 +32,7 @@ static void login_exit (unused int sig)
|
|||||||
* is set in login.defs, this file is displayed before the prompt.
|
* is set in login.defs, this file is displayed before the prompt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void login_prompt (const char *prompt, char *name, int namesize)
|
void login_prompt (char *name, int namesize)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
@ -41,6 +41,7 @@ void login_prompt (const char *prompt, char *name, int namesize)
|
|||||||
char *cp;
|
char *cp;
|
||||||
int i;
|
int i;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
const char *fname = getdef_str ("ISSUE_FILE");
|
||||||
|
|
||||||
sighandler_t sigquit;
|
sighandler_t sigquit;
|
||||||
sighandler_t sigtstp;
|
sighandler_t sigtstp;
|
||||||
@ -59,8 +60,6 @@ void login_prompt (const char *prompt, char *name, int namesize)
|
|||||||
* be displayed and display it before the prompt.
|
* be displayed and display it before the prompt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (NULL != prompt) {
|
|
||||||
const char *fname = getdef_str ("ISSUE_FILE");
|
|
||||||
if (NULL != fname) {
|
if (NULL != fname) {
|
||||||
fp = fopen (fname, "r");
|
fp = fopen (fname, "r");
|
||||||
if (NULL != fp) {
|
if (NULL != fp) {
|
||||||
@ -72,9 +71,8 @@ void login_prompt (const char *prompt, char *name, int namesize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) gethostname (buf, sizeof buf);
|
(void) gethostname (buf, sizeof buf);
|
||||||
printf (prompt, buf);
|
printf (_("\n%s login: "), buf);
|
||||||
(void) fflush (stdout);
|
(void) fflush (stdout);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the user's response. The trailing newline will be
|
* Read the user's response. The trailing newline will be
|
||||||
|
@ -910,7 +910,7 @@ int main (int argc, char **argv)
|
|||||||
preauth_flag = false;
|
preauth_flag = false;
|
||||||
username = XMALLOCARRAY (USER_NAME_MAX_LENGTH + 1, char);
|
username = XMALLOCARRAY (USER_NAME_MAX_LENGTH + 1, char);
|
||||||
username[USER_NAME_MAX_LENGTH] = '\0';
|
username[USER_NAME_MAX_LENGTH] = '\0';
|
||||||
login_prompt (_("\n%s login: "), username, USER_NAME_MAX_LENGTH);
|
login_prompt (username, USER_NAME_MAX_LENGTH);
|
||||||
|
|
||||||
if ('\0' == username[0]) {
|
if ('\0' == username[0]) {
|
||||||
/* Prompt for a new login */
|
/* Prompt for a new login */
|
||||||
|
Loading…
Reference in New Issue
Block a user