port-aix.h revision 323134
1/* 2 * 3 * Copyright (c) 2001 Gert Doering. All rights reserved. 4 * Copyright (c) 2004,2005,2006 Darren Tucker. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#ifdef _AIX 28 29#ifdef HAVE_SYS_SOCKET_H 30# include <sys/socket.h> 31#endif 32 33#include "buffer.h" 34 35/* These should be in the system headers but are not. */ 36int usrinfo(int, char *, int); 37#if defined(HAVE_DECL_SETAUTHDB) && (HAVE_DECL_SETAUTHDB == 0) 38int setauthdb(const char *, char *); 39#endif 40/* these may or may not be in the headers depending on the version */ 41#if defined(HAVE_DECL_AUTHENTICATE) && (HAVE_DECL_AUTHENTICATE == 0) 42int authenticate(char *, char *, int *, char **); 43#endif 44#if defined(HAVE_DECL_LOGINFAILED) && (HAVE_DECL_LOGINFAILED == 0) 45int loginfailed(char *, char *, char *); 46#endif 47#if defined(HAVE_DECL_LOGINRESTRICTIONS) && (HAVE_DECL_LOGINRESTRICTIONS == 0) 48int loginrestrictions(char *, int, char *, char **); 49#endif 50#if defined(HAVE_DECL_LOGINSUCCESS) && (HAVE_DECL_LOGINSUCCESS == 0) 51int loginsuccess(char *, char *, char *, char **); 52#endif 53#if defined(HAVE_DECL_PASSWDEXPIRED) && (HAVE_DECL_PASSWDEXPIRED == 0) 54int passwdexpired(char *, char **); 55#endif 56 57/* Some versions define r_type in the above headers, which causes a conflict */ 58#ifdef r_type 59# undef r_type 60#endif 61 62/* AIX 4.2.x doesn't have nanosleep but does have nsleep which is equivalent */ 63#if !defined(HAVE_NANOSLEEP) && defined(HAVE_NSLEEP) 64# define nanosleep(a,b) nsleep(a,b) 65#endif 66 67/* For struct timespec on AIX 4.2.x */ 68#ifdef HAVE_SYS_TIMERS_H 69# include <sys/timers.h> 70#endif 71 72/* for setpcred and friends */ 73#ifdef HAVE_USERSEC_H 74# include <usersec.h> 75#endif 76 77/* 78 * According to the setauthdb man page, AIX password registries must be 15 79 * chars or less plus terminating NUL. 80 */ 81#ifdef HAVE_SETAUTHDB 82# define REGISTRY_SIZE 16 83#endif 84 85void aix_usrinfo(struct passwd *); 86 87#ifdef WITH_AIXAUTHENTICATE 88# define CUSTOM_SYS_AUTH_PASSWD 1 89# define CUSTOM_SYS_AUTH_ALLOWED_USER 1 90int sys_auth_allowed_user(struct passwd *, Buffer *); 91# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 92int sys_auth_record_login(const char *, const char *, const char *, Buffer *); 93# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG 94char *sys_auth_get_lastlogin_msg(const char *, uid_t); 95# define CUSTOM_FAILED_LOGIN 1 96# if defined(S_AUTHDOMAIN) && defined (S_AUTHNAME) 97# define USE_AIX_KRB_NAME 98char *aix_krb5_get_principal_name(char *); 99# endif 100#endif 101 102void aix_setauthdb(const char *); 103void aix_restoreauthdb(void); 104void aix_remove_embedded_newlines(char *); 105 106#if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_GETADDRINFO) 107# ifdef getnameinfo 108# undef getnameinfo 109# endif 110int sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t, 111 char *, size_t, int); 112# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g)) 113#endif 114 115/* 116 * We use getgrset in preference to multiple getgrent calls for efficiency 117 * plus it supports NIS and LDAP groups. 118 */ 119#if !defined(HAVE_GETGROUPLIST) && defined(HAVE_GETGRSET) 120# define HAVE_GETGROUPLIST 121# define USE_GETGRSET 122int getgrouplist(const char *, gid_t, gid_t *, int *); 123#endif 124 125#endif /* _AIX */ 126