Filenames with backslashes causes a fatal error for Rex::Commands::Sync
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Comienza en Rex::Interface::Fs::Base::_quotepath, referenciado desde la línea 149 de Base.pm, y sigue cómo sync_down gestiona la ruta que contiene una barra inversa. Reprodúcelo con el Rexfile proporcionado contra un host que contenga el nombre de archivo de systemd y, después, verifica que sync_down se complete sin un error fatal y preserve la ruta.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Rex terminates with errors (the error varies based on where it is thrown) if dealing with a filename containing backslashes.
Example:
[2023-09-20 11:16:14] INFO - Running task systemd on host
[2023-09-20 11:17:18] ERROR - Error executing task:
[2023-09-20 11:17:18] ERROR - Error running chmod 0755 /Users/mmusgrove/tmp/host/fs/etc/systemd/system/dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants at /Users/mmusgrove/perl5/perlbrew/perls/perl-5.26.3/lib/site_perl/5.26.3/Rex/Interface/Fs/Base.pm line 149, <> line 145.
[2023-09-20 11:17:18] ERROR - 1 out of 1 task(s) failed:
[2023-09-20 11:17:18] ERROR - systemd failed on host
[2023-09-20 11:17:18] ERROR - Error running chmod 0755 /Users/mmusgrove/tmp/host/fs/etc/systemd/system/dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants at /Users/mmusgrove/perl5/perlbrew/perls/perl-5.26.3/lib/site_perl/5.26.3/Rex/Interface/Fs/Base.pm line 149, <> line 145.
I was attempting to use rsync_down on /etc/systemd and it encountered this file:
[root@host ~]# ls -al /etc/systemd/system/dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants/qemu-guest-agent.service
lrwxrwxrwx. 1 root root 48 Oct 20 2021 '/etc/systemd/system/dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants/qemu-guest-agent.service' -> /usr/lib/systemd/system/qemu-guest-agent.service
The host/fs/etc/systemd/ directory exists with ~/tmp.
The problem seems to be that Rex::Interface::Fs::Base::_quotepath is not handling backslashes. I can fix it if I override that method as follows:
{
# Allow /etc/systemd/system/dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants to be synced
no warnings 'redefine';
*Rex::Interface::Fs::Base::_quotepath = sub {
my ( $self, $p ) = @_;
$p =~ s/([\\\@\$\% ])/\\$1/g; # Note the extra \\ before \@
return $p;
};
}
Expected behavior
I would expect the sync_down to function the same regardless of whether or not the filename contains a backslash character.
How to reproduce it
Modify the following Rexfile to use a valid hostname of a Linux system with qemu installed you can connect to with ssh
mkdir -p ~/tmp/host/fs/etc/systemd # where host is the same hostname
Place the Rexfile into ~/tmp.
cd ~/tmp
rex systemd
Code example
# Rexfile
use Rex -feature => ['1.4'];
group myservers => 'host';
desc 'Get /etc/systemd';
task 'systemd',
group => 'myservers',
sub {
my $server = connection->server;
sync_down "/etc/systemd", "$server/fs/etc/systemd/";
};
Additional context
No response
Rex version
(R)?ex 1.14.3
Perl version
v5.26.3
Operating system running rex
Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020 arm64
Operating system managed by rex
AlmaLinux 8.8 (Sapphire Caracal)
How rex was installed?
package manager
- Lenguaje dominante
- Perl
- Estrellas
- 737
- Forks
- 214
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de RexOps/Rex
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
triage needed
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
triage needed
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
Todos los issues de RexOps/Rex
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
openfoodfacts/openfoodfacts-server#14724 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
rubocop/ruby-style-guide#982 ·
-
Strange loop in AgentTicketBulkAbiertoquestion
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100