Preliminary merge of winbind into HEAD. Note that this compiles and links
[ira/wip.git] / source3 / nsswitch / winbindd.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 2.0
4
5    Winbind daemon for ntdom nss module
6
7    Copyright (C) Tim Potter 2000
8    
9    This library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Library General Public
11    License as published by the Free Software Foundation; either
12    version 2 of the License, or (at your option) any later version.
13    
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Library General Public License for more details.
18    
19    You should have received a copy of the GNU Library General Public
20    License along with this library; if not, write to the
21    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA  02111-1307, USA.   
23 */
24
25 #ifndef _WINBINDD_H
26 #define _WINBINDD_H
27
28 #include "includes.h"
29 #include "nterr.h"
30
31 #include "winbindd_nss.h"
32
33 /* Naughty global stuff */
34
35 extern int DEBUGLEVEL;
36
37 /* Client state structure */
38
39 struct winbindd_cli_state {
40     struct winbindd_cli_state *prev, *next;   /* Linked list pointers */
41     int sock;                                 /* Open socket from client */
42     pid_t pid;                                /* pid of client */
43     int read_buf_len, write_buf_len;          /* Indexes in request/response */
44     BOOL finished;                            /* Can delete from list */
45     BOOL write_extra_data;                    /* Write extra_data field */
46     struct winbindd_request request;          /* Request from client */
47     struct winbindd_response response;        /* Respose to client */
48     struct getent_state *getpwent_state;      /* State for getpwent() */
49     struct getent_state *getgrent_state;      /* State for getgrent() */
50 };
51
52 /* State between get{pw,gr}ent() calls */
53
54 struct getent_state {
55         struct getent_state *prev, *next;
56         void *sam_entries;
57         uint32 sam_entry_index, num_sam_entries;
58         uint32 dispinfo_ndx;
59         BOOL got_all_sam_entries, got_sam_entries;
60         struct winbindd_domain *domain;
61 };
62
63 /* Storage for cached getpwent() user entries */
64
65 struct getpwent_user {
66         fstring name;                        /* Account name */
67         fstring gecos;                       /* User information */
68         uint32 user_rid, group_rid;          /* NT user and group rids */
69 };
70
71 /* Server state structure */
72
73 struct winbindd_state {
74         /* Netbios name of PDC */
75         fstring controller;
76         
77         /* User and group id pool */
78         uid_t uid_low, uid_high;               /* Range of uids to allocate */
79         gid_t gid_low, gid_high;               /* Range of gids to allocate */
80         
81         /* Cached handle to lsa pipe */
82         CLI_POLICY_HND lsa_handle;
83         BOOL lsa_handle_open;
84         BOOL pwdb_initialised;
85 };
86
87 extern struct winbindd_state server_state;  /* Server information */
88
89 /* Structures to hold per domain information */
90
91 struct winbindd_domain {
92
93         /* Domain information */
94
95         fstring name;                          /* Domain name */
96         fstring controller;                    /* NetBIOS name of DC */
97         
98         DOM_SID sid;                           /* SID for this domain */
99         BOOL got_domain_info;                  /* Got controller and sid */
100         
101         /* Cached handles to samr pipe */
102         
103         CLI_POLICY_HND sam_handle, sam_dom_handle;
104         BOOL sam_handle_open, sam_dom_handle_open;
105         time_t last_check;
106         
107         struct winbindd_domain *prev, *next;   /* Linked list info */
108 };
109
110 extern struct winbindd_domain *domain_list;  /* List of domains we know */
111
112 #include "winbindd_proto.h"
113
114 #include "rpc_parse.h"
115 #include "rpc_client.h"
116
117 #define WINBINDD_ESTABLISH_LOOP 30
118 #define DOM_SEQUENCE_NONE ((uint32)-1)
119
120 /* SETENV */
121 #if HAVE_SETENV
122 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
123 #elif HAVE_PUTENV
124 #define SETENV(name, value, overwrite)                                   \
125 {                                                                        \
126         fstring envvar;                                                  \
127         slprintf(envvar, sizeof(fstring), "%s=%s", name, value);         \
128         putenv(envvar);                                                  \
129 }
130 #else
131 #define SETENV(name, value, overwrite) ;
132 #endif
133
134 #endif /* _WINBINDD_H */