|
|
aa6d84 |
From 83c408842b80b4ed26a3fe8a61177846dda18c60 Mon Sep 17 00:00:00 2001
|
|
|
aa6d84 |
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
|
|
|
aa6d84 |
Date: Wed, 26 Dec 2018 14:38:18 +0100
|
|
|
aa6d84 |
Subject: [PATCH] Don't save user/pw with --xattr
|
|
|
aa6d84 |
|
|
|
aa6d84 |
---
|
|
|
aa6d84 |
src/ftp.c | 2 +-
|
|
|
aa6d84 |
src/http.c | 4 ++--
|
|
|
aa6d84 |
src/xattr.c | 24 ++++++++++++++++++++----
|
|
|
aa6d84 |
src/xattr.h | 3 ++-
|
|
|
aa6d84 |
4 files changed, 25 insertions(+), 8 deletions(-)
|
|
|
aa6d84 |
|
|
|
aa6d84 |
diff --git a/src/ftp.c b/src/ftp.c
|
|
|
aa6d84 |
index daaae93..c02ed02 100644
|
|
|
aa6d84 |
--- a/src/ftp.c
|
|
|
aa6d84 |
+++ b/src/ftp.c
|
|
|
aa6d84 |
@@ -1580,7 +1580,7 @@ Error in server response, closing control connection.\n"));
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#ifdef ENABLE_XATTR
|
|
|
aa6d84 |
if (opt.enable_xattr)
|
|
|
aa6d84 |
- set_file_metadata (u->url, NULL, fp);
|
|
|
aa6d84 |
+ set_file_metadata (u, NULL, fp);
|
|
|
aa6d84 |
#endif
|
|
|
aa6d84 |
|
|
|
aa6d84 |
fd_close (local_sock);
|
|
|
aa6d84 |
diff --git a/src/http.c b/src/http.c
|
|
|
aa6d84 |
index 499a43b..18e58e9 100644
|
|
|
aa6d84 |
--- a/src/http.c
|
|
|
aa6d84 |
+++ b/src/http.c
|
|
|
aa6d84 |
@@ -4120,9 +4120,9 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
|
|
|
aa6d84 |
if (opt.enable_xattr)
|
|
|
aa6d84 |
{
|
|
|
aa6d84 |
if (original_url != u)
|
|
|
aa6d84 |
- set_file_metadata (u->url, original_url->url, fp);
|
|
|
aa6d84 |
+ set_file_metadata (u, original_url, fp);
|
|
|
aa6d84 |
else
|
|
|
aa6d84 |
- set_file_metadata (u->url, NULL, fp);
|
|
|
aa6d84 |
+ set_file_metadata (u, NULL, fp);
|
|
|
aa6d84 |
}
|
|
|
aa6d84 |
#endif
|
|
|
aa6d84 |
|
|
|
aa6d84 |
diff --git a/src/xattr.c b/src/xattr.c
|
|
|
aa6d84 |
index 6652422..0f20fad 100644
|
|
|
aa6d84 |
--- a/src/xattr.c
|
|
|
aa6d84 |
+++ b/src/xattr.c
|
|
|
aa6d84 |
@@ -21,6 +21,7 @@
|
|
|
aa6d84 |
#include <string.h>
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#include "log.h"
|
|
|
aa6d84 |
+#include "utils.h"
|
|
|
aa6d84 |
#include "xattr.h"
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#ifdef USE_XATTR
|
|
|
aa6d84 |
@@ -57,7 +58,7 @@ write_xattr_metadata (const char *name, const char *value, FILE *fp)
|
|
|
aa6d84 |
#endif /* USE_XATTR */
|
|
|
aa6d84 |
|
|
|
aa6d84 |
int
|
|
|
aa6d84 |
-set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp)
|
|
|
aa6d84 |
+set_file_metadata (const struct url *origin_url, const struct url *referrer_url, FILE *fp)
|
|
|
aa6d84 |
{
|
|
|
aa6d84 |
/* Save metadata about where the file came from (requested, final URLs) to
|
|
|
aa6d84 |
* user POSIX Extended Attributes of retrieved file.
|
|
|
aa6d84 |
@@ -67,13 +68,28 @@ set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp)
|
|
|
aa6d84 |
* [http://0pointer.de/lennart/projects/mod_mime_xattr/].
|
|
|
aa6d84 |
*/
|
|
|
aa6d84 |
int retval = -1;
|
|
|
aa6d84 |
+ char *value;
|
|
|
aa6d84 |
|
|
|
aa6d84 |
if (!origin_url || !fp)
|
|
|
aa6d84 |
return retval;
|
|
|
aa6d84 |
|
|
|
aa6d84 |
- retval = write_xattr_metadata ("user.xdg.origin.url", escnonprint_uri (origin_url), fp);
|
|
|
aa6d84 |
- if ((!retval) && referrer_url)
|
|
|
aa6d84 |
- retval = write_xattr_metadata ("user.xdg.referrer.url", escnonprint_uri (referrer_url), fp);
|
|
|
aa6d84 |
+ value = url_string (origin_url, URL_AUTH_HIDE);
|
|
|
aa6d84 |
+ retval = write_xattr_metadata ("user.xdg.origin.url", escnonprint_uri (value), fp);
|
|
|
aa6d84 |
+ xfree (value);
|
|
|
aa6d84 |
+
|
|
|
aa6d84 |
+ if (!retval && referrer_url)
|
|
|
aa6d84 |
+ {
|
|
|
aa6d84 |
+ struct url u;
|
|
|
aa6d84 |
+
|
|
|
aa6d84 |
+ memset(&u, 0, sizeof(u));
|
|
|
aa6d84 |
+ u.scheme = referrer_url->scheme;
|
|
|
aa6d84 |
+ u.host = referrer_url->host;
|
|
|
aa6d84 |
+ u.port = referrer_url->port;
|
|
|
aa6d84 |
+
|
|
|
aa6d84 |
+ value = url_string (&u, 0);
|
|
|
aa6d84 |
+ retval = write_xattr_metadata ("user.xdg.referrer.url", escnonprint_uri (value), fp);
|
|
|
aa6d84 |
+ xfree (value);
|
|
|
aa6d84 |
+ }
|
|
|
aa6d84 |
|
|
|
aa6d84 |
return retval;
|
|
|
aa6d84 |
}
|
|
|
aa6d84 |
diff --git a/src/xattr.h b/src/xattr.h
|
|
|
aa6d84 |
index 10f3ed1..40c7a8d 100644
|
|
|
aa6d84 |
--- a/src/xattr.h
|
|
|
aa6d84 |
+++ b/src/xattr.h
|
|
|
aa6d84 |
@@ -16,12 +16,13 @@
|
|
|
aa6d84 |
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#include <stdio.h>
|
|
|
aa6d84 |
+#include <url.h>
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#ifndef _XATTR_H
|
|
|
aa6d84 |
#define _XATTR_H
|
|
|
aa6d84 |
|
|
|
aa6d84 |
/* Store metadata name/value attributes against fp. */
|
|
|
aa6d84 |
-int set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp);
|
|
|
aa6d84 |
+int set_file_metadata (const struct url *origin_url, const struct url *referrer_url, FILE *fp);
|
|
|
aa6d84 |
|
|
|
aa6d84 |
#if defined(__linux)
|
|
|
aa6d84 |
/* libc on Linux has fsetxattr (5 arguments). */
|
|
|
aa6d84 |
--
|
|
|
aa6d84 |
2.17.2
|
|
|
aa6d84 |
|