[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
and another diff... trailing slashes
here is (finally) my answer to that silly ls -l symlink/ problem...
i have only one question now :) should it look at curproc->domain in
both cases? would save a few bytes code.
Index: filesys.c
@@ -968,8 +968,10 @@
break;
}
- /* if the file is a link, and we're following links, follow it */
- if ( (xattr.mode & S_IFMT) == S_IFLNK && (*path || dolast > 1)) {
+ /* if the file is a link, and we're following links, follow it,
+ * including for trailing slashes...
+ */
+ if ( (xattr.mode & S_IFMT) == S_IFLNK && (c || dolast > 1)) {
r = (res->fs->readlink)(res, linkstuff, PATH_MAX);
release_cookie(res);
if (r) {
@@ -986,9 +988,31 @@
}
dir = *res;
(void)(res->fs->getxattr)(res, &xattr);
+
+ /* but if it ended with a slash then we do want a directory
+ * (TOS-compatibility is not an issue here, TOS didn't have
+ * symlinks anyway)
+ */
+ if (c && !*path && (xattr.mode & S_IFMT) != S_IFDIR) {
+ DEBUG(("trailing slash and symlink to non-directory"));
+ r = EPTHNF;
+ break;
+ }
} else {
release_cookie(&dir);
dir = *res;
+#if 1
+ /* if not TOS domain can we enforce the trailing slash == must-be-
+ * directory rule for non-symlinks too? i prefer safety over
+ * TOS-compatibility...
+ */
+ if (c && !*path && curproc->domain != DOM_TOS &&
+ (xattr.mode & S_IFMT) != S_IFDIR) {
+ DEBUG(("trailing slash and not a directory"));
+ r = EPTHNF;
+ break;
+ }
+#endif
}
}
have fun...
Juergen
--
J"urgen Lock / nox@jelal.hb.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
...ohne Gewehr
PGP public key fingerprint = 8A 18 58 54 03 7B FC 12 1F 8B 63 C7 19 27 CF DA