Red Hat Bugzilla – Bug 557655
guestfish number parsing should not use atoi, should support '0...' for octal and '0x...' for hexadecimal
Last modified: 2010-03-16 13:26:13 EDT
Description of problem:
guestfish interprets the mode argument of chmod in decimal rather than octal.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Run "chmod 700 /" in guestfish.
/ gets permissions -w-rwxr-T (1274 octal = 700 decimal)
/ gets permissions rwx------
"chmod 0700 /" doesn't work correctly either.
Yes I agree this is a bug.
At the moment the code does:
mode = atoi (argv);
which is wrong on several levels.
Jim, it seems sensible to ask which gnulib function
I should be using here.
xstrtoul should do the trick.
Patch posted upstream:
This still violates the principle of least surprise. The chmod command-line program doesn't require the leading 0, so users will omit it here too and will get nonsensical file modes. Is it really useful to be able to specify file modes in decimal or hex?
We can cover this in the documentation, but guestfish isn't like
bash, and chmod in guestfish is a wrapper around guestfs_chmod,
not the chmod program, so it behaves a bit differently (but
consistent with other guestfish commands).
I updated the patch to add a note to the 'chmod' command in the
guestfish manual page.
Updated patch posted upstream:
This fix will be in 1.0.82.