sftp-server-main.c revision 1.1.1.1
1/*	$NetBSD: sftp-server-main.c,v 1.1.1.1 2009/06/07 22:19:14 christos Exp $	*/
2/* $OpenBSD: sftp-server-main.c,v 1.4 2009/02/21 19:32:04 tobias Exp $ */
3/*
4 * Copyright (c) 2008 Markus Friedl.  All rights reserved.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <sys/types.h>
20#include <pwd.h>
21#include <stdarg.h>
22#include <stdio.h>
23#include <unistd.h>
24
25#include "log.h"
26#include "sftp.h"
27#include "misc.h"
28
29void
30cleanup_exit(int i)
31{
32	sftp_server_cleanup_exit(i);
33}
34
35int
36main(int argc, char **argv)
37{
38	struct passwd *user_pw;
39
40	/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
41	sanitise_stdfd();
42
43	if ((user_pw = getpwuid(getuid())) == NULL) {
44		fprintf(stderr, "No user found for uid %lu\n",
45		    (u_long)getuid());
46		return 1;
47	}
48
49	return (sftp_server_main(argc, argv, user_pw));
50}
51