- /*
- * Allow match either for user's host name.
- */
- if (strcasecmp(host, tokval) == 0)
- goto match;
- continue;
- }
-match:
- while ((t = token()) && t != MACH && t != DEFAULT) {
- switch(t) {
- case LOGIN:
- if (token() && *aname == 0) {
- *aname = malloc((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;
- }
- if (token() && *apass == 0) {
- *apass = malloc((size_t) strlen(tokval) + 1);
- strcpy(*apass, tokval);
+ }
+ match:
+ while ((t = token(tokval)) && t != MACH && t != DEFAULT) {
+ switch(t) {
+ case LOGIN:
+ if (token(tokval) && *aname == 0)
+ *aname = mh_xstrdup(tokval);
+ break;
+
+ case PASSWD:
+ if (!credentials_no_perm_check &&
+ fstat(fileno(cfile), &stb) >= 0 &&
+ (stb.st_mode & 077) != 0) {
+ /* We make this a fatal error to force the
+ user to correct it. */
+ inform("group or other permissions, %#o, "
+ "forbidden: %s", stb.st_mode, credentials_file);
+ die("Remove password or correct file "
+ "permissions.");
+ }
+ if (token(tokval) && *apass == 0)
+ *apass = mh_xstrdup(tokval);
+ break;
+
+ case ACCOUNT:
+ break;
+
+ case MACDEF:
+ fclose(cfile);
+ return;
+
+ default:
+ fprintf(stderr,
+ "Unknown keyword %s in credentials file %s\n",
+ tokval, credentials_file);
+ break;