summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/sftp-server-main.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-02-08 23:24:09 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-02-08 23:24:09 +0000
commitb61be46adafe7676e6b3c1ca4903b6c64b007db1 (patch)
tree667e7da24f8446b750b5b3162f7732b4968a72d0 /usr.bin/ssh/sftp-server-main.c
parentb425483dcf67a41ad5d6c58871e3e43a9b582db9 (diff)
add sshd_config ChrootDirectory option to chroot(2) users to a directory and
tweak internal sftp server to work with it (no special files in chroot required). ok markus@
Diffstat (limited to 'usr.bin/ssh/sftp-server-main.c')
-rw-r--r--usr.bin/ssh/sftp-server-main.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp-server-main.c b/usr.bin/ssh/sftp-server-main.c
index 993455b6c0a..2a4c4f95093 100644
--- a/usr.bin/ssh/sftp-server-main.c
+++ b/usr.bin/ssh/sftp-server-main.c
@@ -16,10 +16,14 @@
*/
#include <sys/types.h>
+#include <pwd.h>
#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
#include "log.h"
#include "sftp.h"
+#include "misc.h"
void
cleanup_exit(int i)
@@ -30,5 +34,15 @@ cleanup_exit(int i)
int
main(int argc, char **argv)
{
- return (sftp_server_main(argc, argv));
+ struct passwd *user_pw;
+
+ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
+ sanitise_stdfd();
+
+ if ((user_pw = getpwuid(getuid())) == NULL) {
+ fprintf(stderr, "No user found for uid %lu", (u_long)getuid());
+ return 1;
+ }
+
+ return (sftp_server_main(argc, argv, user_pw));
}