35 #include <sys/types.h>
43 using std::stringstream;
72 string use_node = node;
75 if (!node.empty() && node !=
"/") {
76 string::size_type pos = use_node.find_last_not_of(
"/");
77 use_node = use_node.substr(0, pos + 1);
86 string fullnode = rootdir;
87 if (!use_node.empty()) {
88 fullnode = fullnode +
"/" + use_node;
92 string::size_type slash = fullnode.rfind(
"/");
93 if (slash != string::npos) {
94 basename = fullnode.substr(slash + 1, fullnode.length() - slash);
100 BESDEBUG(
"bes",
"BESCatalogDirectory::show_catalog: "
101 <<
"use_node = " << use_node << endl
102 <<
"rootdir = " << rootdir << endl
103 <<
"fullnode = " << fullnode << endl
104 <<
"basename = " << basename << endl );
123 DIR *dip = opendir(fullnode.c_str());
130 if (_utils->
exclude(basename)) {
131 string error =
"You do not have permission to view the node " + use_node;
135 bool dirs_only =
false;
136 _utils->
get_entries(dip, fullnode, use_node, coi, myentry, dirs_only);
148 if (_utils->
include(basename)) {
152 (void) lstat(fullnode.c_str(), &buf);
153 if (S_ISLNK(buf.st_mode)) {
154 string error =
"You do not have permission to access node " + use_node;
158 statret = stat(fullnode.c_str(), &buf);
159 if (statret == 0 && S_ISREG(buf.st_mode)) {
162 list < string > services;
164 myentry->set_service_list(services);
166 else if (statret == 0) {
167 string error =
"You do not have permission to access " + use_node;
173 if (errno == ENOENT) {
174 string error =
"Node " + use_node +
" does not exist";
175 char *s_err = strerror(errno);
183 string error =
"Access denied for node " + use_node;
184 char *s_err = strerror(errno);
186 error = error + s_err;
193 string error =
"You do not have permission to access " + use_node;
210 strm <<
BESIndent::LMarg <<
"BESCatalogDirectory::dump - (" << (
void *)
this <<
")" << endl;
error thrown if the resource requested cannot be found
virtual void dump(ostream &strm) const
dumps information about this object
virtual void add_entry(BESCatalogEntry *entry)
static void bes_add_stat_info(BESCatalogEntry *entry, const string &fullnode)
BESCatalogDirectory(const string &name)
static ostream & LMarg(ostream &strm)
bool follow_sym_links() const
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
static bool isData(const string &inQuestion, const string &catalog, list< string > &services)
virtual BESCatalogEntry * show_catalog(const string &container, const string &coi, BESCatalogEntry *entry)
abstract base class catalog object.
error thrown if the BES is not allowed to access the resource requested
virtual ~BESCatalogDirectory(void)
virtual string get_catalog_name()
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
virtual bool include(const string &inQuestion) const
virtual bool exclude(const string &inQuestion) const
static BESCatalogUtils * Utils(const string &name)
virtual unsigned int get_entries(DIR *dip, const string &fullnode, const string &use_node, const string &coi, BESCatalogEntry *entry, bool dirs_only)
static void check_path(const string &path, const string &root, bool follow_sym_links)
Check if the specified path is valid.
const string & get_root_dir() const