-
Notifications
You must be signed in to change notification settings - Fork 2k
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
make: bail out if there are spaces in the path #5221
Conversation
Is checking them all at once robust? |
@@ -42,6 +42,10 @@ BINDIRBASE := $(abspath $(BINDIRBASE)) | |||
BINDIR ?= $(BINDIRBASE)/$(BOARD) | |||
BINDIR := $(abspath $(BINDIR))/ | |||
|
|||
ifneq (9, $(words ${RIOTBASE} ${CCACHE_BASEDIR} ${RIOTCPU} ${RIOTBOARD} ${RIOTPROJECT} ${RIOTPKG} ${APPDIR} ${BINDIRBASE} ${BINDIR})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a substitution for each variable in case it is undefined or empty:
ifneq (9, $(words ${RIOTBASE}:-default ${CCACHE_BASEDIR}:-default ${RIOTCPU}:-default ${RIOTBOARD}:-default ${RIOTPROJECT}:-default ${RIOTPKG}:-default ${APPDIR}:-default ${BINDIRBASE}:-default ${BINDIR}:-default))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My logic was borken. Now I apply each variable individually to $(words)
and test if any outcome is unequal 1.
@gebart, no my check was not rebust at all. Fixed. Also I noticed a non-absolute BINDIR leads to messed up build. It is ensured now, too, that variables are absolute, and end with a slash if they need to. |
If the paths have to end with a slash or no slash then it is a bug in the build system. Where does it fail if the path contains an extra slash in the middle? Normally /bin/ls and /bin//ls point to the same file, same as /bin/./ls as well. Additionally, abspath will filter away all extra slashes and relative directories. You could do an override MYDIR:=$(abspath ${MYDIR}) to always get a consistent state with regards to slashes |
If you use |
Seems like |
hmm, the former implementation was much less intrusive (: |
Now it works. I think it's not even ugly. :) |
|
||
GITCACHE:=$(RIOTBASE)/dist/tools/git/git-cache | ||
# Path to the current directory relative to the git root | ||
BUILDRELPATH ?= $(shell git rev-parse --show-prefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes it necessary to have a .git
directory in our root, and to have git installed.
Why not just ${PWD#$RIOTBASE}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only moved the line.
Please review again. |
doesn't seem to break anything for me. ACK please squash |
Squashed |
ifneq (, $(filter-out 1, $(foreach v,${__DIRECTORY_VARIABLES},$(words ${${v}})))) | ||
$(info Aborting compilation for your safety.) | ||
$(info Related variables = ${__DIRECTORY_VARIABLES}) | ||
$(error Make sure no path override is empty or contains spaces!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this fail on many Windows systems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are spaces in the path, yes, that's the point. :) Otherwise Windows' directory layout got smarter, e.g. $HOME is C:\Users$ID, Eigene Daten is actually $HOME/Documents. There should be no spaces in your common folders unless you put one in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kijewski I am just wondering: would it be "safer" if this check is done after making all paths absolute below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would catch the unlikely case that (RIOTBASE != PWD) && !contains_space(RIOTBASE) && contains_space(PWD)
. Will change this evening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change this evening.
@Kijewski it's now or never (for this release at least) (;
If we use `rm -r(f)` then we should make sure that we don't delete random directory trees because there was a whitespace in the path.
Addressed @cgundogan's comment, squashed directly. |
nice! |
ACK and GO |
make: bail out if there are spaces in the path (backport of #5221)
If we use
rm -r(f)
then we should make sure that we don't delete random directory trees because there was a whitespace in the path.Related story: “In A UEFI World, "rm -rf /" Can Brick Your System”.