35 #include <sys/types.h>
43 using std::stringstream;
71 string use_node = node;
74 if (!node.empty() && node !=
"/") {
75 string::size_type pos = use_node.find_last_not_of(
"/");
76 use_node = use_node.substr(0, pos + 1);
85 string fullnode = rootdir;
86 if (!use_node.empty()) {
87 fullnode = fullnode +
"/" + use_node;
91 string::size_type slash = fullnode.rfind(
"/");
92 if (slash != string::npos) {
93 basename = fullnode.substr(slash + 1, fullnode.length() - slash);
99 BESDEBUG(
"bes",
"BESCatalogDirectory::show_catalog: "
100 <<
"use_node = " << use_node << endl
101 <<
"rootdir = " << rootdir << endl
102 <<
"fullnode = " << fullnode << endl
103 <<
"basename = " << basename << endl );
122 DIR *dip = opendir(fullnode.c_str());
129 if (_utils->
exclude(basename)) {
130 string error =
"You do not have permission to view the node " + use_node;
134 bool dirs_only =
false;
135 _utils->
get_entries(dip, fullnode, use_node, coi, myentry, dirs_only);
147 if (_utils->
include(basename)) {
151 (void) lstat(fullnode.c_str(), &buf);
152 if (S_ISLNK(buf.st_mode)) {
153 string error =
"You do not have permission to access node " + use_node;
157 statret = stat(fullnode.c_str(), &buf);
158 if (statret == 0 && S_ISREG(buf.st_mode)) {
161 list < string > services;
163 myentry->set_service_list(services);
165 else if (statret == 0) {
166 string error =
"You do not have permission to access " + use_node;
172 if (errno == ENOENT) {
173 string error =
"Node " + use_node +
" does not exist";
174 char *s_err = strerror(errno);
182 string error =
"Access denied for node " + use_node;
183 char *s_err = strerror(errno);
185 error = error + s_err;
192 string error =
"You do not have permission to access " + use_node;
209 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