( taxy | 2011. 09. 17., szo – 12:19 )

Ha már itt tartunk ez a patch szerintetek elfogadhatóan biztonságos?


--- sftp-server.c	2010-01-13 11:44:06.000000000 +0000
+++ sftp-server3.c	2011-09-07 15:30:23.000000000 +0000
@@ -13,6 +13,12 @@
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ ************************************************************************
+ * This version modified to provide chroot'd SFTP
+ *
+ * Search for 'Minstrel' in this file to find modifications
+ ************************************************************************
  */
 
 #include "includes.h"
@@ -51,6 +57,10 @@
 #include "sftp.h"
 #include "sftp-common.h"
 
+/* Following single line added by Minstrel */
+
+#define CHROOT
+
 /* helper */
 #define get_int64()			buffer_get_int64(&iqueue);
 #define get_int()			buffer_get_int(&iqueue);
@@ -1441,6 +1451,20 @@ sftp_server_main(int argc, char **argv,
 
 	logit("session opened for local user %s from [%s]",
 	    pw->pw_name, client_addr);
+/* Start additions by Minstrel */
+
+#ifdef CHROOT
+	if(strcmp(pw->pw_shell,"/bin/sftpsh") == 0){
+		if (chroot(pw->pw_dir) != 0)
+			fatal("Couldn't chroot to user directory %s: %s", pw->pw_dir, strerror(errno));
+		else
+			setenv("HOME", "/", 1);
+	}
+#endif
+	if (setuid(getuid()) != 0 || setgid(getgid()) != 0)
+		fatal("Couldn't drop privileges: %s", strerror(errno));
+
+/* End additions by Minstrel */
 
 	in = STDIN_FILENO;
 	out = STDOUT_FILENO;

A légyege hogy setuid-os az sftpserver, és ledobja miután chroot-oldt.
Az is lenne a kérdésem, hogy más ezt hogy szokta megoldani?

Szerk: Válasz a kérdésemre:
Aha:
http://www.debian-administration.org/articles/590

Szóval ez is egy elavult gányolás a részemről. Gondoltam, de csak most vetődött fel a kérdés bennem egyáltalán.