]> git.pld-linux.org Git - packages/wget.git/blame - user.xdg.origin.url.patch
update BR
[packages/wget.git] / user.xdg.origin.url.patch
CommitLineData
4e0229b5
ER
1From 2c968b81d9d9c4025379242b5f560aab441e1430 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Mantas=20Mikul=C4=97nas?= <grawity@gmail.com>
3Date: Sat, 7 Dec 2013 20:45:00 +0200
4Subject: [PATCH] Set the 'user.xdg.origin.url' xattr for downloaded files
5
6---
7 src/ftp.c | 2 ++
8 src/http.c | 2 ++
9 src/url.c | 20 ++++++++++++++++++++
10 src/url.h | 4 ++++
11 4 files changed, 28 insertions(+)
12
13diff --git a/src/ftp.c b/src/ftp.c
14index 1902242..eeffd88 100644
15--- a/src/ftp.c
16+++ b/src/ftp.c
17@@ -1299,6 +1299,8 @@ Error in server response, closing control connection.\n"));
18 else
19 fp = output_stream;
20
21+ set_xa (u, fileno(fp));
22+
23 if (passed_expected_bytes)
24 {
25 print_length (passed_expected_bytes, restval, true);
26diff --git a/src/http.c b/src/http.c
27index 53c9818..c99c417 100644
28--- a/src/http.c
29+++ b/src/http.c
30@@ -3123,6 +3123,8 @@ read_header:
31 return err;
32 }
33
34+ set_xa (u, fileno(fp));
35+
36 err = read_response_body (hs, sock, fp, contlen, contrange,
37 chunked_transfer_encoding,
38 u->url, warc_timestamp_str,
39diff --git a/src/url.c b/src/url.c
40index df63e1c..b41d5ac 100644
41--- a/src/url.c
42+++ b/src/url.c
43@@ -37,6 +37,7 @@ as that of the covered work. */
44 #include <unistd.h>
45 #include <errno.h>
46 #include <assert.h>
47+#include <attr/xattr.h>
48
49 #include "utils.h"
50 #include "url.h"
51@@ -2200,6 +2201,25 @@ are_urls_equal (const char *u1, const char *u2)
52 return (*p == 0 && *q == 0 ? true : false);
53 }
54
55+int
56+set_xa (const struct url *origin, int fd)
57+{
58+ const char *url;
59+ int res;
60+
61+ url = url_string(origin, URL_AUTH_HIDE);
62+ res = fsetxattr(fd, XA_ORIGIN, url, strlen(url), 0);
63+ if (res != 0)
64+ {
65+ if (errno == ENOTSUP)
66+ res = 0;
67+ else
68+ logprintf (LOG_NOTQUIET, "fsetxattr: %s\n", strerror (errno));
69+ }
70+
71+ return res;
72+}
73+
74 #ifdef TESTING
75 /* Debugging and testing support for path_simplify. */
76
77diff --git a/src/url.h b/src/url.h
78index b1c46c1..72234e9 100644
79--- a/src/url.h
80+++ b/src/url.h
81@@ -132,4 +132,8 @@ bool schemes_are_similar_p (enum url_scheme a, enum url_scheme b);
82
83 bool are_urls_equal (const char *u1, const char *u2);
84
85+#define XA_ORIGIN "user.xdg.origin.url"
86+
87+int set_xa (const struct url *, int);
88+
89 #endif /* URL_H */
90--
912.3.3
92
93
9a092d10
ER
94commit 8a15b84d4be480514c650db1a34cbb2122d6590d
95Author: Mantas Mikulėnas <grawity@gmail.com>
96Date: Tue Jun 30 14:56:59 2015 +0300
97
98 Ignore 'Operation not permitted' when writing to /dev/null
99
100diff --git a/src/url.c b/src/url.c
101index 30cb86f..cff8683 100644
102--- a/src/url.c
103+++ b/src/url.c
104@@ -2242,7 +2242,7 @@ set_xa (const struct url *origin, int fd)
105 res = fsetxattr(fd, XA_ORIGIN, url, strlen(url), 0);
106 if (res != 0)
107 {
108- if (errno == ENOTSUP)
109+ if (errno == ENOTSUP || errno == EPERM)
110 res = 0;
111 else
112 logprintf (LOG_NOTQUIET, "fsetxattr: %s\n", strerror (errno));
113
This page took 0.063555 seconds and 4 git commands to generate.