Subject: RE: Solaris 2.6 Guest-root restricted-uid setup

From: David Stringer <[email-masked]>
Date: Tue, 4 May 1999 09:21:44 -0600

Gregory:

Our current version of wu-ftp-2.4(9) does exactly what you mention below.
There is a guestroot (not guest-root) command that will do a chroot, and
grab the system etc/passwd information and strip out the guestroot part of
the path.  I don't know if this was a modification that someone did here, or
if it was in the ftp sources already and never documented. 

If you could make a patch to the current version that would accomplish this
I would be very grateful. 

Thanks,
David Stringer

Code snippet from out current version of wu-ftp:

    if (anonymous || guest) {
        /* We MUST do a chdir() after the chroot. Otherwise the old current
         * directory will be accessible as "." outside the new root! */
        if (anonymous) {
            if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
                reply(550, "Can't set guest privileges.");
                goto bad;
            }
        } else if (guest) {
            char *sp;
                char cdir[256];
                char rdir[256];

            /* determine root and home directory */

        getaclentry("guestroot", &entry);
        syslog(LOG_DEBUG,"guestroot: %s",ARG0);
        syslog(LOG_DEBUG,"pw dir: %s",pw->pw_dir);
            if ((sp = strstr(pw->pw_dir, ARG0)) == NULL) {
                        syslog(LOG_DEBUG,"oops");
                if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
                    reply(550, "Can't set guest privileges.");
                    goto bad;
                }
            } else {
                sp += strlen(ARG0);
                *sp = '\0';
                ++sp;
                strcpy(cdir,"/");
                strcat(cdir,sp);
                strcpy(rdir,pw->pw_dir);
                strcat(rdir,"/");
                syslog(LOG_DEBUG,"chdir : %s",cdir);
                syslog(LOG_DEBUG,"chroot dir: %s",rdir);

                if (chroot(rdir) < 0 || chdir(cdir) < 0) {
                    reply(550, "Can't set guest privileges.");
                    goto bad;
                }
            }
        }
    } else {
        if (chdir(pw->pw_dir) < 0) {
            if (chdir("/") < 0) {
                reply(530, "User %s: can't change directory to %s.",
                      pw->pw_name, pw->pw_dir);
                goto bad;
            } else
                lreply(230, "No directory! Logging in with home=/");
        }
    }
> -----Original Message-----
> From:	Gregory A Lundberg [SMTP:[email-masked]]
> Sent:	Monday, May 03, 1999 11:26 AM
> To:	David Stringer
> Cc:	[email-masked]'
> Subject:	RE: Solaris 2.6 Guest-root restricted-uid setup
> 
> On Mon, 3 May 1999, David Stringer wrote:
> 
> > So if I read this properly, the workable options are:
> > 	1. Use the guestgroup/passwd file hack
> (/export/home/./export/home/username)
> > 	2. Create another passwd file for all guest users
> (/export/home/etc/passwd)
> 
> First off, I handle the problem by hacking my useradd / userdel scripts to
> create / delete the FTP passwd and group file entries when it does the
> main system passwd / group files.
> 
> I could see an argument for not requiring the FTP-local passwd/group
> files.  It would take some syntax in the ftpaccess file to tell the daemon
> when it sees guest-root to use the system /etc/passwd file to locate the
> user's home directory and strip the guest-root directory from the front of
> it.
> 
> Without an FTP-local passwd file some things will break:
> 
>  - No usernames or group names when doing 'ls'
>  - No ~ globbing for CWD, etc.
> 
> I'd have to think about other ramifications of not having an FTP-local
> passwd or group file.
> 
> Since none of the problems (that I've thought of) would prevent normal
> operation of the daemon in all other respects, if you ask and are willing
> to wait a week or so for me to get 'round to it, I could do up a patch for
> you.
> 
> -- 
> 
> 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: Tue, 4 May 1999 11:30:04 -0400 (EDT)

On Tue, 4 May 1999, David Stringer wrote:

> Our current version of wu-ftp-2.4(9) does exactly what you mention
> below. There is a guestroot (not guest-root) command that will do a
> chroot, and grab the system etc/passwd information and strip out the
> guestroot part of the path.  I don't know if this was a modification
> that someone did here, or if it was in the ftp sources already and
> never documented.
> 
> If you could make a patch to the current version that would accomplish
> this I would be very grateful.

That's a local mod someone did your your site.  It's along the lines of
what I was thinking.  Right now I have higher-priority work, it'll be a
few days (maybe a week) until I can get to this.

--