summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorse <se@FreeBSD.org>1998-07-12 09:07:36 +0000
committerse <se@FreeBSD.org>1998-07-12 09:07:36 +0000
commitcc6b01dc7224c41c8fcfa81084bc73c5cd5ab960 (patch)
tree057655bda420562f4dc71dd8e250d681801ee6f0 /usr.bin/fetch
parent5d983285b3e981a79fb1323695dd3fd491ce7484 (diff)
downloadFreeBSD-src-cc6b01dc7224c41c8fcfa81084bc73c5cd5ab960.zip
FreeBSD-src-cc6b01dc7224c41c8fcfa81084bc73c5cd5ab960.tar.gz
Fix proxy authorization code:
- failed to use authorization parameters passed in the environment, if /dev/tty could not be opened (i.e. if running from cron) - mixed use of /dev/tty and stdin for prompt and reading of the result
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/http.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c
index 7b9cb50..e29bd0f 100644
--- a/usr.bin/fetch/http.c
+++ b/usr.bin/fetch/http.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: http.c,v 1.17 1998/02/20 05:11:40 jb Exp $
+ * $Id: http.c,v 1.18 1998/05/09 20:50:37 wollman Exp $
*/
#include <sys/types.h>
@@ -1694,18 +1694,17 @@ basic_doauth(struct fetch_state *fs, struct http_auth *ha, int isproxy)
(ha->ha_params == 0 || strchr(ha->ha_params, ':') == 0))
return EX_NOPERM;
- fp = fopen("/dev/tty", "r+");
- if (fp == 0) {
- warn("opening /dev/tty");
- return EX_OSERR;
- }
if (ha->ha_params == 0) {
+ fp = fopen("/dev/tty", "r+");
+ if (fp == 0) {
+ warn("opening /dev/tty");
+ return EX_OSERR;
+ }
fprintf(fp, "Enter `basic' user name for realm `%s': ",
ha->ha_realm);
fflush(fp);
- user = fgetln(stdin, &userlen);
+ user = fgetln(fp, &userlen);
if (user == 0 || userlen < 1) { /* longer name? */
- fclose(fp);
return EX_NOPERM;
}
if (user[userlen - 1] == '\n')
@@ -1713,6 +1712,7 @@ basic_doauth(struct fetch_state *fs, struct http_auth *ha, int isproxy)
else
user[userlen] = '\0';
user = safe_strdup(user);
+ fclose(fp);
pass = 0;
} else if ((pass = strchr(ha->ha_params, ':')) == 0) {
user = safe_strdup(ha->ha_params);
OpenPOWER on IntegriCloud