Read passwords from given file. Tries to open file itself as well as file prefixed with $IMPALAROOT. Format (two lines, either string may be empty, no spaces): read=string write=string Definition at line 41 of file ChannelAuthorization.h. References Impala::FileExists(), Impala::FileReadString(), ILOG_ERROR, mReadPassword, mValid, mWritePassword, Impala::StringReplace(), and Impala::StringStartsWith(). 00042 { 00043 mValid = false; 00044 if (fileName.empty()) 00045 { 00046 ILOG_ERROR("Need passwordfile"); 00047 return; 00048 } 00049 String path; 00050 if (FileExists(fileName)) 00051 { 00052 path = fileName; 00053 } 00054 else 00055 { 00056 char* ptr = getenv("IMPALAROOT"); 00057 if (ptr) 00058 { 00059 String root = String(ptr) + "/" + fileName; 00060 if (FileExists(root)) 00061 path = root; 00062 } 00063 } 00064 if (path.empty()) 00065 { 00066 ILOG_ERROR("Unable to open passwordfile " << fileName); 00067 return; 00068 } 00069 std::vector<String> lines; 00070 FileReadString(std::back_inserter(lines), path); 00071 if (lines.size() != 2) 00072 { 00073 ILOG_ERROR("passwordfile should contain 2 lines"); 00074 return; 00075 } 00076 for (int i=0 ; i<lines.size() ; i++) 00077 { 00078 String s = lines[i]; 00079 if (StringStartsWith(s, "read=")) 00080 mReadPassword = StringReplace(s, "read=", ""); 00081 else if (StringStartsWith(s, "write=")) 00082 mWritePassword = StringReplace(s, "write=", ""); 00083 else 00084 { 00085 ILOG_ERROR("wrong format password file"); 00086 return; 00087 } 00088 } 00089 mValid = true; 00090 }
Here is the call graph for this function:
|