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
|
/*
nslcd.h - file describing client/server protocol
Copyright (C) 2006 West Consulting
Copyright (C) 2006 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#ifndef _NSLCD_H
#define _NSLCD_H 1
/*
The protocol used between the nslcd client and server
is a simple binary protocol. It is request/response based
where the client initiates a connection, does a single request
and closes the connection again. Any mangled messages will be
silently ignored by the server.
A request looks like:
int32 NSLCD_VERSION
int32 NSLCD_RT_*
[request parameters if any]
A response looks like:
int32 NSLCD_VERSION
int32 NSLCD_RT_* (the original request type)
int32 NSLCD_RS_* (response code)
[result value(s)]
If a response would return multiple values (e.g. for the
NSLCD_RT_GETPWDALL function) each return value will be preceded
by a NSLCD_RS_* value.
These are the available data types:
INT32 - 32-bit integer value
TYPE - a typed field that is transferred using sizeof()
STRING - a string length (32bit) followed by the string value
(not null-terminted)
LOOP - a 32-bit number noting the number of entries followed
by the entries one at a time
Compound datatypes (such as PASSWD) are defined below as a
combination of the above types. They are defined as macros so
they can be expanded to code later on.
The protocol is described in this generic fashion (instead of just
transferring the allocated memory) because pointers will not
be valid between transfers and this also makes the server
independant of the NSS implementation.
*/
/* used for transferring struct alias information */
#define LDF_ALIAS \
LDF_STRING(ALIAS_NAME) \
LDF_LOOP( \
LDF_STRING(ALIAS_RCPT) \
)
/* AUTOMOUNT - TBD */
/* used for transferring mac addresses */
#define LDF_ETHER \
LDF_TYPE(ETHER_ADDR,u_int8_t[6])
/* a group entry from /etc/group (struct group) */
#define LDF_GROUP \
LDF_STRING(GROUP_NAME) \
LDF_STRING(GROUP_PASSWD) \
LDF_TYPE(GROUP_GIF,gid_t) \
LDF_LOOP( \
LDF_STRING(GROUP_MEMBER) \
)
/* HOSTS - TBD - gethostbyname - struct hostent - gethostbyaddr - struct in_addr */
/* NETGROUP - TBD */
/* NETWORKS - TBD - struct netent */
/* used for transferring struct passwd information */
#define LDF_PASSWD \
LDF_STRING(PASSWD_NAME) \
LDF_STRING(PASSWD_PASSWD) \
LDF_TYPE(PASSWD_UID,uid_t) \
LDF_TYPE(PASSWD_GID,gid_t) \
LDF_STRING(PASSWD_GECOS) \
LDF_STRING(PASSWD_DIR) \
LDF_STRING(PASSWD_SHELL)
/* PROTOCOLS - TBD - getprotobyname - struct protoent */
/* for transferring struct rpcent structs */
#define LDF_RPC \
LDF_STRING(RPC_NAME) \
LDF_LOOP( \
LDF_STRING(RPC_ALIAS) \
) \
LDF_TYPE(RPC_NUMBER,int32_t)
/* SERVICES - TBD - getservbyname - struct servent */
/* SHADOW - TBD - getspnam - struct spwd */
/* The location of the socket used for communicating. */
#define NSLCD_SOCKET "/tmp/nslcd.socket"
/* The location of the pidfile used for checking availability of the nslcd. */
#define NSLCD_PIDFILE "/tmp/nslcd.pid"
/* The current version of the protocol. */
#define NSLCD_VERSION 1
/* Request types. */
#define NSLCD_RT_ALIAS_BYNAME 4001
#define NSLCD_RT_GETPWBYNAME 1001
#define NSLCD_RT_GETPWBYUID 1002
#define NSLCD_RT_GETPWALL 1004
#define NSLCD_RT_GETGRBYNAME 2003
#define NSLCD_RT_GETGRBYGID 2004
#define NSLCD_RT_GETHOSTBYNAME 3005
#define NSLCD_RT_GETHOSTBYADDR 3008
/* Response data types */
#define NSLCD_DT_BUF 1000 /* any data, blob */
#define NSLCD_DT_HEADER 2001 /* initial response header */
#define NSLCD_DT_PASSWD 3001 /* struct passwd */
/* Request result. */
#define NSLCD_RS_UNAVAIL 2 /* sevice unavailable */
#define NSLCD_RS_NOTFOUND 3 /* key was not found */
#define NSLCD_RS_SUCCESS 0 /* everything ok */
#endif /* not _NSLCD_H */
|