influxdata / pkg-config

PROTOTYPE: A pkg-config drop-in for compiling C libraries for InfluxData
MIT License
3 stars 8 forks source link

Ensure the wrapper doesn't detect itself for the pkg-config binary #41

Open onelson opened 2 years ago

onelson commented 2 years ago

In a situation where the wrapper detects itself as the system pkg-config binary, it can call itself recursively. This ultimately causes the build to fail while also eating all your system resources in the process!

When searching for the system binary, we should check to make sure we haven't just rediscovered the wrapper. I'm not sure what the method for this should be. Perhaps we can canonicalize the paths, or generate hashes for each binary or something else.

If we exhaust our search only finding the wrapper then exit after printing some helpful message.

onelson commented 2 years ago

An odd thought that occurred to me for spotting the difference between the wrapper and the system binary: we could add a flag that only the wrapper has and use that as the guard. If some/path/to/pkg-config --is-influxdata-wrapper produces a non-zero exit, then we could know it's not the wrapper.

A weakness to this approach is that the earlier releases for the wrapper also won't know about this flag, but I think that'd implicitly put is in the situation we have today (without any sort of guard).