sftp-server-main.c revision 192595
1212793Sdim/* $OpenBSD: sftp-server-main.c,v 1.4 2009/02/21 19:32:04 tobias Exp $ */ 2212793Sdim/* 3212793Sdim * Copyright (c) 2008 Markus Friedl. All rights reserved. 4212793Sdim * 5212793Sdim * Permission to use, copy, modify, and distribute this software for any 6212793Sdim * purpose with or without fee is hereby granted, provided that the above 7212793Sdim * copyright notice and this permission notice appear in all copies. 8212793Sdim * 9212793Sdim * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10212793Sdim * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11212793Sdim * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12212793Sdim * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13212793Sdim * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14212793Sdim * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15218893Sdim * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16212793Sdim */ 17218893Sdim 18212793Sdim#include "includes.h" 19212793Sdim 20212793Sdim#include <sys/types.h> 21218893Sdim#include <pwd.h> 22212793Sdim#include <stdarg.h> 23212793Sdim#include <stdio.h> 24212793Sdim#include <unistd.h> 25212793Sdim 26212793Sdim#include "log.h" 27212793Sdim#include "sftp.h" 28212793Sdim#include "misc.h" 29212793Sdim 30212793Sdimvoid 31212793Sdimcleanup_exit(int i) 32212793Sdim{ 33212793Sdim sftp_server_cleanup_exit(i); 34212793Sdim} 35212793Sdim 36212793Sdimint 37212793Sdimmain(int argc, char **argv) 38212793Sdim{ 39212793Sdim struct passwd *user_pw; 40218893Sdim 41212793Sdim /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 42212793Sdim sanitise_stdfd(); 43218893Sdim 44218893Sdim if ((user_pw = getpwuid(getuid())) == NULL) { 45218893Sdim fprintf(stderr, "No user found for uid %lu\n", 46218893Sdim (u_long)getuid()); 47218893Sdim return 1; 48218893Sdim } 49212793Sdim 50212793Sdim return (sftp_server_main(argc, argv, user_pw)); 51218893Sdim} 52218893Sdim