MCPcopy Create free account
hub / github.com/apache/impala / EnvAppend

Function EnvAppend

be/src/rpc/authentication.cc:1325–1354  ·  view source on GitHub ↗

For the environment variable attr, append "-Dthing=thingval" if "thing" is not already in the current attr's value.

Source from the content-addressed store, hash-verified

1323// For the environment variable attr, append "-Dthing=thingval" if "thing" is not already
1324// in the current attr's value.
1325static Status EnvAppend(const string& attr, const string& thing, const string& thingval) {
1326 // Carefully append to attr. There are three distinct cases:
1327 // 1. Attr doesn't exist: set it
1328 // 2. Attr exists, and doesn't contain thing: append to it
1329 // 3. Attr exists, and already contains thing: do nothing
1330 string current_val;
1331 char* current_val_c = getenv(attr.c_str());
1332 if (current_val_c != NULL) {
1333 current_val = current_val_c;
1334 }
1335
1336 if (!current_val.empty() && (current_val.find(thing) != string::npos)) {
1337 // Case 3 above
1338 return Status::OK();
1339 }
1340
1341 stringstream val_out;
1342 if (!current_val.empty()) {
1343 // Case 2 above
1344 val_out << current_val << " ";
1345 }
1346 val_out << "-D" << thing << "=" << thingval;
1347
1348 if (setenv(attr.c_str(), val_out.str().c_str(), 1) < 0) {
1349 return Status(Substitute("Bad $0=$1 value: Could not set environment variable $2: $3",
1350 thing, thingval, attr, GetStrErrMsg()));
1351 }
1352
1353 return Status::OK();
1354}
1355
1356Status AuthManager::InitKerberosEnv() {
1357 if (IsKerberosEnabled()) {

Callers 1

InitKerberosEnvMethod · 0.85

Calls 7

OKFunction · 0.85
SubstituteFunction · 0.85
GetStrErrMsgFunction · 0.85
StatusClass · 0.50
emptyMethod · 0.45
findMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected