108 |
if (cfile == NULL) |
if (cfile == NULL) |
109 |
{ |
{ |
110 |
if (errno != ENOENT) |
if (errno != ENOENT) |
111 |
warn("%s", buf); |
error (0, errno, "%s", buf); |
112 |
return (0); |
return (0); |
113 |
} |
} |
114 |
|
|
161 |
if (*aname == 0) |
if (*aname == 0) |
162 |
{ |
{ |
163 |
*aname = xmalloc((unsigned) strlen(tokval) + 1); |
*aname = xmalloc((unsigned) strlen(tokval) + 1); |
164 |
(void) strcpy(*aname, tokval); |
strcpy(*aname, tokval); |
165 |
} |
} |
166 |
else |
else |
167 |
{ |
{ |
174 |
&& fstat(fileno(cfile), &stb) >= 0 |
&& fstat(fileno(cfile), &stb) >= 0 |
175 |
&& (stb.st_mode & 077) != 0) |
&& (stb.st_mode & 077) != 0) |
176 |
{ |
{ |
177 |
warnx("Error: .netrc file is readable by others."); |
error (0, 0, "Error: .netrc file is readable by others."); |
178 |
warnx("Remove password or make file unreadable by others."); |
error (0, 0, "Remove password or make file unreadable by others."); |
179 |
goto bad; |
goto bad; |
180 |
} |
} |
181 |
if (token() && *apass == 0) |
if (token() && *apass == 0) |
182 |
{ |
{ |
183 |
*apass = xmalloc((unsigned) strlen(tokval) + 1); |
*apass = xmalloc((unsigned) strlen(tokval) + 1); |
184 |
(void) strcpy(*apass, tokval); |
strcpy(*apass, tokval); |
185 |
} |
} |
186 |
break; |
break; |
187 |
case ACCOUNT: |
case ACCOUNT: |
188 |
if (fstat(fileno(cfile), &stb) >= 0 |
if (fstat(fileno(cfile), &stb) >= 0 |
189 |
&& (stb.st_mode & 077) != 0) |
&& (stb.st_mode & 077) != 0) |
190 |
{ |
{ |
191 |
warnx("Error: .netrc file is readable by others."); |
error (0, 0, "Error: .netrc file is readable by others."); |
192 |
warnx("Remove account or make file unreadable by others."); |
error (0, 0, "Remove account or make file unreadable by others."); |
193 |
goto bad; |
goto bad; |
194 |
} |
} |
195 |
if (token() && *aacct == 0) |
if (token() && *aacct == 0) |
196 |
{ |
{ |
197 |
*aacct = xmalloc((unsigned) strlen(tokval) + 1); |
*aacct = xmalloc((unsigned) strlen(tokval) + 1); |
198 |
(void) strcpy(*aacct, tokval); |
strcpy(*aacct, tokval); |
199 |
} |
} |
200 |
break; |
break; |
201 |
case MACDEF: |
case MACDEF: |
270 |
} |
} |
271 |
break; |
break; |
272 |
default: |
default: |
273 |
warnx("Unknown .netrc keyword %s", tokval); |
error (0, 0, "Unknown .netrc keyword %s", tokval); |
274 |
break; |
break; |
275 |
} |
} |
276 |
goto done; |
goto done; |
277 |
} |
} |
278 |
done: |
done: |
279 |
(void) fclose(cfile); |
fclose(cfile); |
280 |
if (myname) |
if (myname) |
281 |
free (myname); |
free (myname); |
282 |
return (0); |
return (0); |
283 |
bad: |
bad: |
284 |
(void) fclose(cfile); |
fclose(cfile); |
285 |
if (myname) |
if (myname) |
286 |
free (myname); |
free (myname); |
287 |
return (-1); |
return (-1); |