Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Oct 1999 13:20:57 +0200
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        Huidae Cho <hdcho@unix.knu.ac.kr>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: FTP incoming 
Message-ID:  <97822.939727257@axl.noc.iafrica.com>
In-Reply-To: Your message of "Tue, 12 Oct 1999 14:59:37 %2B0900." <199910120559.OAA17721@unix.knu.ac.kr> 

next in thread | previous in thread | raw e-mail | index | archive | help


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?97822.939727257>