Subject: Re: ftpaccess problem with the upload command and guest accounts - Follow Up

From: [email-masked] (Andy Church)
Date: Thu, 11 Jun 1998 16:28:41 EDT

>I received some good comments about how this has been patched a few months
>back.  I was able to retrieve both a full set of patches incorporating
>several things as well as an isolated patch for just the mkdir problem.  A
>few things I've noted:
>
>1.  [mkdir patch doesn't work with newvirt patch]

     I've never tried the newvirt code, but I know it changes a lot of
stuff, so I'm not too surprised.  Since I don't use newvirt, someone else
will have to get them to work together.

>2.  The mkdir patch only looks to allow you to specify the mode of the
>    created directory, not the owner or the group.

     The patch takes the same values for directory owner and group as are
given for files.  The reason I added a mode parameter was because
directories usually need to have different modes than files (in particular,
directories need the execute bit).  I don't see a reason to have a
different owner and group for directories, so I didn't add parameters for
them--after all, the upload directive is long enough already.  (On the
other hand, if the patch isn't setting owner and group at all, that's a bug
that needs to be fixed.)

  --Andy Church                  | If Bell Atlantic really is the heart
    [email-masked]       | of communication, then it desperately
    www.dragonfire.net/~achurch/ | needs a quadruple bypass.

---

From: Aaron Holtz <[email-masked]>
Date: Thu, 11 Jun 1998 16:36:18 -0400 (EDT)

I apologize for reading the code as if the mkdir statement was not 
changing the ownership and group name of the created directory based on
values from the upload statement.  I will still try and work further on
getting it to compile with the newvirt code.  I'm not seeing the typo
pointed out by Greg as possibly existing, but my compile errors do give me
errors that may point to such a thing (all hunks succeed on applying the
mkdir.patch from dragonfire.net):

gcc -O -g -I.. -I../support -L../support -DVIRTUAL  -target sun4 -c
ftpd.c
ftpd.c: In function `makedir':
ftpd.c:3093: parse error before `<'
ftpd.c:3099: `st' undeclared (first use this function)
ftpd.c:3099: (Each undeclared identifier is reported only once
ftpd.c:3099: for each function it appears in.)
ftpd.c:3100: `oldid' undeclared (first use this function)
ftpd.c:3105: `fd' undeclared (first use this function)
ftpd.c: At top level:
ftpd.c:3127: parse error before `257'
ftpd.c:3127: conflicting types for `reply'
ftpd.c:2765: previous declaration of `reply'
ftpd.c:3127: warning: data definition has no type or storage class
*** Error code 1
make: Fatal error: Command failed for target `ftpd.o'

If you are interested in any more information, I'd be happy to oblige.
Thanks.

-------------------------------------------------------------------------
Aaron Holtz
First Network Group    "The First Name in Internetworking"
Manager, UNIX Systems Admin
Email:  [email-masked]
"We do these things not because they are easy, 
 but because they are hard."  -JFK
-------------------------------------------------------------------------

On Thu, 11 Jun 1998, Andy Church wrote:

> Date: Thu, 11 Jun 1998 16:28:41 EDT
> From: Andy Church <[email-masked]>
> To: Aaron Holtz <[email-masked]>
> Cc: [email-masked]
> Subject: Re: ftpaccess problem with the upload command and guest accounts - Follow Up
>

---

From: Gregory A Lundberg <[email-masked]>
Date: Thu, 11 Jun 1998 16:56:09 -0400 (EDT)

> make: Fatal error: Command failed for target `ftpd.o'

that looks liek the errors I got, too.  Here's the patched code from my
source base.

----

void
#ifdef __STDC__
makedir(char *name)
#else
makedir(name)
char *name;
#endif
{
        uid_t uid;
        gid_t gid;
        int   d_mode;
        int   valid;
        uid_t oldid;

    /*
     * check the directory, can we mkdir here?
     */
    if ( (dir_check(name, &uid, &gid, &d_mode, &valid)) <= 0 )
        return;

    /*
     * check the filename, is it legal?
     */
    if ( (fn_check(name)) <= 0 )
        return;

    if (valid <= 0)
        d_mode = 0777;
    if (mkdir(name, d_mode) < 0) {
        if (errno == EEXIST)
            perror_reply(553, name);
        else
            perror_reply(550, name);
        return;
    }
    if (valid > 0) {
        oldid = geteuid();
        delay_signaling(); /* we can't allow any signals while euid==0: kinch */
        (void) seteuid((uid_t) 0);
        if ((chown(name, uid, gid)) < 0) {
            (void) seteuid(oldid);
            enable_signaling(); /* we can allow signals once again: kinch */
            perror_reply(550, "chown");
            return;
        }
        (void) seteuid(oldid);
        enable_signaling(); /* we can allow signals once again: kinch */
    }
    reply(257, "MKD command successful.");
}

----

Gregory A Lundberg		Senior Partner, VRnet Company
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195

---

From: Gregory A Lundberg <[email-masked]>
Date: Thu, 11 Jun 1998 16:57:53 -0400 (EDT)

> will have to get them to work together.

On my plate for sometime in the next couple weeks ..

Kent: you updated newvirt to beta-17 yet?  If not, I'll send you what I
come up with, when I come up with it.

----

---

From: Andy Mell <[email-masked]>
Date: Thu, 11 Jun 1998 23:50:03 +0100 (BST)

On Thu, 11 Jun 1998, Andy Church wrote:
> different owner and group for directories.

Theres a very good reason for this.

When you have multiple incoming directories, and each incoming directory
is administered by a different user you need to force the owner and group
for newly created directories within incoming so that the administrator of
that incoming directory is able to delete files.

At the moment I have to delete files for my ftp administrators, which is a
bit ridiculous. However, I now have beta-17 with Gregorys VR1 and VR2
patches so will be trying this to see if that work. My fingers are crossed.

Andy
-- 
Andy Mell, Network Admin, Cambridge University Press, Shaftesbury Road,
Cambridge CB2 2RU, UK.      Phone +44-1893-359536, Fax +44-1223-325972
Email: [email-masked], Urgent email: [email-masked]