From 1589d09ec365733ee746aa5caf33fea5748d5ea0 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 4 May 2008 21:00:18 +0000 Subject: [PATCH] Port from trunk: bug #23167: sbr/ruserpass.c (ruserpass): make bad permissions on .netrc be an instantly fatal error. Previously we returned an error value; however, no caller was checking it. So now ruserpass() has a void return type. --- ChangeLog | 5 +++++ h/prototypes.h | 2 +- sbr/ruserpass.c | 12 ++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf19730..fcac069 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ * Fixes ported from trunk: + * bug #23167: sbr/ruserpass.c (ruserpass): make bad permissions + on .netrc be an instantly fatal error. Previously we returned + an error value; however, no caller was checking it. So now + ruserpass() has a void return type. + * bug #23163: various minor fixes for the benefit of older Unixes (specifically SunOS 4): reintroduce strerror() substitute implementation diff --git a/h/prototypes.h b/h/prototypes.h index 2f4f651..52fab3a 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -98,7 +98,7 @@ char *pwd (void); char *r1bindex(char *, int); void readconfig (struct node **, FILE *, char *, int); int refile (char **, char *); -int ruserpass(char *, char **, char **); +void ruserpass(char *, char **, char **); int remdir (char *); int seq_addmsg (struct msgs *, char *, int, int, int); int seq_addsel (struct msgs *, char *, int, int); diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 36605be..5ed6fde 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -61,7 +61,7 @@ static struct toktab toktabs[] = { static int token(void); -int +void ruserpass(char *host, char **aname, char **apass) { char *hdir, buf[BUFSIZ]; @@ -108,9 +108,9 @@ match: case PASSWD: if (fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { - fprintf(stderr, "Error - .netrc file not correct mode.\n"); - fprintf(stderr, "Remove password or correct mode.\n"); - goto bad; + /* We make this a fatal error to force the user to correct it */ + advise(NULL, "Error - ~/.netrc file must not be world or group readable."); + adios(NULL, "Remove password or correct file permissions."); } if (token() && *apass == 0) { *apass = mh_xmalloc((size_t) strlen(tokval) + 1); @@ -173,10 +173,6 @@ done: strcpy (*apass, mypass); } - return(0); -bad: - fclose(cfile); - return(-1); } static int -- 1.7.10.4