]> arthur.barton.de Git - netatalk.git/blob - include/atalk/globals.h
Proper check whether code runs in an AFP session context or not
[netatalk.git] / include / atalk / globals.h
1 /*
2  * Copyright (c) 1990,1993 Regents of The University of Michigan.
3  * All Rights Reserved.  See COPYRIGHT.
4  */
5
6 #ifndef AFPD_GLOBALS_H
7 #define AFPD_GLOBALS_H 1
8
9 #include <sys/param.h>
10
11 #ifdef ADMIN_GRP
12 #include <grp.h>
13 #include <sys/types.h>
14 #endif /* ADMIN_GRP */
15
16 #ifdef HAVE_NETDB_H
17 #include <netdb.h>  /* this isn't header-protected under ultrix */
18 #endif /* HAVE_NETDB_H */
19
20 #include <atalk/afp.h>
21 #include <atalk/compat.h>
22 #include <atalk/unicode.h>
23 #include <atalk/uam.h>
24 #include <atalk/iniparser.h>
25
26 /* #define DOSFILELEN 12 */             /* Type1, DOS-compat*/
27 #define MACFILELEN 31                   /* Type2, HFS-compat */
28 #define UTF8FILELEN_EARLY 255           /* Type3, early Mac OS X 10.0-10.4.? */
29 /* #define UTF8FILELEN_NAME_MAX 765 */  /* Type3, 10.4.?- , getconf NAME_MAX */
30 /* #define UTF8FILELEN_SPEC 0xFFFF */   /* Type3, spec on document */
31 /* #define HFSPLUSFILELEN 510 */        /* HFS+ spec, 510byte = 255codepoint */
32
33 #define MAXUSERLEN 256
34
35 #define DEFAULT_MAX_DIRCACHE_SIZE 8192
36
37 #define OPTION_DEBUG         (1 << 0)
38 #define OPTION_CLOSEVOL      (1 << 1)
39 #define OPTION_SERVERNOTIF   (1 << 2)
40 #define OPTION_NOSENDFILE    (1 << 3)
41 #define OPTION_CUSTOMICON    (1 << 4)
42 #define OPTION_ANNOUNCESSH   (1 << 6)
43 #define OPTION_UUID          (1 << 7)
44 #define OPTION_ACL2MACCESS   (1 << 8)
45 #define OPTION_NOZEROCONF    (1 << 9)
46 #define OPTION_KEEPSESSIONS  (1 << 10) /* preserve sessions across master afpd restart with SIGQUIT */
47
48 #define PASSWD_NONE     0
49 #define PASSWD_SET     (1 << 0)
50 #define PASSWD_NOSAVE  (1 << 1)
51 #define PASSWD_ALL     (PASSWD_SET | PASSWD_NOSAVE)
52
53 #define IS_AFP_SESSION(obj) ((obj)->dsi && (obj)->dsi->serversock == -1)
54
55 /**********************************************************************************************
56  * Ini config sections
57  **********************************************************************************************/
58
59 #define INISEC_GLOBAL "Global"
60 #define INISEC_HOMES  "Homes"
61
62 struct DSI;
63 #define AFPOBJ_TMPSIZ (MAXPATHLEN)
64
65 struct afp_volume_name {
66     time_t     mtime;
67     int        loaded;
68 };
69
70 struct afp_options {
71     int connections;            /* Maximum number of possible AFP connections */
72     int tickleval;
73     int timeout;
74     int flags;
75     int dircachesize;
76     int sleep;                  /* Maximum time allowed to sleep (in tickles) */
77     int disconnected;           /* Maximum time in disconnected state (in tickles) */
78     int fce_fmodwait;           /* number of seconds FCE file mod events are put on hold */
79     unsigned int tcp_sndbuf, tcp_rcvbuf;
80     unsigned char passwdbits, passwdminlen;
81     uint32_t server_quantum;
82     int dsireadbuf; /* scale factor for sizefof(dsi->buffer) = server_quantum * dsireadbuf */
83     char *hostname;
84     char *listen, *port;
85     char *Cnid_srv, *Cnid_port;
86     char *configfile;
87     char *uampath, *fqdn;
88     char *sigconffile;
89     char *uuidconf;
90     char *guest, *loginmesg, *keyfile, *passwdfile;
91     char *uamlist;
92     char *signatureopt;
93     unsigned char signature[16];
94     char *k5service, *k5realm, *k5keytab;
95     char *unixcodepage, *maccodepage, *volcodepage;
96     charset_t maccharset, unixcharset; 
97     mode_t umask;
98     mode_t save_mask;
99 #ifdef ADMIN_GRP
100     gid_t admingid;
101 #endif /* ADMIN_GRP */
102     int    volnamelen;
103     /* default value for winbind authentication */
104     char *ntdomain, *ntseparator;
105     char *logconfig;
106     char *logfile;
107     char *mimicmodel;
108     char *adminauthuser;
109     struct afp_volume_name volfile;
110 };
111
112 typedef struct AFPObj {
113     const char *cmdlineconfigfile;
114     int cmdlineflags;
115     const void *signature;
116     struct DSI *dsi;
117     struct afp_options options;
118     dictionary *iniconfig;
119     char username[MAXUSERLEN];
120     /* to prevent confusion, only use these in afp_* calls */
121     char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
122     void *uam_cookie; /* cookie for uams */
123     struct session_info  sinfo;
124     uid_t uid;  /* client running user id */
125     int ipc_fd; /* anonymous PF_UNIX socket for IPC with afpd parent */
126     gid_t *groups;
127     int ngroups;
128     int afp_version;
129     /* Functions */
130     void (*logout)(void);
131     void (*exit)(int);
132     int (*reply)(void *, int);
133     int (*attention)(void *, AFPUserBytes);
134 } AFPObj;
135
136 /* typedef for AFP functions handlers */
137 typedef int (*AFPCmd)(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
138
139 /* Global variables */
140 extern AFPObj             *AFPobj;
141 extern int                afp_version;
142 extern int                afp_errno;
143 extern unsigned char      nologin;
144 extern struct dir         *curdir;
145 extern char               getwdbuf[];
146 extern struct afp_options default_options;
147 extern const char         *Cnid_srv;
148 extern const char         *Cnid_port;
149
150 extern int  get_afp_errno   (const int param);
151 extern void afp_options_init (struct afp_options *);
152 extern void afp_options_parse_cmdline(AFPObj *obj, int ac, char **av);
153 extern void afp_options_free(struct afp_options *);
154 extern void setmessage (const char *);
155 extern void readmessage (AFPObj *);
156
157 /* gettok.c */
158 extern void initline   (int, char *);
159 extern int  parseline  (int, char *);
160
161 /* afp_util.c */
162 extern const char *AfpNum2name (int );
163 extern const char *AfpErr2name(int err);
164
165 /* directory.c */
166 extern struct dir rootParent;
167
168 extern void afp_over_dsi (AFPObj *);
169
170 #endif /* globals.h */