41 bool CanonizePath (std::string path,
bool ChRootProtected, std::ostringstream &result)
43 std::vector <std::string> profs;
44 std::ostringstream cur;
46 const char *crsr = path.c_str ();
48 bool SlashStart = (
'/' == *crsr);
101 if ((
'/' == *crsr)||(!*crsr))
105 std::string e = cur.str ();
124 if (ChRootProtected && !SlashStart && (level < 0))
134 profs.push_back (
"..");
141 cur <<
'.' <<
'.' << *crsr;
163 if (profs.size () > 0)
165 for (std::vector <std::string> :: iterator i = profs.begin () ; i != profs.end () ; ++i)
167 if (!first || SlashStart)
193 std::list<std::string> p =
Split (paths,
":");
194 for (std::list<std::string>::const_iterator i = p.begin (); i != p.end (); i++)
196 std::ostringstream cano;
199 std::string e = cano.str ();
210 for (std::vector <std::string>::const_iterator i =
m_paths.begin (); i !=
m_paths.end (); ++i)
214 if (*p.c_str () ==
'/')
236 if ((cwd.length () > 0) && (p.length () > 0))
238 pp =
m_basePath +
"/" + cwd +
"/" + p +
"/" + file;
241 if (cwd.length () > 0)
255 std::ostringstream cano;
258 if ((pp.length () > 0) && checker (pp, userData))
267 bool (*checker)(std::string,
void*))
270 std::string res = p1.
SeekFile (file,
"", userData, checker);
271 if (res.length () > 0)
278 return p2.
SeekFile (file,
"", userData, checker);
283 void *userData,
bool (*checker)(std::string,
void*))
286 return p1.
SeekFile (file,
"", userData, checker);
295 bool (*checker)(std::string,
void*))
298 std::string res = p1.
SeekFile (file, cwd, userData, checker);
299 if (res.length () > 0)
306 return p2.
SeekFile (file,
"", userData, checker);
315 std::string altRoots,
317 bool (*checker)(std::string,
void*))
319 if (*file.c_str () ==
'/')
323 int idx = file.find (
'/',0);
328 return SearchSimpleFile (file, vroot, vpath, cwd, dcepath, userData, checker);
334 std::string altRoots,
336 bool (*checker)(std::string,
void*))
338 if (*file.c_str () ==
'/')
350 if (0 != ::stat (file.c_str (), &st))
356 uid_t uid = criteria->
uid;
357 gid_t gid = criteria->
gid;
364 *criteria->
errNo = ENOEXEC;
371 SearchExecFile (std::string file, std::string vpath, uid_t uid, gid_t gid,
int *errNo)
376 std::string dcepath =
"";
378 std::string altRoots =
"";
379 char *c = getenv (
"DCE_PATH");
385 if (vpath.length () == 0)
403 c = getenv (
"DCE_ROOT");
410 userData.
errNo = errNo;
419 std::string altRoots =
"";
425 char *c = getenv (
"DCE_ROOT");
432 userData.
errNo = errNo;
440 char *c = getenv (envVar.c_str ());
441 std::string dcepath =
"";