[535] in testers
Re: rt 6.4R: attach
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Dec 19 18:49:13 1989
Date: Tue, 19 Dec 89 18:48:47 EST
From: Theodore Ts'o <tytso@ATHENA.MIT.EDU>
To: Jonathan I. Kamens <jik@PIT-MANAGER.MIT.EDU>
Cc: testers@ATHENA.MIT.EDU
In-Reply-To: Jonathan I. Kamens's message of Tue, 19 Dec 89 11:01:51 -0500,
Reply-To: tytso@ATHENA.MIT.EDU
Fixed. The problem was in various people's insistance that attach blow
away symlinks during the process of an AFS attach. I changed attach to
do so (if keep_mount is off), but I forgot to consider the implications
of such a change. Since I think this is the wrong thing to do (and a
security hole besides), I normally run with keep_mount enabled, so I
didn't run into this problem.
Patches so that attach will complain if the attached filesystem uses a
mountpoint used by another already mounted filesystem follow this
message. Note that this still allows you to blow away sym links and is
still potentially a security hole --- if you don't like this, run with
keep_mount enabled (Just add ``keep_mount'' on in your
/etc/attach.conf). (The original justification was something about
hesiod pointers changing; I don't remember exactly.)
- Ted
*** /tmp/,RCSt1005543 Tue Dec 19 18:41:24 1989
--- attach.h Tue Dec 19 18:23:30 1989
***************
*** 235,240 ****
--- 235,242 ----
#define ERR_ATTACHBADMNTPT 25 /* User not allowed to mount a */
/* filesystem here */
#define ERR_ATTACHNOFILSYS 26 /* The remote filesystem doesn't exist */
+ #define ERR_ATTACHDIRINUSE 27 /* Some other filesystem is using the */
+ /* mountpoint directory */
#define ERR_DETACHNOTATTACHED 20 /* Filesystem not attached */
#define ERR_DETACHINUSE 21 /* Filesystem in use by another proc */
RCS file: RCS/attach.c,v
retrieving revision 2.9
diff -c -r2.9 attach.c
*** /tmp/,RCSt1005533 Tue Dec 19 18:40:31 1989
--- attach.c Tue Dec 19 18:37:02 1989
***************
*** 147,153 ****
mark_in_use(name);
attachtab_append(&at);
put_attachtab();
- free_attachtab();
unlock_attachtab();
for (i=0;hes[i];i++) {
--- 147,152 ----
***************
*** 156,161 ****
--- 155,161 ----
if (caught_signal) {
if (debug_flag)
printf("Caught signal; cleaning up attachtab....\n");
+ free_attachtab();
lock_attachtab();
get_attachtab();
attachtab_delete(attachtab_lookup(at.hesiodname));
***************
*** 169,179 ****
* successful.
*/
if (try_attach(name, hes[i], !hes[i+1]) == SUCCESS) {
! mark_in_use(NULL);
! end_critical_code();
! return (SUCCESS);
}
}
if (error_status == ERR_ATTACHNOTALLOWED)
fprintf(stderr, "Sorry, you're not allowed to attach %s.\n",
--- 169,181 ----
* successful.
*/
if (try_attach(name, hes[i], !hes[i+1]) == SUCCESS) {
! free_attachtab();
! mark_in_use(NULL);
! end_critical_code();
! return (SUCCESS);
}
}
+ free_attachtab();
if (error_status == ERR_ATTACHNOTALLOWED)
fprintf(stderr, "Sorry, you're not allowed to attach %s.\n",
***************
*** 208,214 ****
char *name, *hesline;
int errorout;
{
! struct _attachtab at;
int status;
int attach_suid;
#ifdef ZEPHYR
--- 210,216 ----
char *name, *hesline;
int errorout;
{
! struct _attachtab at, *atp;
int status;
int attach_suid;
#ifdef ZEPHYR
***************
*** 249,254 ****
--- 251,262 ----
error_status = ERR_ATTACHBADMNTPT;
return(FAILURE);
}
+ }
+ if (atp=attachtab_lookup_mntpt(at.mntpt)) {
+ fprintf(stderr,"%s: Filesystem %s is already mounted on %s\n",
+ at.hesiodname, atp->hesiodname, at.mntpt);
+ error_status = ERR_ATTACHDIRINUSE;
+ return(FAILURE);
}
if (override_mode)