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