1 2 /* 3 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #include "includes.h" 19 20 #include <sys/types.h> 21 #ifdef HAVE_SYS_SELECT_H 22 # include <sys/select.h> 23 #endif 24 #ifdef HAVE_SYS_TIME_H 25 # include <sys/time.h> 26 #endif 27 28 #include <fcntl.h> 29 #include <string.h> 30 #include <signal.h> 31 #include <stdlib.h> 32 #include <stdio.h> 33 #include <time.h> 34 #include <unistd.h> 35 36 #ifndef HAVE___PROGNAME 37 char *__progname; 38 #endif 39 40 /* 41 * NB. duplicate __progname in case it is an alias for argv[0] 42 * Otherwise it may get clobbered by setproctitle() 43 */ 44 char *ssh_get_progname(char *argv0) 45 { 46 char *p, *q; 47 #ifdef HAVE___PROGNAME 48 extern char *__progname; 49 50 p = __progname; 51 #else 52 if (argv0 == NULL) 53 return ("unknown"); /* XXX */ 54 p = strrchr(argv0, '/'); 55 if (p == NULL) 56 p = argv0; 57 else 58 p++; 59 #endif 60 if ((q = strdup(p)) == NULL) { 61 perror("strdup"); 62 exit(1); 63 } 64 return q; 65 } 66 67 #ifndef HAVE_PLEDGE 68 int 69 pledge(const char *promises, const char *paths[]) 70 { 71 return 0; 72 } 73 #endif 74