[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MiNT 1.09: some protection for biosfs
Most of the function of biosfs that change it should only be allowed
by root, IMHO. This patch adds checks to bios_remove, bios_rename,
bios_fscntl and bios_symlink. Additionally i have added a check for
existence of the new name in bios_rename.
--- orig/biosfs.c Tue Aug 17 21:23:18 1993
+++ biosfs.c Mon Nov 22 19:58:30 1993
@@ -358,6 +358,9 @@
struct bios_file *b, **lastb;
UNUSED(dir);
+ if (curproc->euid)
+ return EACCDN;
+
lastb = &broot;
for (b = broot; b; b = *(lastb = &b->next)) {
if (!stricmp(b->name, name)) break;
@@ -401,18 +404,24 @@
fcookie *newdir;
const char *newname;
{
- struct bios_file *b;
+ struct bios_file *b, *be = 0;
UNUSED(olddir); UNUSED(newdir);
-/* BUG: we should check to see if "newname" already exists */
+ if (curproc->euid)
+ return EACCDN;
for (b = broot; b; b = b->next) {
- if (!stricmp(b->name, oldname)) {
- strncpy(b->name, newname, BNAME_MAX);
- return 0;
- }
- }
+ if (!stricmp (b->name, newname))
+ return EACCDN;
+ if (!stricmp(b->name, oldname))
+ be = b;
+ }
+ if (be)
+ {
+ strncpy(be->name, newname, BNAME_MAX);
+ return 0;
+ }
return EFILNF;
}
@@ -552,6 +561,9 @@
struct bios_file *b;
UNUSED(dir);
+ if (curproc->euid)
+ return EACCDN;
+
if ((unsigned)cmd == DEV_INSTALL) {
struct dev_descr *d = (struct dev_descr *)arg;
@@ -608,6 +620,9 @@
struct bios_file *b;
long r;
fcookie fc;
+
+ if (curproc->euid)
+ return EACCDN;
r = bios_lookup(dir, name, &fc);
if (r == 0) return EACCDN; /* file already exists */