1192595Sdes/* $OpenBSD: sftp-server-main.c,v 1.4 2009/02/21 19:32:04 tobias Exp $ */ 2180746Sdes/* 3180746Sdes * Copyright (c) 2008 Markus Friedl. All rights reserved. 4180746Sdes * 5180746Sdes * Permission to use, copy, modify, and distribute this software for any 6180746Sdes * purpose with or without fee is hereby granted, provided that the above 7180746Sdes * copyright notice and this permission notice appear in all copies. 8180746Sdes * 9180746Sdes * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10180746Sdes * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11180746Sdes * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12180746Sdes * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13180746Sdes * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14180746Sdes * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15180746Sdes * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16180746Sdes */ 17180746Sdes 18180746Sdes#include "includes.h" 19180746Sdes 20180746Sdes#include <sys/types.h> 21180746Sdes#include <pwd.h> 22180746Sdes#include <stdarg.h> 23180746Sdes#include <stdio.h> 24180746Sdes#include <unistd.h> 25180746Sdes 26180746Sdes#include "log.h" 27180746Sdes#include "sftp.h" 28180746Sdes#include "misc.h" 29180746Sdes 30180746Sdesvoid 31180746Sdescleanup_exit(int i) 32180746Sdes{ 33180746Sdes sftp_server_cleanup_exit(i); 34180746Sdes} 35180746Sdes 36180746Sdesint 37180746Sdesmain(int argc, char **argv) 38180746Sdes{ 39180746Sdes struct passwd *user_pw; 40180746Sdes 41180746Sdes /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 42180746Sdes sanitise_stdfd(); 43180746Sdes 44180746Sdes if ((user_pw = getpwuid(getuid())) == NULL) { 45192595Sdes fprintf(stderr, "No user found for uid %lu\n", 46192595Sdes (u_long)getuid()); 47180746Sdes return 1; 48180746Sdes } 49180746Sdes 50180746Sdes return (sftp_server_main(argc, argv, user_pw)); 51180746Sdes} 52