1106121Sdes/* 2106121Sdes * 3106121Sdes * Copyright (c) 2001 Gert Doering. All rights reserved. 4181111Sdes * Copyright (c) 2004,2005,2006 Darren Tucker. All rights reserved. 5106121Sdes * 6106121Sdes * Redistribution and use in source and binary forms, with or without 7106121Sdes * modification, are permitted provided that the following conditions 8106121Sdes * are met: 9106121Sdes * 1. Redistributions of source code must retain the above copyright 10106121Sdes * notice, this list of conditions and the following disclaimer. 11106121Sdes * 2. Redistributions in binary form must reproduce the above copyright 12106121Sdes * notice, this list of conditions and the following disclaimer in the 13106121Sdes * documentation and/or other materials provided with the distribution. 14106121Sdes * 15106121Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16106121Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17106121Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18106121Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19106121Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20106121Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21106121Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22106121Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23106121Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24106121Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25106121Sdes */ 26106121Sdes 2798937Sdes#ifdef _AIX 28113908Sdes 29146998Sdes#ifdef HAVE_SYS_SOCKET_H 30146998Sdes# include <sys/socket.h> 31146998Sdes#endif 32146998Sdes 33146998Sdes#include "buffer.h" 34146998Sdes 35146998Sdes/* These should be in the system headers but are not. */ 36146998Sdesint usrinfo(int, char *, int); 37149749Sdes#if defined(HAVE_DECL_SETAUTHDB) && (HAVE_DECL_SETAUTHDB == 0) 38146998Sdesint setauthdb(const char *, char *); 39147001Sdes#endif 40146998Sdes/* these may or may not be in the headers depending on the version */ 41149749Sdes#if defined(HAVE_DECL_AUTHENTICATE) && (HAVE_DECL_AUTHENTICATE == 0) 42146998Sdesint authenticate(char *, char *, int *, char **); 43146998Sdes#endif 44149749Sdes#if defined(HAVE_DECL_LOGINFAILED) && (HAVE_DECL_LOGINFAILED == 0) 45146998Sdesint loginfailed(char *, char *, char *); 46146998Sdes#endif 47149749Sdes#if defined(HAVE_DECL_LOGINRESTRICTIONS) && (HAVE_DECL_LOGINRESTRICTIONS == 0) 48146998Sdesint loginrestrictions(char *, int, char *, char **); 49146998Sdes#endif 50149749Sdes#if defined(HAVE_DECL_LOGINSUCCESS) && (HAVE_DECL_LOGINSUCCESS == 0) 51146998Sdesint loginsuccess(char *, char *, char *, char **); 52146998Sdes#endif 53149749Sdes#if defined(HAVE_DECL_PASSWDEXPIRED) && (HAVE_DECL_PASSWDEXPIRED == 0) 54146998Sdesint passwdexpired(char *, char **); 55146998Sdes#endif 56146998Sdes 57124208Sdes/* Some versions define r_type in the above headers, which causes a conflict */ 58124208Sdes#ifdef r_type 59124208Sdes# undef r_type 60124208Sdes#endif 61124208Sdes 62113908Sdes/* AIX 4.2.x doesn't have nanosleep but does have nsleep which is equivalent */ 63113908Sdes#if !defined(HAVE_NANOSLEEP) && defined(HAVE_NSLEEP) 64113908Sdes# define nanosleep(a,b) nsleep(a,b) 65113908Sdes#endif 66113908Sdes 67113908Sdes/* For struct timespec on AIX 4.2.x */ 68113908Sdes#ifdef HAVE_SYS_TIMERS_H 69113908Sdes# include <sys/timers.h> 70113908Sdes#endif 71113908Sdes 72197679Sdes/* for setpcred and friends */ 73197679Sdes#ifdef HAVE_USERSEC_H 74197679Sdes# include <usersec.h> 75197679Sdes#endif 76197679Sdes 77126274Sdes/* 78126274Sdes * According to the setauthdb man page, AIX password registries must be 15 79126274Sdes * chars or less plus terminating NUL. 80126274Sdes */ 81126274Sdes#ifdef HAVE_SETAUTHDB 82126274Sdes# define REGISTRY_SIZE 16 83126274Sdes#endif 84126274Sdes 85126274Sdesvoid aix_usrinfo(struct passwd *); 86126274Sdes 87124208Sdes#ifdef WITH_AIXAUTHENTICATE 88126274Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 89137015Sdes# define CUSTOM_SYS_AUTH_ALLOWED_USER 1 90146998Sdesint sys_auth_allowed_user(struct passwd *, Buffer *); 91137015Sdes# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 92146998Sdesint sys_auth_record_login(const char *, const char *, const char *, Buffer *); 93197679Sdes# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG 94197679Sdeschar *sys_auth_get_lastlogin_msg(const char *, uid_t); 95124208Sdes# define CUSTOM_FAILED_LOGIN 1 96204917Sdes# if defined(S_AUTHDOMAIN) && defined (S_AUTHNAME) 97204917Sdes# define USE_AIX_KRB_NAME 98204917Sdeschar *aix_krb5_get_principal_name(char *); 99204917Sdes# endif 100124208Sdes#endif 101124208Sdes 102126274Sdesvoid aix_setauthdb(const char *); 103126274Sdesvoid aix_restoreauthdb(void); 104124208Sdesvoid aix_remove_embedded_newlines(char *); 105146998Sdes 106146998Sdes#if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_GETADDRINFO) 107146998Sdes# ifdef getnameinfo 108146998Sdes# undef getnameinfo 109146998Sdes# endif 110146998Sdesint sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t, 111146998Sdes char *, size_t, int); 112146998Sdes# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g)) 113146998Sdes#endif 114146998Sdes 115181111Sdes/* 116181111Sdes * We use getgrset in preference to multiple getgrent calls for efficiency 117181111Sdes * plus it supports NIS and LDAP groups. 118181111Sdes */ 119181111Sdes#if !defined(HAVE_GETGROUPLIST) && defined(HAVE_GETGRSET) 120181111Sdes# define HAVE_GETGROUPLIST 121181111Sdes# define USE_GETGRSET 122181111Sdesint getgrouplist(const char *, gid_t, gid_t *, int *); 123181111Sdes#endif 124181111Sdes 12598937Sdes#endif /* _AIX */ 126