From owner-freebsd-questions Tue Oct 12 4:21:29 1999 Delivered-To: freebsd-questions@freebsd.org Received: from axl.noc.iafrica.com (axl.noc.iafrica.com [196.31.1.175]) by hub.freebsd.org (Postfix) with ESMTP id 02FFB14DD5 for ; Tue, 12 Oct 1999 04:21:23 -0700 (PDT) (envelope-from sheldonh@axl.noc.iafrica.com) Received: from sheldonh (helo=axl.noc.iafrica.com) by axl.noc.iafrica.com with local-esmtp (Exim 3.037 #1) id 11azzF-000PRn-00; Tue, 12 Oct 1999 13:20:57 +0200 From: Sheldon Hearn To: Huidae Cho Cc: freebsd-questions@FreeBSD.ORG Subject: Re: FTP incoming In-reply-to: Your message of "Tue, 12 Oct 1999 14:59:37 +0900." <199910120559.OAA17721@unix.knu.ac.kr> Date: Tue, 12 Oct 1999 13:20:57 +0200 Message-ID: <97822.939727257@axl.noc.iafrica.com> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 12 Oct 1999 14:59:37 +0900, Huidae Cho wrote: > i want to prevent anonymous users from removing files in incoming dir. > > i set sticky bit to incoming dir. however, it didn't work at all. > > how can i do? You should get away with this untested diff. :-) Ciao, Sheldon. PS: The diff may not apply cleanly to your sources, because you didn't tell us which version of FreeBSD you're using. Index: ftpd.c =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.59 diff -u -d -5 -r1.59 ftpd.c --- ftpd.c 1999/09/19 22:05:29 1.59 +++ ftpd.c 1999/10/12 11:19:19 @@ -1912,12 +1912,39 @@ void delete(name) char *name; { struct stat st; + char *dir, *p; + int l; LOGCMD("delete", name); + if (guest) { + p = strrchr(name, '/'); + if (p == NULL) { + dir = "."; + } else if (p == name) { + dir = "/"; + } else if (p == name + strlen(name) - 1) { + dir = NULL; + } else { + l = p - name + 1; + dir = (char *)malloc(l + 1); + strncpy(dir, name, l); + dir[l] = '\0'; + } + if (dir != NULL) { + if (stat(dir, &st) < 0) { + perror_reply(550, dir); + return; + } else if (st.st_mode&S_ISVTX) { + errno = EPERM; + perror_reply(550, name); + return; + } + } + } if (stat(name, &st) < 0) { perror_reply(550, name); return; } if ((st.st_mode&S_IFMT) == S_IFDIR) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message