1/* $NetBSD: sftp-server-main.c,v 1.8 2019/10/12 18:32:22 christos Exp $ */ 2/* $OpenBSD: sftp-server-main.c,v 1.6 2019/06/06 05:13:13 otto 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 "includes.h" 20__RCSID("$NetBSD: sftp-server-main.c,v 1.8 2019/10/12 18:32:22 christos Exp $"); 21#include <sys/types.h> 22#include <pwd.h> 23#include <stdarg.h> 24#include <stdio.h> 25#include <unistd.h> 26#include <time.h> 27 28#include "log.h" 29#include "sftp.h" 30#include "misc.h" 31#include "xmalloc.h" 32 33void 34cleanup_exit(int i) 35{ 36 sftp_server_cleanup_exit(i); 37} 38 39int 40main(int argc, char **argv) 41{ 42 struct passwd *user_pw; 43 44 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 45 sanitise_stdfd(); 46 47 if ((user_pw = getpwuid(getuid())) == NULL) { 48 fprintf(stderr, "No user found for uid %lu\n", 49 (u_long)getuid()); 50 return 1; 51 } 52 53 return (sftp_server_main(argc, argv, user_pw)); 54} 55