Package: pnopaste-cli Version: 1.5-2 Severity: Wishlist Tags: patch
Using nopaste-it with our internal pnopaste, which is behind HTTP auth, fails with a 401 Unauthorized response.
I have added code from LWP's HEAD to prompt for a password if STDIN is a tty.
-- System Information: Debian Release: 8.4 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages pnopaste-cli depends on: ii libwww-perl 6.08-1 ii perl 5.20.2-3+deb8u4 pnopaste-cli recommends no packages. Versions of packages pnopaste-cli suggests: pn pnopaste <none> -- no debconf information -- Dave Page, Operations Team Manager, Senior Systems Engineer, Codethink Ltd Telephone: +44 7762 840 414 302 Ducie House, Ducie Street http://www.codethink.co.uk/ Manchester, M1 2JW, United Kingdom
--- /usr/bin/nopaste-it 2013-10-25 10:25:49.000000000 +0100 +++ bin/nopaste-it 2016-06-20 16:41:56.500373252 +0100 @@ -9,6 +9,37 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +package Pnopaste::UserAgent; + +use parent 'LWP::UserAgent'; + +sub get_basic_credentials { + my ( $self, $realm, $uri, $isproxy ) = @_; + + if ( ! -t STDIN ) { + return (); + } + + # Taken by Dave Page <dave.p...@codethink.co.uk> + # from /usr/bin/HEAD + # Copyright 1995-1999 Gisle Aas <gi...@aas.no> + + my $netloc = $uri->host_port; + print STDERR "Enter username for $realm at $netloc: "; + my $user = <STDIN>; + chomp($user); + return (undef, undef) unless length $user; + print STDERR "Password: "; + system("stty -echo"); + my $password = <STDIN>; + system("stty echo"); + print STDERR "\n"; # because we disabled echo + chomp($password); + return ($user, $password); +} + +package main; + use warnings; use strict; use Getopt::Long; @@ -136,7 +167,7 @@ } -my $Agent = LWP::UserAgent->new; +my $Agent = Pnopaste::UserAgent->new; # Our name ;) $Agent->agent('Perl Nopaste Agent ' . $Build);