allowing to set any known LD_ parameter for the current rtld invocation, but without polluting the activated' binary environment. In other words, the set parameter is not exported into the environment.
Details
- Reviewers
emaste markj - Commits
- rGd1cd0cc32b53: rtld: add direct-exec option -o
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Is there some simple regression test we can add to verify that 1) -o overrides the environment, and 2) actually works? My first idea for a simple test is to use LD_PRELOAD=./libfoo.so /libexec/ld-elf.so.1 -o PRELOAD=./libpythagoras.so cat and then check that libpythagoras.so (some dummy library used in rtld tests) is loaded using procstat -v. Maybe there's a simpler test?
libexec/rtld-elf/rtld.1 | ||
---|---|---|
396 | ||
401 | ||
402 | ||
406 | ||
407 | ||
407 | So if LD_BIND_NOW=1 is set in the env and one passes -o BIND_NOW=0, we'll get the latter's semantics but LD_BIND_NOW=1 will be set in the environment? That seems potentially quite confusing (not for BIND_NOW specifically, but in general). I do not object to the idea, I'm just wondering if it's sensible for rtld to print a warning in this scenario. | |
libexec/rtld-elf/rtld.c | ||
6178 | I don't really see the point of calculating strlen(l->n) if we're going to use strncmp() anyway. I see that rtld_init_env_vars_for_prefix() does this as well, but the reason is also not obvious to me. |
libexec/rtld-elf/rtld.1 | ||
---|---|---|
407 | Note that LD_BIND_NOW=0 is fully equal to LD_BIND_NOW=1 from the rtld PoV. This should be even more confusing, but this is the historical behavior. If you need to isolate direct exec from env settings, there is the '-u' option already. | |
libexec/rtld-elf/rtld.c | ||
6178 | strncmp is used because n is not nul-terminated for our purposes (it is terminated by '='). This is the rare reasonable use of strncmp. |
libexec/rtld-elf/rtld.c | ||
---|---|---|
6178 | Suppose that l->n == "ABCD", and n == "AB=1". Without strlen() comparison, the strncmp() check alone would succeed. |