btrfs-progs: fsck-test: Add check_sudo to check valid root/sudo privilege
commita624680b0e45e0f7ea1c847f8ccebe04aa52ba75
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Mon, 2 Mar 2015 03:41:50 +0000 (2 11:41 +0800)
committerDavid Sterba <dsterba@suse.cz>
Mon, 9 Mar 2015 11:08:56 +0000 (9 12:08 +0100)
tree51d6859eaff8328eb8d3f5d7ed668ad7ae519063
parent0c13bf7936a0388c0bdc99dc80218a0179c88f31
btrfs-progs: fsck-test: Add check_sudo to check valid root/sudo privilege

Although fsck-test/012 uses sudo, it uses 'sudo -n', which won't prompt
user to input password and will return 1 if no valid credential is
found.

And this makes test result quite annoying since it fails to mount and
still continue, which will always fail.

This patch will check 'sudo -v -n' and 'sudo -n true' to determine
whether sudo works fine in different version/settings, since in some
setting/version, 'sudo -v -n' will fail even the user is set NOPASSWD.

Also, remove the 'have_root_helper' variant, since there is a
possibility that sudo credential will timeout during the test and
'have_root_helper' won't help to detect such problem.
New '_sudo' command will do credential check if needed to avoid such
problem.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
tests/common
tests/fsck-tests/012-leaf-corruption/test.sh