From 954177b9da1cbf7175bf6ab7a3b9899fcf49788c Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 9 Oct 2024 16:47:20 -0700 Subject: [PATCH] tool_xattr: create the user.creator xattr attribute 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 | 8 ++++---- src/tool_xattr.c | 2 +- tests/data/test644 | 1 + tests/data/test687 | 1 + tests/data/test688 | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/cmdline-opts/xattr.md b/docs/cmdline-opts/xattr.md index 9dd7dc585f..0c3bb753ae 100644 --- a/docs/cmdline-opts/xattr.md +++ b/docs/cmdline-opts/xattr.md @@ -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. diff --git a/src/tool_xattr.c b/src/tool_xattr.c index f832e24757..299d582078 100644 --- a/src/tool_xattr.c +++ b/src/tool_xattr.c @@ -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) { diff --git a/tests/data/test644 b/tests/data/test644 index 2db24f9071..b055763a39 100644 --- a/tests/data/test644 +++ b/tests/data/test644 @@ -78,6 +78,7 @@ Accept: */* +user.creator => curl user.mime_type => text/html user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test687 b/tests/data/test687 index 6384a5e499..28b8bee7ea 100644 --- a/tests/data/test687 +++ b/tests/data/test687 @@ -55,6 +55,7 @@ Accept: */* +user.creator => curl user.mime_type => fake/data user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test688 b/tests/data/test688 index 4ade6edbc1..6fbd339fc0 100644 --- a/tests/data/test688 +++ b/tests/data/test688 @@ -55,6 +55,7 @@ Accept: */* +user.creator => curl user.mime_type => fake/data user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER -- 2.47.3