Bugzilla – Attachment 1018 Details for
Bug 177
provide chroot option for sftp-server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
A patch to provide chroot functionality to sftp-server
sftp-chroot.diff (text/plain), 1.23 KB, created by
dAniel hAhler
on 2005-10-30 16:25:20 AEDT
(
hide
)
Description:
A patch to provide chroot functionality to sftp-server
Filename:
MIME Type:
Creator:
dAniel hAhler
Created:
2005-10-30 16:25:20 AEDT
Size:
1.23 KB
patch
obsolete
>--- sftp-server.c Fri Apr 13 08:28:42 2001 >+++ sftp-server.c.chroot Wed May 23 18:16:07 2001 >@@ -33,6 +33,8 @@ > #include "sftp.h" > #include "sftp-common.h" > >+#define CHROOT >+ > /* helper */ > #define get_int64() buffer_get_int64(&iqueue); > #define get_int() buffer_get_int(&iqueue); >@@ -1024,6 +1026,36 @@ > } > } > >+#ifdef CHROOT >+void >+chroot_init(void) >+{ >+ char *user_dir, *new_root; >+ >+ user_dir = getenv("HOME"); >+ if (!user_dir) >+ fatal("HOME isn't in environment"); >+ >+ new_root = user_dir + 1; >+ >+ while ((new_root = strchr(new_root, '.')) != NULL) { >+ new_root--; >+ if (strncmp(new_root, "/./", 3) == 0) { >+ *new_root = '\0'; >+ new_root += 2; >+ >+ if (chroot(user_dir) != 0) >+ fatal("Couldn't chroot to user directory %s: %s", >+ user_dir, strerror(errno)); >+ >+ setenv("HOME", new_root, 1); >+ break; >+ } >+ new_root += 2; >+ } >+} >+#endif /* CHROOT */ >+ > int > main(int ac, char **av) > { >@@ -1039,6 +1071,12 @@ > #ifdef DEBUG_SFTP_SERVER > log_init("sftp-server", SYSLOG_LEVEL_DEBUG1, SYSLOG_FACILITY_AUTH, 0); > #endif >+ >+#ifdef CHROOT >+ chroot_init(); >+#endif >+ if (setuid(getuid()) != 0) >+ fatal("Couldn't drop privileges: %s", strerror(errno)); > > in = dup(STDIN_FILENO); > out = dup(STDOUT_FILENO); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 177
:
683
|
1018
|
1156
|
1206
|
1277
|
1346