Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Filenames with backslashes causes a fatal error for Rex::Commands::Sync

オープン
#1,607 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
perl
領域
devops

調査の方向性

Base.pm の149行目から参照されている Rex::Interface::Fs::Base::_quotepath から開始し、sync_down がバックスラッシュを含むパスをどのように処理するかを追跡します。systemd のファイル名を含むホストに対して、提供された Rexfile を使って再現し、その後、sync_down が致命的なエラーなしに完了し、パスが保持されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

bug
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

主要言語
Perl
スター
737
フォーク
214
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RexOps/Rex のほかの issue

RexOps/Rex の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。