Bug 587516
Summary: | setfattr doesn't accept 0x2 as the value [documentation bug] | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomasz Kepczynski <tomek> | ||||||||
Component: | attr | Assignee: | Kamil Dudka <kdudka> | ||||||||
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||||
Severity: | medium | Docs Contact: | |||||||||
Priority: | low | ||||||||||
Version: | rawhide | CC: | brandon, kdudka | ||||||||
Target Milestone: | --- | ||||||||||
Target Release: | --- | ||||||||||
Hardware: | All | ||||||||||
OS: | Linux | ||||||||||
Whiteboard: | |||||||||||
Fixed In Version: | attr-2.4.44-4.fc13 | Doc Type: | Bug Fix | ||||||||
Doc Text: | Story Points: | --- | |||||||||
Clone Of: | |||||||||||
: | 651120 (view as bug list) | Environment: | |||||||||
Last Closed: | 2011-01-17 20:49:39 UTC | Type: | --- | ||||||||
Regression: | --- | Mount Type: | --- | ||||||||
Documentation: | --- | CRM: | |||||||||
Verified Versions: | Category: | --- | |||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||
Embargoed: | |||||||||||
Bug Depends On: | |||||||||||
Bug Blocks: | 651120, 674870 | ||||||||||
Attachments: |
|
Description
Tomasz Kepczynski
2010-04-30 06:33:08 UTC
Thank you for filling the bug! I'll check if it is a real bug or feature. FWIW, here is a trace of the failure: $ gdb -q --args setfattr -n user.DOSATTRIB -v 0x2 /tmp/x (gdb) break decode Breakpoint 1 at 0x401839: file setfattr.c, line 291. (gdb) run Breakpoint 1, decode (value=0x7fffffffe6cb "0x2", size=0x7fffffffe250) at setfattr.c:291 291 if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X')) { (gdb) next 292 const char *v = value+2, *end = value + *size; (gdb) 296 *size / 2)) { (gdb) 295 if (high_water_alloc((void **)&decoded, &decoded_size, (gdb) 302 d = decoded; (gdb) 303 while (v < end) { (gdb) 306 while (v < end && isspace(*v)) (gdb) 308 if (v == end) (gdb) 310 d1 = hex_digit(*v++); (gdb) 311 while (v < end && isspace(*v)) (gdb) 313 if (v == end) { (gdb) 315 fprintf(stderr, "bad input encoding\n"); (gdb) info locals d1 = 2 d0 = 32767 v = 0x7fffffffe6ce "" end = 0x7fffffffe6ce "" d = 0x605000 "" decoded = 0x605000 "" decoded_size = 256 That's not a bug. setfattr(1) takes also values in either hexadecimal or base64 format, given the 0[xX] respectively 0[sS] prefix. You should be able to pass 0x2 as string by surrounding it to quotes. Please confirm. I agree there is a dearth of documentation for this feature. If you had some suggestion what to add to man page or whatever, it would be also appreciated. I would say: it works weirdly: vesemir:/var/tmp> setfattr -n user.DOSATTRIB -v '0x2' rpm-tmp.P2sHiq bad input encoding vesemir:/var/tmp> setfattr -n user.DOSATTRIB -v "0x2" rpm-tmp.P2sHiq bad input encoding vesemir:/var/tmp> setfattr -n user.DOSATTRIB -v '"0x2"' rpm-tmp.P2sHiq vesemir:/var/tmp> getfa getfacl getfattr vesemir:/var/tmp> getfattr -d rpm-tmp.P2sHiq # file: rpm-tmp.P2sHiq user.DOSATTRIB="0x2" So, to make it work - you need single quotes in doubles quotes, the other way around or plenty of backslashes.... I love hearing: it is not a bug, it is a feature ;). Sure, that's a feature of the _shell_ you're using ;-) It drops the outer single or double quotes. You need to either double quote, or escape the quotes to disable their special meaning: $ setfattr -n user.DOSATTRIB -v \"0x2\" You will observe basically the same with e.g. echo(1): $ echo "0x2" 0x2 $ echo \"0x2\" "0x2" That doesn't explain why I have to put quotes around 0x2 which is hexadecimal number and not when passing straight string like zzz: vesemir:/var/tmp> setfattr -n user.DOSATTRIB -v '"0x2"' kdecache-tomek vesemir:/var/tmp> getfattr -d kdecache-tomek # file: kdecache-tomek user.DOSATTRIB="0x2" vesemir:/var/tmp> setfattr -n user.DOSATTRIB -v zzz kdecache-tomek vesemir:/var/tmp> getfattr -d kdecache-tomek # file: kdecache-tomek user.DOSATTRIB="zzz" My understanding is that all attributes are just strings and I consider the requirement to quote hexadecimal number in this case unreasonable. But that's another story, I think you can close the bug (unless you agree with me and want to fix it ;) ). Well, my mistake. I should have explained this properly. The mentioned feature is obstruction from your point of view since you pass only text values through. Nevertheless there should be a way to pass some binary values as well. That's why the hexadecimal and base64 format has been introduced, at least from my understanding of that. Each enhancement has its cost. In this case, it means that all strings starting with '0x', '0X', '0s', or '0S' are treated specially. To get the old behavior back, just surround your value by double quotes. It will work well for "0x2", as well as "zzz". If you have any idea how to implement the feature in a better way (without breaking the stuff), patches are welcome. I left the bug open because I hadn't found the feature mentioned in documentation. If the information is indeed missing, we should perhaps a paragraph there about the feature. FWIW, I've CC'd the upstream maintainer of attr. Created attachment 458858 [details]
proposed improvement of setfattr.1 man page
Created attachment 459025 [details]
[PATCH v2] proposed improvement of setfattr.1 man page
just fixed two typos...
Created attachment 461527 [details]
setfattr.1: document supported encodings of values
after review by David O'Brien
proposed upstream: http://lists.gnu.org/archive/html/acl-devel/2010-11/msg00000.html pushed upstream: http://git.savannah.gnu.org/cgit/attr.git/commit/?id=846ca47 fixed in attr-2.4.44-6.fc15 attr-2.4.44-6.fc14 has been submitted as an update for Fedora 14. https://admin.fedoraproject.org/updates/attr-2.4.44-6.fc14 attr-2.4.44-4.fc13 has been submitted as an update for Fedora 13. https://admin.fedoraproject.org/updates/attr-2.4.44-4.fc13 attr-2.4.44-4.fc13 has been pushed to the Fedora 13 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update attr'. You can provide feedback for this update here: https://admin.fedoraproject.org/updates/attr-2.4.44-4.fc13 attr-2.4.44-6.fc14 has been pushed to the Fedora 14 stable repository. If problems still persist, please make note of it in this bug report. attr-2.4.44-4.fc13 has been pushed to the Fedora 13 stable repository. If problems still persist, please make note of it in this bug report. |