Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] wget: Add --ssh-askpass support
@ 2016-07-22 18:24 Liam R. Howlett
  2016-07-22 18:24 ` Liam R. Howlett
  2016-07-22 19:21 ` Burton, Ross
  0 siblings, 2 replies; 7+ messages in thread
From: Liam R. Howlett @ 2016-07-22 18:24 UTC (permalink / raw)
  To: openembedded-core; +Cc: Liam.Howlett

wget: Add --ssh-askpass support

This adds the --ssh-askpass option which is disabled by default.

--ssh-askpass will request the username and password for a given URL by
executing the external program pointed to by the environment variable
SSH_ASKPASS.  If the environment variable is not set, an error is
returned.  If an error occurs requesting the username or password, wget
will exit.

Upstream-Status: Pending

Liam R. Howlett (1):
  wget: Add --ssh-askpass support

 .../wget/0001-wget-Add-ssh-askpass-support.patch   | 221 +++++++++++++++++++++
 meta/recipes-extended/wget/wget_1.18.bb            |   1 +
 2 files changed, 222 insertions(+)
 create mode 100644 meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch

-- 
1.9.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] wget: Add --ssh-askpass support
  2016-07-22 18:24 [PATCH] wget: Add --ssh-askpass support Liam R. Howlett
@ 2016-07-22 18:24 ` Liam R. Howlett
  2016-07-26 13:38   ` Burton, Ross
  2016-07-22 19:21 ` Burton, Ross
  1 sibling, 1 reply; 7+ messages in thread
From: Liam R. Howlett @ 2016-07-22 18:24 UTC (permalink / raw)
  To: openembedded-core; +Cc: Liam.Howlett

This adds the --ssh-askpass option which is disabled by default.

--ssh-askpass will request the username and password for a given URL by
executing the external program pointed to by the environment variable
SSH_ASKPASS.  If the environment variable is not set, an error is
returned.  If an error occurs requesting the username or password, wget
will exit.

Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
---
 .../wget/0001-wget-Add-ssh-askpass-support.patch   | 221 +++++++++++++++++++++
 meta/recipes-extended/wget/wget_1.18.bb            |   1 +
 2 files changed, 222 insertions(+)
 create mode 100644 meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch

diff --git a/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch b/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
new file mode 100644
index 0000000..e402375
--- /dev/null
+++ b/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
@@ -0,0 +1,221 @@
+From a3af68bfabd210c47f136544061e0d030c618d81 Mon Sep 17 00:00:00 2001
+From: "Liam R. Howlett" <Liam.Howlett@WindRiver.com>
+Date: Fri, 22 Jul 2016 14:10:41 -0400
+Subject: [PATCH] wget: Add --ssh-askpass support
+
+This adds the --ssh-askpass option which is disabled by default.
+
+--ssh-askpass will request the username and password for a given URL by
+executing the external program pointed to by the environment variable
+SSH_ASKPASS.  If the environment variable is not set, an error is
+returned.  If an error occurs requesting the username or password, wget
+will exit.
+
+Upstream-Status: Pending
+
+Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
+---
+ src/init.c    |  3 ++
+ src/main.c    | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ src/options.h |  2 ++
+ src/url.c     |  6 ++++
+ src/url.h     |  1 +
+ 5 files changed, 104 insertions(+)
+
+diff --git a/src/init.c b/src/init.c
+index d043d83..886d701 100644
+--- a/src/init.c
++++ b/src/init.c
+@@ -322,6 +322,7 @@ static const struct {
+   { "user",             &opt.user,              cmd_string },
+   { "useragent",        NULL,                   cmd_spec_useragent },
+   { "useservertimestamps", &opt.useservertimestamps, cmd_boolean },
++  { "usesshaskpass", &opt.use_ssh_askpass, cmd_boolean},
+   { "verbose",          NULL,                   cmd_spec_verbose },
+   { "wait",             &opt.wait,              cmd_time },
+   { "waitretry",        &opt.waitretry,         cmd_time },
+@@ -392,6 +393,8 @@ defaults (void)
+   tmp = getenv ("no_proxy");
+   if (tmp)
+     opt.no_proxy = sepstring (tmp);
++  opt.use_ssh_askpass = false;
++  opt.ssh_askpass = getenv ("SSH_ASKPASS");
+   opt.prefer_family = prefer_none;
+   opt.allow_cache = true;
+   opt.if_modified_since = true;
+diff --git a/src/main.c b/src/main.c
+index e7d5c66..cf82d3c 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -415,6 +415,7 @@ static struct cmdline_option option_data[] =
+     { "unlink", 0, OPT_BOOLEAN, "unlink", -1 },
+     { "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 },
+     { "use-server-timestamps", 0, OPT_BOOLEAN, "useservertimestamps", -1 },
++    { "ssh-askpass", 0, OPT_BOOLEAN, "usesshaskpass", -1 },
+     { "user", 0, OPT_VALUE, "user", -1 },
+     { "user-agent", 'U', OPT_VALUE, "useragent", -1 },
+     { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 },
+@@ -691,6 +692,8 @@ Download:\n"),
+     N_("\
+        --ask-password              prompt for passwords\n"),
+     N_("\
++       --ssh-askpass               Use SSH_ASKPASS for credential requests\n"),
++    N_("\
+        --no-iri                    turn off IRI support\n"),
+     N_("\
+        --local-encoding=ENC        use ENC as the local encoding for IRIs\n"),
+@@ -1019,6 +1022,81 @@ prompt_for_password (void)
+   return getpass("");
+ }
+ 
++
++/* Execute external application SSH_ASKPASS which is stored in opt.ssh_askpass
++ */
++void
++run_ssh_askpass(const char *question, char **answer)
++{
++  char tmp[1024];
++  pid_t pid;
++  int com[2];
++
++  if (pipe(com) == -1)
++  {
++    fprintf(stderr, _("Cannot create pipe"));
++    exit (WGET_EXIT_GENERIC_ERROR);
++  }
++
++  pid = fork();
++  if (pid == -1)
++  {
++    fprintf(stderr, "Error forking SSH_ASKPASS");
++    exit (WGET_EXIT_GENERIC_ERROR);
++  }
++  else if (pid == 0)
++  {
++    /* Child */
++    dup2(com[1], STDOUT_FILENO);
++    close(com[0]);
++    close(com[1]);
++    fprintf(stdout, "test");
++    execlp("/usr/bin/strace", "-s256", "-otest.out", opt.ssh_askpass, question, (char*)NULL);
++    assert("Execlp failed!");
++  }
++  else
++  {
++    close(com[1]);
++    unsigned int bytes = read(com[0], tmp, sizeof(tmp));
++    if (!bytes)
++    {
++      fprintf(stderr,
++        _("Error reading response from SSH_ASKPASS %s %s\n"),
++        opt.ssh_askpass, question);
++      exit (WGET_EXIT_GENERIC_ERROR);
++    }
++    else if (bytes > 1)
++      *answer = strndup(tmp, bytes-1);
++  }
++}
++
++/* set the user name and password*/
++void
++ssh_askpass (struct url *u)
++{
++  static char question[1024];
++  
++  if (u->user == NULL || u->user[0] == '\0')
++  {
++    sprintf(question, "Username for '%s%s': ",
++        scheme_leading_string(u->scheme), u->host);
++    /* Prompt for username */
++    run_ssh_askpass(question, &u->user);
++    if (opt.recursive)
++      opt.user = strdup(u->user);
++  }
++
++  if (u->passwd == NULL || u->passwd[0] == '\0')
++  {
++    sprintf(question, "Password for '%s%s@%s': ",
++        scheme_leading_string(u->scheme), u->user,
++        u->host);
++    /* Prompt for password */
++    run_ssh_askpass(question, &u->passwd);
++    if (opt.recursive)
++      opt.passwd = strdup(u->passwd);
++  }
++}
+ /* Function that prints the line argument while limiting it
+    to at most line_length. prefix is printed on the first line
+    and an appropriate number of spaces are added on subsequent
+@@ -1702,6 +1780,16 @@ for details.\n\n"));
+         exit (WGET_EXIT_GENERIC_ERROR);
+     }
+ 
++  if (opt.use_ssh_askpass)
++  {
++    /* can't request credentials until the URL is known. */
++    if (opt.ssh_askpass == NULL || opt.ssh_askpass[0] == '\0')
++    {
++    fprintf(stderr, _("--ssh-askpass requires environment variable SSH_ASKPASS to be set.\n"));
++      exit(WGET_EXIT_GENERIC_ERROR);
++    }
++  }
++
+ #ifdef USE_WATT32
+   if (opt.wdebug)
+      dbug_init();
+@@ -1920,6 +2008,10 @@ only if outputting to a regular file.\n"));
+         }
+       else
+         {
++          if (opt.use_ssh_askpass)
++          {
++            ssh_askpass(url_parsed);
++          }
+           if ((opt.recursive || opt.page_requisites)
+               && ((url_scheme (*t) != SCHEME_FTP
+ #ifdef HAVE_SSL
+diff --git a/src/options.h b/src/options.h
+index a8c494b..977c150 100644
+--- a/src/options.h
++++ b/src/options.h
+@@ -130,6 +130,8 @@ struct options
+   char *user;                   /* Generic username */
+   char *passwd;                 /* Generic password */
+   bool ask_passwd;              /* Ask for password? */
++  bool use_ssh_askpass;         /* Use SSH_ASKPASS infrastructure */
++  char *ssh_askpass;            /* value of SSH_ASKPASS */
+ 
+   bool always_rest;             /* Always use REST. */
+   wgint start_pos;              /* Start position of a download. */
+diff --git a/src/url.c b/src/url.c
+index ec38d6f..c133d91 100644
+--- a/src/url.c
++++ b/src/url.c
+@@ -512,6 +512,12 @@ scheme_disable (enum url_scheme scheme)
+   supported_schemes[scheme].flags |= scm_disabled;
+ }
+ 
++const char *
++scheme_leading_string (enum url_scheme scheme)
++{
++  return supported_schemes[scheme].leading_string;
++}
++
+ /* Skip the username and password, if present in the URL.  The
+    function should *not* be called with the complete URL, but with the
+    portion after the scheme.
+diff --git a/src/url.h b/src/url.h
+index 7c77737..bf2e3f7 100644
+--- a/src/url.h
++++ b/src/url.h
+@@ -124,6 +124,7 @@ bool url_has_scheme (const char *);
+ bool url_valid_scheme (const char *);
+ int scheme_default_port (enum url_scheme);
+ void scheme_disable (enum url_scheme);
++const char *scheme_leading_string(enum url_scheme);
+ 
+ char *url_string (const struct url *, enum url_auth_mode);
+ char *url_file_name (const struct url *, char *);
+-- 
+1.9.1
+
diff --git a/meta/recipes-extended/wget/wget_1.18.bb b/meta/recipes-extended/wget/wget_1.18.bb
index c969b98..20ec503 100644
--- a/meta/recipes-extended/wget/wget_1.18.bb
+++ b/meta/recipes-extended/wget/wget_1.18.bb
@@ -1,5 +1,6 @@
 SRC_URI = "${GNU_MIRROR}/wget/wget-${PV}.tar.gz \
            file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
+           file://0001-Add-ssh-askpass-support.patch \
           "
 
 SRC_URI[md5sum] = "fc2debd8399e3b933a9b226794e2a886"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] wget: Add --ssh-askpass support
  2016-07-22 18:24 [PATCH] wget: Add --ssh-askpass support Liam R. Howlett
  2016-07-22 18:24 ` Liam R. Howlett
@ 2016-07-22 19:21 ` Burton, Ross
  2016-07-22 20:06   ` Mark Hatle
  2016-07-25 16:06   ` Liam R. Howlett
  1 sibling, 2 replies; 7+ messages in thread
From: Burton, Ross @ 2016-07-22 19:21 UTC (permalink / raw)
  To: Liam R. Howlett; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

On 22 July 2016 at 19:24, Liam R. Howlett <Liam.Howlett@windriver.com>
wrote:

> wget: Add --ssh-askpass support
>
> This adds the --ssh-askpass option which is disabled by default.
>
> --ssh-askpass will request the username and password for a given URL by
> executing the external program pointed to by the environment variable
> SSH_ASKPASS.  If the environment variable is not set, an error is
> returned.  If an error occurs requesting the username or password, wget
> will exit.
>
> Upstream-Status: Pending
>

That's a fairly big patch to be carrying and forward porting everytime they
release, have you sent this upstream?

Ross

[-- Attachment #2: Type: text/html, Size: 1097 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] wget: Add --ssh-askpass support
  2016-07-22 19:21 ` Burton, Ross
@ 2016-07-22 20:06   ` Mark Hatle
  2016-07-25 16:06   ` Liam R. Howlett
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Hatle @ 2016-07-22 20:06 UTC (permalink / raw)
  To: openembedded-core

On 7/22/16 2:21 PM, Burton, Ross wrote:
> 
> On 22 July 2016 at 19:24, Liam R. Howlett <Liam.Howlett@windriver.com
> <mailto:Liam.Howlett@windriver.com>> wrote:
> 
>     wget: Add --ssh-askpass support
> 
>     This adds the --ssh-askpass option which is disabled by default.
> 
>     --ssh-askpass will request the username and password for a given URL by
>     executing the external program pointed to by the environment variable
>     SSH_ASKPASS.  If the environment variable is not set, an error is
>     returned.  If an error occurs requesting the username or password, wget
>     will exit.
> 
>     Upstream-Status: Pending
> 
> 
> That's a fairly big patch to be carrying and forward porting everytime they
> release, have you sent this upstream?

That is actually one of the problem we're having.  Trying to figure out "where"
upstream actually is.. thus the 'pending'.

We suspect the right list is the 'bug-wget' list, even though this isn't a new
bug -- bug a feature.

--Mark

> Ross
> 
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] wget: Add --ssh-askpass support
  2016-07-22 19:21 ` Burton, Ross
  2016-07-22 20:06   ` Mark Hatle
@ 2016-07-25 16:06   ` Liam R. Howlett
  1 sibling, 0 replies; 7+ messages in thread
From: Liam R. Howlett @ 2016-07-25 16:06 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

* Burton, Ross <ross.burton@intel.com> [160722 15:21]:
> On 22 July 2016 at 19:24, Liam R. Howlett <Liam.Howlett@windriver.com>
> wrote:
> 
> > wget: Add --ssh-askpass support
> >
> > This adds the --ssh-askpass option which is disabled by default.
> >
> > --ssh-askpass will request the username and password for a given URL by
> > executing the external program pointed to by the environment variable
> > SSH_ASKPASS.  If the environment variable is not set, an error is
> > returned.  If an error occurs requesting the username or password, wget
> > will exit.
> >
> > Upstream-Status: Pending
> >
> 
> That's a fairly big patch to be carrying and forward porting everytime they
> release, have you sent this upstream?

Yes.  I am working with upstream to get this patch integrated.

Thanks,
Liam

> 
> Ross


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] wget: Add --ssh-askpass support
  2016-07-22 18:24 ` Liam R. Howlett
@ 2016-07-26 13:38   ` Burton, Ross
  2016-07-27 14:08     ` Liam R. Howlett
  0 siblings, 1 reply; 7+ messages in thread
From: Burton, Ross @ 2016-07-26 13:38 UTC (permalink / raw)
  To: Liam R. Howlett; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]

On 22 July 2016 at 19:24, Liam R. Howlett <Liam.Howlett@windriver.com>
wrote:

> diff --git a/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
> b/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
> new file mode 100644
> index 0000000..e402375
> --- /dev/null
> +++ b/meta/recipes-extended/wget/wget/0001-wget
> -Add-ssh-askpass-support.patch
> [snip]
>


> diff --git a/meta/recipes-extended/wget/wget_1.18.bb
> b/meta/recipes-extended/wget/wget_1.18.bb
> index c969b98..20ec503 100644
> --- a/meta/recipes-extended/wget/wget_1.18.bb
> +++ b/meta/recipes-extended/wget/wget_1.18.bb
> @@ -1,5 +1,6 @@
>  SRC_URI = "${GNU_MIRROR}/wget/wget-${PV}.tar.gz \
>
> file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
> +           file://0001-Add-ssh-askpass-support.patch \


As the patch and the SRC_URI don't match, this patch clearly hasn't been
tested.

Also if you're working with upstream then please change the Upstream-Status
to Submitted and provide a link (mailing list post, bug entry, whatever).

Ross

[-- Attachment #2: Type: text/html, Size: 2379 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] wget: Add --ssh-askpass support
  2016-07-26 13:38   ` Burton, Ross
@ 2016-07-27 14:08     ` Liam R. Howlett
  0 siblings, 0 replies; 7+ messages in thread
From: Liam R. Howlett @ 2016-07-27 14:08 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

* Burton, Ross <ross.burton@intel.com> [160726 09:38]:
> On 22 July 2016 at 19:24, Liam R. Howlett <Liam.Howlett@windriver.com>
> wrote:
> 
> > diff --git a/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
> > b/meta/recipes-extended/wget/wget/0001-wget-Add-ssh-askpass-support.patch
> > new file mode 100644
> > index 0000000..e402375
> > --- /dev/null
> > +++ b/meta/recipes-extended/wget/wget/0001-wget
> > -Add-ssh-askpass-support.patch
> > [snip]
> >
> 
> 
> > diff --git a/meta/recipes-extended/wget/wget_1.18.bb
> > b/meta/recipes-extended/wget/wget_1.18.bb
> > index c969b98..20ec503 100644
> > --- a/meta/recipes-extended/wget/wget_1.18.bb
> > +++ b/meta/recipes-extended/wget/wget_1.18.bb
> > @@ -1,5 +1,6 @@
> >  SRC_URI = "${GNU_MIRROR}/wget/wget-${PV}.tar.gz \
> >
> > file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
> > +           file://0001-Add-ssh-askpass-support.patch \
> 
> 
> As the patch and the SRC_URI don't match, this patch clearly hasn't been
> tested.
> 

Apologies for the SRC_URI mismatch.  I had tested my patch but during my
development, I clarified my commit message which changed the filename.
I did not update the include file SRC_URI and had left the old file in
place while I tested.  I will resend a new version as soon as upstream
is happy.

> Also if you're working with upstream then please change the Upstream-Status
> to Submitted and provide a link (mailing list post, bug entry, whatever).

There was a question as to where to send the patch and I wanted to get
your input for new revisions as well.  I will update the status with a
link on the next revision.

I appreciate your input.

Thanks,
Liam

> 
> Ross


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-27 14:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-22 18:24 [PATCH] wget: Add --ssh-askpass support Liam R. Howlett
2016-07-22 18:24 ` Liam R. Howlett
2016-07-26 13:38   ` Burton, Ross
2016-07-27 14:08     ` Liam R. Howlett
2016-07-22 19:21 ` Burton, Ross
2016-07-22 20:06   ` Mark Hatle
2016-07-25 16:06   ` Liam R. Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox