Skip to content

[Error] File globbing triggered during file parsing in distrobox-assemble #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jeffmahoney opened this issue Mar 18, 2025 · 0 comments · May be fixed by #1713
Open

[Error] File globbing triggered during file parsing in distrobox-assemble #1712

jeffmahoney opened this issue Mar 18, 2025 · 0 comments · May be fixed by #1713
Labels
bug Something isn't working

Comments

@jeffmahoney
Copy link

Describe the bug
If a single-character file exists in the directory where distrobox-assemble is executing and it shares a character with one contained in the name of a distrobox to be assembled, it will fail.

 - Deleting ...
Error response from daemon: No such container: my-distrobox
Error response from daemon: No such container: my-distrobox
Cannot find container my-distrobox.
 - Creating ...
 already exists

my-distrobox is the default container name and it's used because $name is never set. This is due to file globbing in the matching a single character file in the current directory, so the line becomes:
w

instead of
[tw]

and the section definition is not interpreted.

This is regression introduced in commit 1bb261a.

        # shellcheck disable=SC2013
        for line in $(cat "${file}"); do
                # Remove comments and trailing spaces

The unquoted file contents are being interpreted by the shell rather than being passed as read.

To Reproduce
Create a distrobox.ini:

image=registry.opensuse.org/opensuse/distrobox:latest
init=true
nvidia=false
pull=true
root=false
replace=true
start_now=false
additional_packages="git vim ctags go1.24 osc fileb0x obs-service-go_modules"
volume="/src:/src"
volume="/var/scratch:/var/scratch"

and create a file in the same directory:
:> w

Then distrobox assemble create

Expected behavior
A distrobox named foo will be created

@jeffmahoney jeffmahoney added the bug Something isn't working label Mar 18, 2025
jeffmahoney added a commit to jeffmahoney/distrobox that referenced this issue Mar 18, 2025
commit 1bb261a (assemble: fix regression in file reading)
introduced a different regression in file parsing.

When create a distrobox I observed:
 - Deleting ...
Error response from daemon: No such container: my-distrobox
Error response from daemon: No such container: my-distrobox
Cannot find container my-distrobox.
 - Creating ...
 already exists

In the loop reading the file, the file contents are being interpreted
by the shell rather than being passed as read.  This results in the
section header being treated as a single-character glob expression.
If a file or directory exists in the working directory and is named
with a single character contained in the section header, the line will
only contain that character rather than the section header.  This
naturally results in the distrobox not being created because the
start of the section is never detected, $name, goes unset, and
run_distrobox is called without a name.  distrobox rm uses a default
name of "my-distrobox" which, on my test system doesn't exist.  Then
distrobox create is called with an empty name, which fails, but
that's interpreted as already existing by run_distrobox.

It appears a few separate changes went into that commit and restoring
the while read loop fixes the issue for me.

Fixes: 89luca89#1712
Fixes: 1bb261a
jeffmahoney added a commit to jeffmahoney/distrobox that referenced this issue Mar 18, 2025
commit 1bb261a (assemble: fix regression in file reading)
introduced a different regression in file parsing.

When creating a distrobox I observed:
 - Deleting ...
Error response from daemon: No such container: my-distrobox
Error response from daemon: No such container: my-distrobox
Cannot find container my-distrobox.
 - Creating ...
 already exists

In the loop reading the file, the file contents are being interpreted
by the shell rather than being passed as read.  This results in the
section header being treated as a single-character glob expression.
If a file or directory exists in the working directory and is named
with a single character contained in the section header, the line will
only contain that character rather than the section header.  This
naturally results in the distrobox not being created because the
start of the section is never detected, $name, goes unset, and
run_distrobox is called without a name.  distrobox rm uses a default
name of "my-distrobox" which, on my test system doesn't exist.  Then
distrobox create is called with an empty name, which fails, but
that's interpreted as already existing by run_distrobox.

It appears a few separate changes went into that commit and restoring
the while read loop fixes the issue for me.

Fixes: 89luca89#1712
Fixes: 1bb261a
jeffmahoney added a commit to jeffmahoney/distrobox that referenced this issue Mar 18, 2025
commit 1bb261a (assemble: fix regression in file reading)
introduced a different regression in file parsing.

When creating a distrobox I observed:
 - Deleting ...
Error response from daemon: No such container: my-distrobox
Error response from daemon: No such container: my-distrobox
Cannot find container my-distrobox.
 - Creating ...
 already exists

In the loop reading the file, the file contents are being interpreted
by the shell rather than being passed as read.  This results in the
section header being treated as a single-character glob expression.
If a file or directory exists in the working directory and is named
with a single character contained in the section header, the line will
only contain that character rather than the section header.  This
naturally results in the distrobox not being created because the
start of the section is never detected, $name, goes unset, and
run_distrobox is called without a name.  distrobox rm uses a default
name of "my-distrobox" which, on my test system doesn't exist.  Then
distrobox create is called with an empty name, which fails, but
that's interpreted as already existing by run_distrobox.

It appears a few separate changes went into that commit and restoring
the while read loop fixes the issue for me.

Fixes: 89luca89#1712
Fixes: 1bb261a
jeffmahoney added a commit to jeffmahoney/distrobox that referenced this issue Mar 18, 2025
commit 1bb261a (assemble: fix regression in file reading)
introduced a different regression in file parsing.

When creating a distrobox I observed:
 - Deleting ...
Error response from daemon: No such container: my-distrobox
Error response from daemon: No such container: my-distrobox
Cannot find container my-distrobox.
 - Creating ...
 already exists

In the loop reading the file, the file contents are being interpreted
by the shell rather than being passed as read.  This results in the
section header being treated as a single-character glob expression.
If a file or directory exists in the working directory and is named
with a single character contained in the section header, the line will
only contain that character rather than the section header.  This
naturally results in the distrobox not being created because the
start of the section is never detected, $name, goes unset, and
run_distrobox is called without a name.  distrobox rm uses a default
name of "my-distrobox" which, on my test system doesn't exist.  Then
distrobox create is called with an empty name, which fails, but
that's interpreted as already existing by run_distrobox.

It appears a few separate changes went into that commit and restoring
the while read loop fixes the issue for me.

Fixes: 89luca89#1712 89luca89#1487
Fixes: 1bb261a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant