std::string VfsCatalog::readLink(const std::string& path) throw (DmException)
{
- char buf[PATH_MAX];
ExtendedStat meta = this->extendedStat(path, false);
+ char *buf;
if (checkPermissions(this->secCtx_, meta.acl, meta.stat, S_IREAD) != 0)
vfsThrow(EACCES, "not enough permissions for '%s' on '%s'", clientName.c_str(), path.c_str());
- memset(buf, 0, sizeof(buf));
- wrapCall(readlink(getLocalPath(path).c_str(), buf, sizeof(buf) - 1));
+ memset(this->buffer, 0, sizeof this->buffer);
+ wrapCall(readlink(getLocalPath(path).c_str(), this->buffer, sizeof(this->buffer) - 1));
+
+ // strip namespace local disk prefix, if target path is absolute and equals to the prefix
+ if (strncmp(this->buffer, this->prefix_.c_str(), this->prefix_.size()) == 0) buf = this->buffer + this->prefix_.size();
+ else buf = this->buffer;
+
return buf;
}
attrlist_t *list;
attrlist_ent_t *entry;
- list = (attrlist_t *)this->xattrBuffer;
+ list = (attrlist_t *)this->buffer;
memset(&attr_cursor, 0, sizeof attr_cursor);
do {
- wrapCall(attr_list(lpath.c_str(), this->xattrBuffer, sizeof this->xattrBuffer, follow ? 0 : ATTR_DONTFOLLOW, &attr_cursor), "could not get list of extended attributes on '%s'", path.c_str());
+ wrapCall(attr_list(lpath.c_str(), this->buffer, sizeof this->buffer, follow ? 0 : ATTR_DONTFOLLOW, &attr_cursor), "could not get list of extended attributes on '%s'", path.c_str());
for (int i = 0; i < list->al_count; i++) {
- entry = ATTR_ENTRY(this->xattrBuffer, i);
+ entry = ATTR_ENTRY(this->buffer, i);
// "selinux" is returned in the list, but failing to get the value
if (strcmp(entry->a_name, "selinux") == 0) {
//syslog(LOG_DEBUG, "%s: skipping attribute '%s'", __func__, entry->a_name);