X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fruserpass.c;h=5ed6fde207b30d97b85b6a3316f3ad6d4897b8f4;hb=3bf07d227725f798f654ac09f015f35d27ab83cb;hp=9e50da68d60b807d04f17e7ead4b7d187085f4c7;hpb=9744555b38947913e094380962ef0774b7c32e8f;p=mmh diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 9e50da6..5ed6fde 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -19,6 +19,7 @@ */ #include +#include #include #include @@ -60,13 +61,12 @@ static struct toktab toktabs[] = { static int token(void); -int +void ruserpass(char *host, char **aname, char **apass) { char *hdir, buf[BUFSIZ]; int t, usedefault = 0; struct stat stb; - extern int errno; hdir = getenv("HOME"); if (hdir == NULL) @@ -92,7 +92,7 @@ ruserpass(char *host, char **aname, char **apass) /* * Allow match either for user's host name. */ - if (strcasecmp(host, tokval) == 0) + if (mh_strcasecmp(host, tokval) == 0) goto match; continue; } @@ -101,19 +101,19 @@ match: switch(t) { case LOGIN: if (token() && *aname == 0) { - *aname = malloc((size_t) strlen(tokval) + 1); + *aname = mh_xmalloc((size_t) strlen(tokval) + 1); strcpy(*aname, tokval); } break; 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 = malloc((size_t) strlen(tokval) + 1); + *apass = mh_xmalloc((size_t) strlen(tokval) + 1); strcpy(*apass, tokval); } break; @@ -154,7 +154,7 @@ done: myname = tmp; } - *aname = malloc((size_t) strlen(myname) + 1); + *aname = mh_xmalloc((size_t) strlen(myname) + 1); strcpy (*aname, myname); } @@ -169,14 +169,10 @@ done: mypass = *aname; } - *apass = malloc((size_t) strlen(mypass) + 1); + *apass = mh_xmalloc((size_t) strlen(mypass) + 1); strcpy (*apass, mypass); } - return(0); -bad: - fclose(cfile); - return(-1); } static int