ref: b0bb531412865e658e9a3efbf990d7e5c108d12f
parent: 07c47f43a906863c080f15022d3201b6b1c9516b
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sun Nov 15 09:01:10 EST 2020
fix symlinks hiding
--- a/ext4srv.c
+++ b/ext4srv.c
@@ -68,7 +68,7 @@
q = s;
s = smprint("%s/%s", q, buf);
free(q);
- cleanname(strchr(s+1, '/')+1);
+ cleanname(strchr(s+1, '/'));
}
}else{
if(res != 0)
@@ -406,7 +406,7 @@
}
t = ext4_inode_type(a->p->sb, &inode);
- if(opts.linkmode == Lhide && (t & EXT4_INODE_MODE_SOFTLINK) != 0){
+ if(opts.linkmode == Lhide && t == EXT4_INODE_MODE_SOFTLINK){
free(s);
return -1;
}
@@ -415,7 +415,7 @@
dir->qid.path = a->p->qidmask.path | ino;
dir->qid.vers = ext4_inode_get_generation(&inode);
dir->qid.type = 0;
- if(t & EXT4_INODE_MODE_DIRECTORY){
+ if(t == EXT4_INODE_MODE_DIRECTORY){
dir->qid.type |= QTDIR;
dir->mode |= DMDIR;
}else
@@ -460,11 +460,16 @@
return -1;
}while(e->name == nil || strcmp((char*)e->name, ".") == 0 || strcmp((char*)e->name, "..") == 0);
+ if(opts.linkmode == Lhide && e->inode_type == EXT4_DE_SYMLINK)
+ continue;
+
if(a->doff++ != n)
continue;
if(dirfill(dir, a, (char*)e->name) == 0)
return 0;
+
+ a->doff--;
}
}
@@ -747,7 +752,7 @@
return "not a directory";
}
dir = *a;
- dir.path = s;
+ dir.path = strchr(s+1, '/')+1;
if(!haveperm(&dir, OEXEC, nil)){
free(s);
return Eperm;