oxidecomputer / oxidecomputer/helios
build-illumos command could sanitize environment variables
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 481
- Forks
- 21
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 2
Description
I had a build failure that was pretty confusing.
mail_msg said:
==== Build errors (non-DEBUG) ====
The following command caused the error:
The following command caused the error:
dmake: Warning: Target `install' not remade because of errors
The following command caused the error:
dmake: Warning: Target `install' not remade because of errors
dmake: Warning: Command failed for target `svc'
dmake: Warning: Target `install' not remade because of errors
The following command caused the error:
dmake: Warning: Target `install' not remade because of errors
==== Build warnings (non-DEBUG) ====
dmake: Warning: Target `install' not remade because of errors
dmake: Warning: Target `install' not remade because of errors
dmake: Warning: Command failed for target `svc'
dmake: Warning: Target `install' not remade because of errors
dmake: Warning: Target `install' not remade because of errors
After narrowing some things down, I started trying to build just usr/src/cmd/svc/profile in bldenv. It failed as such:
$ dmake install
Check for enabled open services not covered by limited profile
sh: /home/jordan/src/helios/projects/illumos/usr/src/test: cannot execute [Is a directory]
*** Error code 126
The following command caused the error:
/home/jordan/src/helios/projects/illumos/usr/src/test ! -s check_open.notcovered && /usr/bin/touch check_open
dmake: Fatal error: Command failed for target `check_open'
Current working directory /home/jordan/src/helios/projects/illumos/usr/src/cmd/svc/profile
The error message suggested it was trying to execute something that it shouldn't be. Looking at the Makefile here, we have:
TEST = /usr/bin/test
...
#
# Enforce consistency between open and limited profiles per README
#
$(CHECK_OPEN) := PROFILES_CHECKED = open
$(CHECK_OPEN) := PROFILES_COVERING = limited
$(CHECK_LMTD) := PROFILES_CHECKED = limited
$(CHECK_LMTD) := PROFILES_COVERING = open
$(CHECK_OPEN) $(CHECK_LMTD): \
$(LISTSVCS) $(PROFILES_open) $(PROFILES_limited)
@$(ECHO) Check for enabled $(PROFILES_CHECKED) services \
not covered by $(PROFILES_COVERING) profile
@$(PERL) -w $(LISTSVCS) -e $(PROFILES_$(PROFILES_CHECKED)) > $@.enabled
@$(PERL) -w $(LISTSVCS) $(PROFILES_$(PROFILES_COVERING)) > $@.all
@$(COMM) -23 $@.enabled $@.all | $(TEE) $@.notcovered
@$(TEST) ! -s $@.notcovered && $(TOUCH) $@
/usr/bin/test was on my system and appeared to be right. I went down a bunch of paths here, including noticing that $PATH in bldenv included . but did not seem to come from my shell. (Is this expected behavior?)
Ultimately, running dmake -n helped me see what the problem was:
/home/jordan/src/helios/projects/illumos/usr/src/test ! -s check_limited.notcovered && /usr/bin/touch check_limited
Instead of /usr/bin/test, it was trying to run: /home/jordan/src/helios/projects/illumos/usr/src/test. It turns out I had a shell variable called TEST that was defined to that path.
I was pretty surprised by this behavior -- that setting a shell variable could interfere with building in this way. The fact that we use MAKEFLAGS=e, which makes env variables override macro assignments, explains this behavior.
It might be nice to have build-illumos sanitize some of the user's environment to prevent goose chases like this in the future.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the build-illumos command and reproduce the failure by defining TEST before running dmake install; inspect how the environment reaches dmake. Use the usr/src/cmd/svc/profile Makefile and its /usr/bin/test assignment as the reproduction point. Done means user-defined variables such as TEST cannot override build macros while normal builds still work; verify with dmake -n and dmake install.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100