1204917Sdes/* $Id: port-aix.h,v 1.32 2009/12/20 23:49:22 dtucker Exp $ */
2124208Sdes
3106121Sdes/*
4106121Sdes *
5106121Sdes * Copyright (c) 2001 Gert Doering.  All rights reserved.
6181111Sdes * Copyright (c) 2004,2005,2006 Darren Tucker.  All rights reserved.
7106121Sdes *
8106121Sdes * Redistribution and use in source and binary forms, with or without
9106121Sdes * modification, are permitted provided that the following conditions
10106121Sdes * are met:
11106121Sdes * 1. Redistributions of source code must retain the above copyright
12106121Sdes *    notice, this list of conditions and the following disclaimer.
13106121Sdes * 2. Redistributions in binary form must reproduce the above copyright
14106121Sdes *    notice, this list of conditions and the following disclaimer in the
15106121Sdes *    documentation and/or other materials provided with the distribution.
16106121Sdes *
17106121Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18106121Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19106121Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20106121Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21106121Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22106121Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23106121Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24106121Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25106121Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26106121Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27106121Sdes */
28106121Sdes
2998937Sdes#ifdef _AIX
30113908Sdes
31146998Sdes#ifdef HAVE_SYS_SOCKET_H
32146998Sdes# include <sys/socket.h>
33146998Sdes#endif
34146998Sdes
35146998Sdes#include "buffer.h"
36146998Sdes
37146998Sdes/* These should be in the system headers but are not. */
38146998Sdesint usrinfo(int, char *, int);
39149749Sdes#if defined(HAVE_DECL_SETAUTHDB) && (HAVE_DECL_SETAUTHDB == 0)
40146998Sdesint setauthdb(const char *, char *);
41147001Sdes#endif
42146998Sdes/* these may or may not be in the headers depending on the version */
43149749Sdes#if defined(HAVE_DECL_AUTHENTICATE) && (HAVE_DECL_AUTHENTICATE == 0)
44146998Sdesint authenticate(char *, char *, int *, char **);
45146998Sdes#endif
46149749Sdes#if defined(HAVE_DECL_LOGINFAILED) && (HAVE_DECL_LOGINFAILED == 0)
47146998Sdesint loginfailed(char *, char *, char *);
48146998Sdes#endif
49149749Sdes#if defined(HAVE_DECL_LOGINRESTRICTIONS) && (HAVE_DECL_LOGINRESTRICTIONS == 0)
50146998Sdesint loginrestrictions(char *, int, char *, char **);
51146998Sdes#endif
52149749Sdes#if defined(HAVE_DECL_LOGINSUCCESS) && (HAVE_DECL_LOGINSUCCESS == 0)
53146998Sdesint loginsuccess(char *, char *, char *, char **);
54146998Sdes#endif
55149749Sdes#if defined(HAVE_DECL_PASSWDEXPIRED) && (HAVE_DECL_PASSWDEXPIRED == 0)
56146998Sdesint passwdexpired(char *, char **);
57146998Sdes#endif
58146998Sdes
59124208Sdes/* Some versions define r_type in the above headers, which causes a conflict */
60124208Sdes#ifdef r_type
61124208Sdes# undef r_type
62124208Sdes#endif
63124208Sdes
64113908Sdes/* AIX 4.2.x doesn't have nanosleep but does have nsleep which is equivalent */
65113908Sdes#if !defined(HAVE_NANOSLEEP) && defined(HAVE_NSLEEP)
66113908Sdes# define nanosleep(a,b) nsleep(a,b)
67113908Sdes#endif
68113908Sdes
69113908Sdes/* For struct timespec on AIX 4.2.x */
70113908Sdes#ifdef HAVE_SYS_TIMERS_H
71113908Sdes# include <sys/timers.h>
72113908Sdes#endif
73113908Sdes
74197679Sdes/* for setpcred and friends */
75197679Sdes#ifdef HAVE_USERSEC_H
76197679Sdes# include <usersec.h>
77197679Sdes#endif
78197679Sdes
79126274Sdes/*
80126274Sdes * According to the setauthdb man page, AIX password registries must be 15
81126274Sdes * chars or less plus terminating NUL.
82126274Sdes */
83126274Sdes#ifdef HAVE_SETAUTHDB
84126274Sdes# define REGISTRY_SIZE	16
85126274Sdes#endif
86126274Sdes
87126274Sdesvoid aix_usrinfo(struct passwd *);
88126274Sdes
89124208Sdes#ifdef WITH_AIXAUTHENTICATE
90126274Sdes# define CUSTOM_SYS_AUTH_PASSWD 1
91137015Sdes# define CUSTOM_SYS_AUTH_ALLOWED_USER 1
92146998Sdesint sys_auth_allowed_user(struct passwd *, Buffer *);
93137015Sdes# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1
94146998Sdesint sys_auth_record_login(const char *, const char *, const char *, Buffer *);
95197679Sdes# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG
96197679Sdeschar *sys_auth_get_lastlogin_msg(const char *, uid_t);
97124208Sdes# define CUSTOM_FAILED_LOGIN 1
98204917Sdes# if defined(S_AUTHDOMAIN)  && defined (S_AUTHNAME)
99204917Sdes# define USE_AIX_KRB_NAME
100204917Sdeschar *aix_krb5_get_principal_name(char *);
101204917Sdes# endif
102124208Sdes#endif
103124208Sdes
104126274Sdesvoid aix_setauthdb(const char *);
105126274Sdesvoid aix_restoreauthdb(void);
106124208Sdesvoid aix_remove_embedded_newlines(char *);
107146998Sdes
108146998Sdes#if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_GETADDRINFO)
109146998Sdes# ifdef getnameinfo
110146998Sdes#  undef getnameinfo
111146998Sdes# endif
112146998Sdesint sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t,
113146998Sdes    char *, size_t, int);
114146998Sdes# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g))
115146998Sdes#endif
116146998Sdes
117181111Sdes/*
118181111Sdes * We use getgrset in preference to multiple getgrent calls for efficiency
119181111Sdes * plus it supports NIS and LDAP groups.
120181111Sdes */
121181111Sdes#if !defined(HAVE_GETGROUPLIST) && defined(HAVE_GETGRSET)
122181111Sdes# define HAVE_GETGROUPLIST
123181111Sdes# define USE_GETGRSET
124181111Sdesint getgrouplist(const char *, gid_t, gid_t *, int *);
125181111Sdes#endif
126181111Sdes
12798937Sdes#endif /* _AIX */
128