Possible bug in 'file' command under 'sudo' condition

Skip to first unread message


Aug 25, 2021, 5:33:34 AM8/25/21
to Rex Users

new Rex user (but old sysadmin and old perlish guy), I try to use it from my Ubuntu laptop to manage my new personnal NAS box (QNAP with QTS and Entware).

I think I found a bug when the 'file' command is used under sudo, and the ownership of the file target must be changed:

# for QTS 'admin' is UID 0 'administrators' is GID 0, of course I
# use another admin account to connect by SSH and sudoers file is
# correctly set
task 'install_file_with_sudo',
    server => 'qnapnas',
    sub {
        sudo {
            command => sub {
                file "$targetfile",
                    source => "$sourcefile",
                    owner  => 'admin',
                    group  => 'administrators',
                    mode   => 744;
            user => 'admin',

In this case, the line 539 in Rex/Commands/File.pm is called by the file command:

$fs->chown( "$current_options->{user}:", ...);

with a colon (:), which AFAIK is an error according to specs. I suspect that most implementation of 'chown' syscall removed gracefully this colon in this case, but not QTS and probably some others NAS kernels.

When I remove this colon, everything is OK.


Reply all
Reply to author
0 new messages