Skip to content
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

--workdir=~/tmp/rpminspect creates literal ~ directory in PWD #22

Closed
hroncok opened this issue Aug 10, 2019 · 4 comments
Closed

--workdir=~/tmp/rpminspect creates literal ~ directory in PWD #22

hroncok opened this issue Aug 10, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@hroncok
Copy link
Contributor

hroncok commented Aug 10, 2019

$ rpminspect -v --workdir=~/tmp/rpminspect python3-3.7.4-1.fc31 python3-3.7.4-3.fc31

This command creates a directory called literally ~ in PWD. That is somewhat unexpected.

@dcantrell
Copy link
Collaborator

I agree, that is unexpected. Though it's not technically wrong. ~ is a perfectly legal filename character. :)

I will fix this up. Thank you for these reports, they are really helpful.

@dcantrell dcantrell self-assigned this Aug 14, 2019
@dcantrell dcantrell added the enhancement New feature or request label Aug 14, 2019
@dcantrell
Copy link
Collaborator

~ expansion is generally handled by your shell, but when using long options most shells do not expand the ~ character and pass the string directly in the argument vector.

What I have done is add ~ expanding for the workdir argument if you have a ~ in the string. See the glob(3) man page for details on the functionality. I am using the GLOB_TILDE_CHECK functionality, so there are some additional checks to ensure the user is there and such.

Since I am relying on glob(3), I will get GLOB_NOMATCH back if the path does not exist. That is a side effect of using glob(3). So if you are going to use the long option syntax of rpminspect, keep this in mind.

@hroncok
Copy link
Contributor Author

hroncok commented Aug 14, 2019

In other words, if the directory in my home doesn't exists, literal ~ is created, but if it exists, it is used? I bet that this will also bite somebody, but If anything else would be more complicated, i think it is fine.

@dcantrell
Copy link
Collaborator

It won't create it for workdir because glob() can't successfully expand it. Before this fix it would create it though because the ~ was carried through to the mkdirp() function. This fix will prevent that.

dcantrell added a commit that referenced this issue Aug 14, 2019
~ expansion is generally handled by your shell, but when using long
options most shells do not expand the ~ character and pass the string
directly in the argument vector.

What I have done is add ~ expanding for the workdir argument if you have
a ~ in the string. See the glob(3) man page for details on the
functionality. I am using the GLOB_TILDE_CHECK functionality, so there
are some additional checks to ensure the user is there and such.

Since I am relying on glob(3), I will get GLOB_NOMATCH back if the path
does not exist. That is a side effect of using glob(3). So if you are
going to use the long option syntax of rpminspect, keep this in mind.
jeremycline pushed a commit to jeremycline/rpminspect that referenced this issue Jul 13, 2020
~ expansion is generally handled by your shell, but when using long
options most shells do not expand the ~ character and pass the string
directly in the argument vector.

What I have done is add ~ expanding for the workdir argument if you have
a ~ in the string. See the glob(3) man page for details on the
functionality. I am using the GLOB_TILDE_CHECK functionality, so there
are some additional checks to ensure the user is there and such.

Since I am relying on glob(3), I will get GLOB_NOMATCH back if the path
does not exist. That is a side effect of using glob(3). So if you are
going to use the long option syntax of rpminspect, keep this in mind.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants