|
|
4b6aa8 |
From 5b7d6f911920043671ef8aa0a9e559bfb6f3a3c8 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
Date: Tue, 30 Sep 2014 01:46:07 +0200
|
|
|
4b6aa8 |
Subject: [LIBREPORT PATCH 90/93] upload: read credentials from environment
|
|
|
4b6aa8 |
variables
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
We use environment variables for the per-user-configuration.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Adding new configuration options to the configuration file for
|
|
|
4b6aa8 |
credentials doesn't make sense because the credentials can be part of
|
|
|
4b6aa8 |
the URL (everything is plain text in the configuration file). But it
|
|
|
4b6aa8 |
does make sense to add a support for environment variables which are
|
|
|
4b6aa8 |
used to propagate the configuration from the GUI where the URL field is
|
|
|
4b6aa8 |
plain text but the password field cannot be read.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Related to rhbz#1066486
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Conflicts:
|
|
|
4b6aa8 |
doc/reporter-upload.txt
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
doc/reporter-upload.txt | 5 +++++
|
|
|
4b6aa8 |
src/plugins/report_Uploader.xml.in | 10 ++++++++++
|
|
|
4b6aa8 |
src/plugins/reporter-upload.c | 24 +++++++++++++++++++++++-
|
|
|
4b6aa8 |
3 files changed, 38 insertions(+), 1 deletion(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/doc/reporter-upload.txt b/doc/reporter-upload.txt
|
|
|
4b6aa8 |
index 8df7ea2..e813c58 100644
|
|
|
4b6aa8 |
--- a/doc/reporter-upload.txt
|
|
|
4b6aa8 |
+++ b/doc/reporter-upload.txt
|
|
|
4b6aa8 |
@@ -68,6 +68,11 @@ the configuration file.
|
|
|
4b6aa8 |
'Upload_URL'::
|
|
|
4b6aa8 |
The URL where should be the tarball uploaded.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+'Upload_Username'::
|
|
|
4b6aa8 |
+ User name for the upload URL
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+'Upload_Password'::
|
|
|
4b6aa8 |
+ Password for the upload URL
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
SEE ALSO
|
|
|
4b6aa8 |
--------
|
|
|
4b6aa8 |
diff --git a/src/plugins/report_Uploader.xml.in b/src/plugins/report_Uploader.xml.in
|
|
|
4b6aa8 |
index df01e21..a136aad 100644
|
|
|
4b6aa8 |
--- a/src/plugins/report_Uploader.xml.in
|
|
|
4b6aa8 |
+++ b/src/plugins/report_Uploader.xml.in
|
|
|
4b6aa8 |
@@ -19,6 +19,16 @@
|
|
|
4b6aa8 |
<_note-html>Examples:
ftp://[user[:pass]@]host/dir/[file.tar.gz]
scp://[user[:pass]@]host/dir/[file.tar.gz]
file:///dir/[file.tar.gz]</_note-html>
|
|
|
4b6aa8 |
<default-value></default-value>
|
|
|
4b6aa8 |
</option>
|
|
|
4b6aa8 |
+ <option type="text" name="Upload_Username">
|
|
|
4b6aa8 |
+ <_label>User name</_label>
|
|
|
4b6aa8 |
+ <allow-empty>no</allow-empty>
|
|
|
4b6aa8 |
+ <_description>Use this field if you do not want to have user name in URL</_description>
|
|
|
4b6aa8 |
+ </option>
|
|
|
4b6aa8 |
+ <option type="password" name="Upload_Password">
|
|
|
4b6aa8 |
+ <_label>Password</_label>
|
|
|
4b6aa8 |
+ <allow-empty>no</allow-empty>
|
|
|
4b6aa8 |
+ <_description>Use this field if you do not want to have password in URL</_description>
|
|
|
4b6aa8 |
+ </option>
|
|
|
4b6aa8 |
<advanced-options>
|
|
|
4b6aa8 |
<option type="text" name="http_proxy">
|
|
|
4b6aa8 |
<_label>HTTP Proxy</_label>
|
|
|
4b6aa8 |
diff --git a/src/plugins/reporter-upload.c b/src/plugins/reporter-upload.c
|
|
|
4b6aa8 |
index 7783557..f934953 100644
|
|
|
4b6aa8 |
--- a/src/plugins/reporter-upload.c
|
|
|
4b6aa8 |
+++ b/src/plugins/reporter-upload.c
|
|
|
4b6aa8 |
@@ -148,9 +148,31 @@ static int create_and_upload_archive(
|
|
|
4b6aa8 |
/* Upload from /tmp to /tmp + deletion -> BAD, exclude this possibility */
|
|
|
4b6aa8 |
if (url && url[0] && strcmp(url, "file://"LARGE_DATA_TMP_DIR"/") != 0)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
- char *remote_name = upload_file(url, tempfile);
|
|
|
4b6aa8 |
+ post_state_t *state = new_post_state(POST_WANT_ERROR_MSG);
|
|
|
4b6aa8 |
+ state->username = getenv("Upload_Username");
|
|
|
4b6aa8 |
+ char *password_inp = NULL;
|
|
|
4b6aa8 |
+ if (state->username != NULL && state->username[0] != '\0')
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ /* Load Password only if Username is configured, it doesn't make */
|
|
|
4b6aa8 |
+ /* much sense to load Password without Username. */
|
|
|
4b6aa8 |
+ state->password = getenv("Upload_Password");
|
|
|
4b6aa8 |
+ if (state->password == NULL && state->password[0] == '\0')
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ /* Be permissive and nice, ask only once and don't check */
|
|
|
4b6aa8 |
+ /* the result. User can dismiss this prompt but the upload */
|
|
|
4b6aa8 |
+ /* may work somehow??? */
|
|
|
4b6aa8 |
+ char *msg = xasprintf(_("Please enter password for uploading:"), state->username);
|
|
|
4b6aa8 |
+ state->password = password_inp = ask_password(msg);
|
|
|
4b6aa8 |
+ free(msg);
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+ char *remote_name = upload_file_ext(state, url, tempfile, UPLOAD_FILE_HANDLE_ACCESS_DENIALS);
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
result = (remote_name == NULL); /* error if NULL */
|
|
|
4b6aa8 |
free(remote_name);
|
|
|
4b6aa8 |
+ free(password_inp);
|
|
|
4b6aa8 |
+ free_post_state(state);
|
|
|
4b6aa8 |
/* cleanup code will delete tempfile */
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
else
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|