libstore: make netrc/cafile child args plain strings again
not having the optionals set when the builder runs (e.g. because FOD hashes were not configured correctly) could cause assertion failures in the builder process. while this should usually not happen we *do* want to print a useful error message here instead of a crash report. Change-Id: I81fb1d45fcbf660d0d9a7f0c0a12c38379ecd4c6
This commit is contained in:
@@ -841,19 +841,17 @@ try {
|
||||
/* Make the contents of netrc and the CA certificate bundle
|
||||
available to builtin:fetchurl (which may run under a
|
||||
different uid and/or in a sandbox). */
|
||||
std::optional<std::string> netrcData;
|
||||
std::optional<std::string> caFileData;
|
||||
std::string netrcData;
|
||||
std::string caFileData;
|
||||
if (drv->isBuiltin() && drv->builder == "builtin:fetchurl" && !derivationType->isSandboxed()) {
|
||||
try {
|
||||
netrcData = readFile(settings.netrcFile);
|
||||
} catch (SysError &) {
|
||||
netrcData = "";
|
||||
}
|
||||
|
||||
try {
|
||||
caFileData = readFile(settings.caFile);
|
||||
} catch (SysError &) {
|
||||
caFileData = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,8 +909,8 @@ try {
|
||||
}
|
||||
|
||||
Pid LocalDerivationGoal::startChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args,
|
||||
AutoCloseFD logPTY
|
||||
@@ -1159,8 +1157,8 @@ void LocalDerivationGoal::chownToBuilder(const AutoCloseFD & fd)
|
||||
}
|
||||
|
||||
void LocalDerivationGoal::runChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args
|
||||
)
|
||||
@@ -1233,9 +1231,7 @@ void LocalDerivationGoal::runChild(
|
||||
e.second = rewriteStrings(e.second, inputRewrites);
|
||||
|
||||
if (drv->builder == "builtin:fetchurl") {
|
||||
assert(netrcData.has_value());
|
||||
assert(caFileData.has_value());
|
||||
builtinFetchurl(drv2, netrcData.value(), caFileData.value());
|
||||
builtinFetchurl(drv2, netrcData, caFileData);
|
||||
} else if (drv->builder == "builtin:buildenv") {
|
||||
builtinBuildenv(drv2);
|
||||
} else if (drv->builder == "builtin:unpack-channel") {
|
||||
|
||||
@@ -215,8 +215,8 @@ struct LocalDerivationGoal : public DerivationGoal
|
||||
* Run the builder's process.
|
||||
*/
|
||||
void runChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args
|
||||
);
|
||||
@@ -317,8 +317,8 @@ protected:
|
||||
* On some platforms this process is created with sandboxing flags.
|
||||
*/
|
||||
virtual Pid startChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args,
|
||||
AutoCloseFD logPTY
|
||||
|
||||
@@ -1239,8 +1239,8 @@ bool LinuxLocalDerivationGoal::prepareChildSetup()
|
||||
}
|
||||
|
||||
Pid LinuxLocalDerivationGoal::startChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args,
|
||||
AutoCloseFD logPTY
|
||||
|
||||
@@ -74,8 +74,8 @@ private:
|
||||
* create /etc/passwd and /etc/group based on discovered uid/gid
|
||||
*/
|
||||
Pid startChild(
|
||||
const std::optional<std::string> & netrcData,
|
||||
const std::optional<std::string> & caFileData,
|
||||
const std::string & netrcData,
|
||||
const std::string & caFileData,
|
||||
const Strings & envStrs,
|
||||
const Strings & args,
|
||||
AutoCloseFD logPTY
|
||||
|
||||
Reference in New Issue
Block a user