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