File: proftpd.h

package info (click to toggle)
proftpd-dfsg 1.3.0-19etch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 9,604 kB
  • ctags: 5,598
  • sloc: ansic: 59,475; sh: 18,832; perl: 1,474; makefile: 1,191
file content (258 lines) | stat: -rw-r--r-- 8,157 bytes parent folder | download | duplicates (2)
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
 * ProFTPD - FTP server daemon
 * Copyright (c) 1997, 1998 Public Flood Software
 * Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
 * Copyright (c) 2001, 2002, 2003, 2004 The ProFTPD Project team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
 *
 * As a special exemption, Public Flood Software/MacGyver aka Habeeb J. Dihu
 * and other respective copyright holders give permission to link this program
 * with OpenSSL, and distribute the resulting executable, without including
 * the source code for OpenSSL in the source distribution.
 */

/* General options
 * $Id: proftpd.h,v 1.53 2005/02/26 17:28:58 castaglia Exp $
 */

#ifndef PR_PROFTPD_H
#define PR_PROFTPD_H

#include "class.h"

#ifndef TRUE
# define TRUE				1
#endif

#ifndef FALSE
# define FALSE				0
#endif

/* Definition of root user/group IDs (non-Unix platforms may have these as
 * different from 0/0).
 */
#ifdef __CYGWIN__
# define PR_ROOT_UID    18
# define PR_ROOT_GID    544
#else
# define PR_ROOT_UID    0
# define PR_ROOT_GID    0
#endif /* __CYGWIN__ */

#define CALLBACK_FRAME	\
  unsigned long p1, unsigned long p2, unsigned long p3, void *data

#define ASSERT(x)			assert(x)
#include <assert.h>

typedef int (*callback_t)(CALLBACK_FRAME);

struct conn_struc;
struct cmd_struc;
struct config_struc;

typedef struct {
  pool *pool;

  volatile int sf_flags;		/* Session/State flags */
  volatile int sp_flags;		/* Session/Protection flags */

  pr_netaddr_t data_addr;		/* Remote data address */
  unsigned short data_port;		/* Remote data port */

  unsigned char ident_lookups;		/* Is RFC931 (ident) protocol used? */
  char *ident_user;			/* User identified by ident protocol */

  const char *auth_mech;		/* Name of the authentication
                                         * module/mechanism that successfully
                                         * authenticated the client
					 */

  const char *rfc2228_mech;		/* RFC2228 authentication mechanism
					 * used
					 */

  char cwd[PR_TUNABLE_PATH_MAX];	/* Current working directory */
  char vwd[PR_TUNABLE_PATH_MAX];	/* Current virtual working directory */

  struct config_struc *dir_config;	/* Closest matching configuration
                                         * for current operation
                                         */

  /* The uid/gids are manipulated by the PRIVS macros in
   * privs.h
   */

  int disable_id_switching;		/* Disable UID/GID switching */
  uid_t uid, ouid;                      /* Current and original UIDs */
  gid_t gid;                            /* Current GID */

  array_header *gids;
  array_header *groups;

  /* fsuid/fsgid are used for automagic chown after creation or upload.
   * They are initially -1, meaning no chown/chgrp.
   */
  uid_t fsuid;				/* Saved file UID */
  gid_t fsgid;				/* Saved file GID */

  char *user,*group;			/* Username/groupname after login */
  uid_t login_uid;                      /* UID after login, but before
                                         * session.uid is changed
                                         */
  gid_t login_gid;                      /* GID after login, but before
                                         * session.gid is changed
                                         */

  pr_table_t *notes;			/* Session notes table */

  pr_class_t *class;			/* Session class */
  char *proc_prefix;			/* The "prefix" of our process name */

  int wtmp_log;				/* Are we logging to wtmp? */
  struct conn_struc *c;			/* Control connection */
  struct conn_struc *d;			/* Data connection */

  int hide_password;			/* Hide password in logs/ps listing */

  char *chroot_path;			/* Chroot directory */

  struct config_struc *anon_config;	/* Anonymous FTP configuration */
  char *anon_user;			/* E-mail address sent to us */

  char *curr_cmd;                       /* Current FTP command */
  int curr_phase;                       /* Current handler phase */

  off_t restart_pos;			/* Restart marked position */

  struct {
    struct pool *p;

    int xfer_type;     /* xfer session attributes, default/append/hidden */
    int direction;
    char *filename;			/* As shown to user */
    char *path;				/* As used in transfer */
    char *path_hidden;			/* As used in hidden stor */

    unsigned int bufsize,buflen;

    struct timeval start_time;		/* Time current transfer started */
    off_t file_size;			/* Total size of file (if known) */
    off_t total_bytes;			/* Total bytes transfered */

    char *bufstart,*buf;
  } xfer;

  /* Total number of bytes uploaded in this session. */
  off_t total_bytes_in;

  /* Total number of bytes downloaded in this session. */
  off_t total_bytes_out;

  /* Total number of bytes transfered in this session. */
  off_t total_bytes;

  /* Total number of files uploaded in this session. */
  unsigned int total_files_in;

  /* Total number of files downloaded in this session. */
  unsigned int total_files_out;

  /* Total number of files transfered (both uploaded and downloaded) in
   * this session.
   */
  unsigned int total_files_xfer;

} session_t;

/* Daemon identity values, defined in main.c */
extern uid_t daemon_uid;
extern gid_t daemon_gid;
extern array_header *daemon_gids;

/* Possible values for xfer.xfer_type, mutually exclusive */
#define STOR_DEFAULT	0
#define STOR_APPEND	1
#define STOR_HIDDEN	2
#define STOR_UNIQUE	3

extern session_t	session;
extern char AddressCollisionCheck;
extern char ServerType;
extern char MultilineRFC2228;
extern const char	*pwdfname,*grpfname;

/* Session/State flags */

#define SF_PASSIVE		0x0001	/* Data connection is in passive mode */
#define SF_ABORT		0x0002	/* Abort in progess */
#define SF_XFER			0x0004	/* Transfer in progress */
#define SF_ASCII		0x0010	/* ASCII mode transfer */
#define SF_ASCII_OVERRIDE 	0x0020	/* ASCII override this xfer only */
#define SF_ANON			0x0040	/* Anonymous (chroot) login */
#define SF_POST_ABORT		0x0100	/* After abort has occured */
#define SF_PORT			0x0200	/* Port command given */
#define	SF_EPSV_ALL		0x0400	/* EPSV ALL in effect */

#define SF_ALL		(SF_PASSIVE|SF_ABORT|SF_XFER|SF_ASCII| \
                        SF_ASCII_OVERRIDE|SF_ANON|SF_POST_ABORT|SF_PORT| \
                        SF_EPSV_ALL)

/* Session/Protection flags (RFC 2228) */

#define SP_CCC		(1 << 0)	/* Clear command channel */
#define SP_ENC		(1 << 1)	/* Privacy protected command */
#define SP_MIC		(1 << 2)	/* Integrity protected command */
#define SP_CONF		(1 << 3)	/* Confidentiality protected command */

/* Macro to test global abort flag */
#define XFER_ABORTED	(session.sf_flags & SF_ABORT)

/* Server Types */
#define SERVER_INETD		0
#define SERVER_STANDALONE	1

/* Signals */
#define RECEIVED_SIG_REHASH	0x0001
#define RECEIVED_SIG_EXIT	0x0002
#define RECEIVED_SIG_SHUTDOWN	0x0004
#define RECEIVED_SIG_SEGV	0x0008
#define RECEIVED_SIG_TERMINATE	0x0010
#define RECEIVED_SIG_XCPU	0x0020
#define RECEIVED_SIG_TERM_OTHER	0x0040
#define RECEIVED_SIG_ABORT	0x0080
#define RECEIVED_SIG_EVENT	0x0100
#define RECEIVED_SIG_CHLD	0x0200
#define RECEIVED_SIG_ALRM	0x0400

/* Timers */
#define TIMER_LOGIN		1
#define TIMER_IDLE		2
#define TIMER_NOXFER		3
#define TIMER_STALLED		4
#define TIMER_SESSION		5

/* Misc Prototypes */

void end_login(int);
void pr_signals_handle(void);
void session_exit(int, void *, int, void *);
void session_set_idle(void);
void pr_rehash_register_handler(void *, void(*)(void *));
void set_daemon_rlimits(void);
void set_session_rlimits(void);

#endif /* PR_PROFTPD_H */