]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_xattr: create the user.creator xattr attribute
authorDan Fandrich <dan@coneharvesters.com>
Wed, 9 Oct 2024 23:47:20 +0000 (16:47 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Fri, 11 Oct 2024 17:13:37 +0000 (10:13 -0700)
This indicates that the file was created by curl which can help a user
determine the origin of a file. Like the other attributes, this is only
enabled with the --xattr option.

Closes #15237

docs/cmdline-opts/xattr.md
src/tool_xattr.c
tests/data/test644
tests/data/test687
tests/data/test688

index 9dd7dc585f34929b67a2be8494dab8f103abe99e..0c3bb753ae5db02a2f08abff304f8e6bb6ac2e3c 100644 (file)
@@ -17,7 +17,7 @@ Example:
 # `--xattr`
 
 When saving output to a file, tell curl to store file metadata in extended
-file attributes. Currently, the URL is stored in the `xdg.origin.url`
-attribute and, for HTTP, the content type is stored in the `mime_type`
-attribute. If the file system does not support extended attributes, a warning
-is issued.
+file attributes. Currently, `curl` is stored in the `creator` attribute,
+the URL is stored in the `xdg.origin.url` attribute and, for HTTP, the content
+type is stored in the `mime_type` attribute. If the file system does not
+support extended attributes, a warning is issued.
index f832e24757a5586a44e42c1180b7a970e1a9d1db..299d5820786fa558d7ef80d414e82204ababe92f 100644 (file)
@@ -114,7 +114,7 @@ static int xattr(int fd,
 int fwrite_xattr(CURL *curl, const char *url, int fd)
 {
   int i = 0;
-  int err = 0;
+  int err = xattr(fd, "user.creator", "curl");
 
   /* loop through all xattr-curlinfo pairs and abort on a set error */
   while(!err && mappings[i].attr) {
index 2db24f9071311ecb6504c1df31b2bedd18b9e864..b055763a398bab26ed5722782bd8369d968ac083 100644 (file)
@@ -78,6 +78,7 @@ Accept: */*
 \r
 </protocol>
 <stdout mode="text">
+user.creator => curl
 user.mime_type => text/html
 user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
 </stdout>
index 6384a5e49970de401489cd11d5e9b07589b32636..28b8bee7eab75790f121dd0ded6fad9d9933f8b2 100644 (file)
@@ -55,6 +55,7 @@ Accept: */*
 \r
 </protocol>
 <stdout mode="text">
+user.creator => curl
 user.mime_type => fake/data
 user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
 </stdout>
index 4ade6edbc1ae1f271a0cb650f59c9cc47ebeb496..6fbd339fc0075b5d6df2b1fae2e8058325fd0d16 100644 (file)
@@ -55,6 +55,7 @@ Accept: */*
 \r
 </protocol>
 <stdout mode="text">
+user.creator => curl
 user.mime_type => fake/data
 user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
 </stdout>