-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.h
235 lines (194 loc) · 5.52 KB
/
conf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/** conf.h
**
** Fichier de configuration pour calife.c
**
** cree pour simplifier calife.c
**
** Copyright (c) 1991-2010 par O. ROBERT
**
** @(#) $Id: conf.h,v b0fe97d87286 2014/03/20 11:17:33 roberto $
**/
#ifndef CONF_H /* evite les includes multiples */
#define CONF_H
#define ROOT_LOGIN "root"
#ifdef SUNOS4
#define _PATH_UTMP "/etc/utmp" /* sigh */
#endif
/* for Gould NP1 */
#ifdef GOULD
#define BSD
#endif
#if (defined(BSD) && (BSD >= 199306)) /* for both NetBSD & FreeBSD */
#define ADMIN_LOG "/var/log/calife"
#define HAVE_SYSCONF
#endif /* __386BSD__ */
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
#if defined(HAVE_SYS_WAIT_H) || defined(HAVE_NON_POSIX_WAIT_H)
#include <sys/wait.h>
#endif /* HAVE_SYS_WAIT_H && HAVE_NON_POSIX_WAIT_H */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif /* HAVE_SYSLOG_H */
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
#include <signal.h>
#include <stdio.h>
#include <time.h>
#include <pwd.h>
#include <grp.h>
#if defined (SUNOS4) || defined (__linux__)
# include <sys/time.h>
# include <utmp.h>
#endif /* SunOS && __linux__ */
#ifdef HAVE_SHADOW_H
#include <shadow.h>
#endif /* HAVE_SHADOW_H */
#include <errno.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#ifdef NEED_STRINGS_H
#include <strings.h>
#endif /* NEED_STRINGS_H */
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
#ifdef HAVE_RLIMIT
#include <sys/resource.h>
#endif /* HAVE_RLIMIT */
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
#endif /* HAVE_LIBGEN_H */
/* A verifier */
#ifdef BSD
#if !defined(__FreeBSD__) && !defined(HAVE_SYS_WAIT_H)
#define WEXITSTATUS(x) ((x).w_retcode)
#define WCOREDUMP(x) ((x).w_coredump)
#define WTERMSIG(x) ((x).w_termsig)
#endif
#endif
/*
* Number of attempts the code will try to verify the password
*/
#define MAX_ATTEMPTS 3
#ifdef WITH_PAM
/*
* the following code is stolen from imap-uw PAM authentication module and
* login.c
*/
#define COPY_STRING(s) (s ? strdup(s) : NULL)
struct cred_t {
const char *uname; /* user name */
const char *pass; /* password */
};
typedef struct cred_t cred_t;
#ifdef HAVE_PAM_PAM_APPL_H
#include <pam/pam_appl.h>
#else
#include <security/pam_appl.h>
#endif
#endif /* WITH_PAM */
/*
* Try to simplify the code
*/
#include <assert.h>
#ifdef HPUX
# define GET_ROOT { \
int e = setresuid(-1,ssid,-1); \
assert(e == 0); \
}
#else
# define GET_ROOT { \
int e = seteuid(ssid); \
assert(e == 0); \
}
#endif /* HPUX */
#ifdef HPUX
# define RELEASE_ROOT { \
int e = setresuid(-1,getuid (),-1);
assert(e == 0); \
}
#else
# define RELEASE_ROOT { \
int e = seteuid(getuid ()); \
assert(e == 0); \
}
#endif /* HPUX */
/* compiler-related keywords */
#include "compiler.h"
#define MAX_STRING 1024 /* "safe" value */
#ifndef MAXLOGNAME
#define MAXLOGNAME 16
#endif
#define ACCEPT_ALPHAL "abcdefghijklmnopqrstuvwxyz"
#define ACCEPT_ALPHAU "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define ACCEPT_NUM "0123456789"
#define ACCEPT_PUNCT "-_"
#define ACCEPT_CHARS ACCEPT_ALPHAL \
ACCEPT_ALPHAU \
ACCEPT_NUM \
ACCEPT_PUNCT
#define AUTH_OK 0
#define AUTH_NULL 1
#define AUTH_ERR 2
#define AUTH_BADP 3
int open_databases (void);
void authenticate_user (char *, char *, char *, char *);
int verify_auth_info (char *, char *);
void exec_shell (char *);
# ifndef HAVE_BASENAME
char * basename (char * file_name);
# endif /* HAVE_BASENAME */
void * xalloc (size_t size);
_Noreturn void die (int err, const char * fmt,...) _NORETURN;
char * whoami(void);
#ifdef WITH_PAM
int auth_pam(struct passwd **ppw, const char *pass);
#endif
#ifndef MAIN_MODULE
extern int custom_shell; /* modification du shell ? */
extern char * shell; /* nom du shell */
extern uid_t ssid; /* POSIX saved uid */
extern char * _group; /* Si user E group */
#ifdef WITH_PAM
extern pam_handle_t *pamh;
#endif /* WITH_PAM */
#endif /* !MAIN_MODULE */
extern int errno;
#ifdef DEBUG
#define MESSAGE(x) fprintf (stderr, (x)); \
fflush (stderr)
#define MESSAGE_1(x,y) fprintf (stderr, (x), (y)); \
fflush (stderr)
#define MESSAGE_2(x,y,z) fprintf (stderr, (x), (y), (z)); \
fflush (stderr)
#define MESSAGE_3(x,y,z,t) fprintf (stderr, (x), (y), (z), (t)); \
fflush (stderr)
#define MESSAGE_4(x,y,z,t,u) fprintf (stderr, (x), (y), (z), (t), (u)); \
fflush (stderr)
#define MESSAGE_5(x,y,z,t,u,v) fprintf (stderr, (x), (y), (z), (t), \
(u), (v)); \
fflush (stderr)
#else
#define MESSAGE(x)
#define MESSAGE_1(x,y)
#define MESSAGE_2(x,y,z)
#define MESSAGE_3(x,y,z,t)
#define MESSAGE_4(x,y,z,t,u)
#define MESSAGE_5(x,y,z,t,u,v)
#endif /* DEBUG */
#ifdef NO_SYSLOG
#define ADMIN_LOG "/var/log/calife.log"
#endif /* NO_SYSLOG */
#endif /* CONF_H */