diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-02 14:13:21 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-02 14:13:21 +0000 |
commit | eee4fc27f887ed7c66e0b85e5b8b592eb28e134d (patch) | |
tree | 09c73592b74a6db144dae16c386da5cf5e921535 | |
parent | fbafd084e0829b25ec2a876123f17d2510552d7e (diff) |
rename some constants and switch to a more sane naming scheme
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@56 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | nslcd-client.h | 2 | ||||
-rw-r--r-- | nslcd-server.c | 8 | ||||
-rw-r--r-- | nslcd-server.h | 8 | ||||
-rw-r--r-- | nslcd.h | 72 | ||||
-rw-r--r-- | nss/aliases.c | 4 | ||||
-rw-r--r-- | nss/common.c | 6 | ||||
-rw-r--r-- | nss/passwd.c | 12 | ||||
-rw-r--r-- | server/aliases.c | 10 | ||||
-rw-r--r-- | server/common.c | 8 | ||||
-rw-r--r-- | server/passwd.c | 30 |
10 files changed, 79 insertions, 81 deletions
diff --git a/nslcd-client.h b/nslcd-client.h index 61b28d5..f67ea41 100644 --- a/nslcd-client.h +++ b/nslcd-client.h @@ -51,7 +51,7 @@ FILE *nslcd_client_open(void); #define READ_RESPONSE_CODE(fp) \ READ_TYPE(fp,tmpint32,int32_t); \ - if (tmpint32!=NSLCD_RS_SUCCESS) \ + if (tmpint32!=NSLCD_RESULT_SUCCESS) \ { ERROR_OUT_NOSUCCESS(fp,tmpint32) } #endif /* not _NSLCD_CLIENT_H */ diff --git a/nslcd-server.c b/nslcd-server.c index 25190e2..d7d64f9 100644 --- a/nslcd-server.c +++ b/nslcd-server.c @@ -148,10 +148,10 @@ void nslcd_server_handlerequest(int sock) /* handle request */ switch (tmpint32) { - case NSLCD_RT_GETPWBYNAME: nslcd_getpwnam(fp); break; - case NSLCD_RT_GETPWBYUID: nslcd_getpwuid(fp); break; - case NSLCD_RT_GETPWALL: nslcd_getpwall(fp); break; - case NSLCD_RT_ALIAS_BYNAME: nslcd_aliases_byname(fp); break; + case NSLCD_ACTION_ALIAS_BYNAME: nslcd_alias_byname(fp); break; + case NSLCD_ACTION_PASSWD_BYNAME: nslcd_passwd_byname(fp); break; + case NSLCD_ACTION_PASSWD_BYUID: nslcd_passwd_byuid(fp); break; + case NSLCD_ACTION_PASSWD_ALL: nslcd_passwd_all(fp); break; default: log_log(LOG_DEBUG,"invalid request id (%d)",(int)tmpint32); break; diff --git a/nslcd-server.h b/nslcd-server.h index bb95d17..e40032e 100644 --- a/nslcd-server.h +++ b/nslcd-server.h @@ -38,14 +38,14 @@ void nslcd_server_handlerequest(int sock); /* TODO: these definitions should probably be moved */ /* the caller should take care of opening and closing the stream */ -int nslcd_getpwnam(FILE *fp); +int nslcd_passwd_byname(FILE *fp); /* the caller should take care of opening and closing the stream */ -int nslcd_getpwuid(FILE *fp); +int nslcd_passwd_byuid(FILE *fp); /* the caller should take care of opening and closing the stream */ -int nslcd_getpwall(FILE *fp); +int nslcd_passwd_all(FILE *fp); -int nslcd_aliases_byname(FILE *fp); +int nslcd_alias_byname(FILE *fp); #endif /* not _NSLCD_SERVER_H */ @@ -24,44 +24,42 @@ #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. + 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 or not understood messages will be silently ignored by the server. A request looks like: int32 NSLCD_VERSION - int32 NSLCD_RT_* + int32 NSLCD_ACTION_* [request parameters if any] A response looks like: int32 NSLCD_VERSION - int32 NSLCD_RT_* (the original request type) + int32 NSLCD_ACTION_* (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. + If a response would return multiple values (e.g. for NSLCD_ACTION_*_ALL + functions) 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 + 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. + 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. + 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 */ +/* used for transferring alias information */ #define LDF_ALIAS \ LDF_STRING(ALIAS_NAME) \ LDF_LOOP( \ @@ -74,7 +72,7 @@ #define LDF_ETHER \ LDF_TYPE(ETHER_ADDR,u_int8_t[6]) -/* a group entry from /etc/group (struct group) */ +/* used for transferring group and membership information */ #define LDF_GROUP \ LDF_STRING(GROUP_NAME) \ LDF_STRING(GROUP_PASSWD) \ @@ -89,7 +87,7 @@ /* NETWORKS - TBD - struct netent */ -/* used for transferring struct passwd information */ +/* used for transferring user (/etc/passwd) information */ #define LDF_PASSWD \ LDF_STRING(PASSWD_NAME) \ LDF_STRING(PASSWD_PASSWD) \ @@ -123,21 +121,21 @@ #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 +#define NSLCD_ACTION_ALIAS_BYNAME 4001 +#define NSLCD_ACTION_ALIAS_ALL 4002 #define NSLCD_ACTION_GROUP_BYNAME 5001 #define NSLCD_ACTION_GROUP_BYGID 5002 -#define NSLCD_ACTION_GROUP_ALL 5003 - -/* 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 */ +#define NSLCD_ACTION_GROUP_BYMEMBER 5003 +#define NSLCD_ACTION_GROUP_ALL 5004 +#define NSLCD_ACTION_PASSWD_BYNAME 1001 +#define NSLCD_ACTION_PASSWD_BYUID 1002 +#define NSLCD_ACTION_PASSWD_ALL 1004 + +/* Request result codes. */ +#define NSLCD_RESULT_NOTFOUND 3 /* key was not found */ +#define NSLCD_RESULT_SUCCESS 0 /* everything ok */ + +/* We need this for now, get rid of it later. */ +#define NSLCD_RESULT_UNAVAIL 2 /* sevice unavailable */ #endif /* not _NSLCD_H */ diff --git a/nss/aliases.c b/nss/aliases.c index 43ae45e..add8f15 100644 --- a/nss/aliases.c +++ b/nss/aliases.c @@ -60,11 +60,11 @@ enum nss_status _nss_ldap_getaliasbyname_r( int32_t tmpint32,tmp2int32; /* open socket and write request */ OPEN_SOCK(fp); - WRITE_REQUEST(fp,NSLCD_RT_ALIAS_BYNAME); + WRITE_REQUEST(fp,NSLCD_ACTION_ALIAS_BYNAME); WRITE_STRING(fp,name); WRITE_FLUSH(fp); /* read response header */ - READ_RESPONSEHEADER(fp,NSLCD_RT_ALIAS_BYNAME); + READ_RESPONSEHEADER(fp,NSLCD_ACTION_ALIAS_BYNAME); /* read response */ READ_RESPONSE_CODE(fp); LDF_ALIAS; diff --git a/nss/common.c b/nss/common.c index c5d0433..a1fc34f 100644 --- a/nss/common.c +++ b/nss/common.c @@ -33,9 +33,9 @@ enum nss_status nslcd2nss(int code) { switch (code) { - case NSLCD_RS_UNAVAIL: return NSS_STATUS_UNAVAIL; - case NSLCD_RS_NOTFOUND: return NSS_STATUS_NOTFOUND; - case NSLCD_RS_SUCCESS: return NSS_STATUS_SUCCESS; + case NSLCD_RESULT_UNAVAIL: return NSS_STATUS_UNAVAIL; + case NSLCD_RESULT_NOTFOUND: return NSS_STATUS_NOTFOUND; + case NSLCD_RESULT_SUCCESS: return NSS_STATUS_SUCCESS; default: return NSS_STATUS_UNAVAIL; } } diff --git a/nss/passwd.c b/nss/passwd.c index b12e42c..0557bc6 100644 --- a/nss/passwd.c +++ b/nss/passwd.c @@ -48,11 +48,11 @@ enum nss_status _nss_ldap_getpwnam_r(const char *name,struct passwd *result,char int32_t tmpint32; /* open socket and write request */ OPEN_SOCK(fp); - WRITE_REQUEST(fp,NSLCD_RT_GETPWBYNAME); + WRITE_REQUEST(fp,NSLCD_ACTION_PASSWD_BYNAME); WRITE_STRING(fp,name); WRITE_FLUSH(fp); /* read response header */ - READ_RESPONSEHEADER(fp,NSLCD_RT_GETPWBYNAME); + READ_RESPONSEHEADER(fp,NSLCD_ACTION_PASSWD_BYNAME); /* read response */ READ_RESPONSE_CODE(fp); LDF_PASSWD; @@ -68,11 +68,11 @@ enum nss_status _nss_ldap_getpwuid_r(uid_t uid,struct passwd *result,char *buffe int32_t tmpint32; /* open socket and write request */ OPEN_SOCK(fp); - WRITE_REQUEST(fp,NSLCD_RT_GETPWBYUID); + WRITE_REQUEST(fp,NSLCD_ACTION_PASSWD_BYUID); WRITE_TYPE(fp,uid,uid_t); WRITE_FLUSH(fp); /* read response header */ - READ_RESPONSEHEADER(fp,NSLCD_RT_GETPWBYUID); + READ_RESPONSEHEADER(fp,NSLCD_ACTION_PASSWD_BYUID); /* read response */ READ_RESPONSE_CODE(fp); LDF_PASSWD; @@ -98,10 +98,10 @@ enum nss_status _nss_ldap_setpwent(void) _nss_ldap_endpwent(); /* open a new stream and write the request */ OPEN_SOCK(fp); - WRITE_REQUEST(fp,NSLCD_RT_GETPWALL); + WRITE_REQUEST(fp,NSLCD_ACTION_PASSWD_ALL); WRITE_FLUSH(fp); /* read response header */ - READ_RESPONSEHEADER(fp,NSLCD_RT_GETPWALL); + READ_RESPONSEHEADER(fp,NSLCD_ACTION_PASSWD_ALL); return NSS_STATUS_SUCCESS; } diff --git a/server/aliases.c b/server/aliases.c index c9d1dfb..466c6f4 100644 --- a/server/aliases.c +++ b/server/aliases.c @@ -121,7 +121,7 @@ _nss_ldap_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen, #define ALIAS_NAME result.alias_name #define ALIAS_RCPT result.alias_members[tmp2int32] -int nslcd_aliases_byname(FILE *fp) +int nslcd_alias_byname(FILE *fp) { int32_t tmpint32,tmp2int32; char *name; @@ -134,21 +134,21 @@ int nslcd_aliases_byname(FILE *fp) READ_STRING_ALLOC(fp,name); /* FIXME: free() this buffer somewhere */ /* log call */ - log_log(LOG_DEBUG,"nslcd_aliases_byname(%s)",name); + log_log(LOG_DEBUG,"nslcd_alias_byname(%s)",name); /* do the LDAP request */ retv=nss2nslcd(_nss_ldap_getaliasbyname_r(name,&result,buffer,1024,&errnop)); /* no more need for this */ free(name); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); - WRITE_INT32(fp,NSLCD_RT_ALIAS_BYNAME); + WRITE_INT32(fp,NSLCD_ACTION_ALIAS_BYNAME); WRITE_INT32(fp,retv); - if (retv==NSLCD_RS_SUCCESS) + if (retv==NSLCD_RESULT_SUCCESS) { LDF_ALIAS; } WRITE_FLUSH(fp); - log_log(LOG_DEBUG,"nslcd_aliases_byname DONE"); + log_log(LOG_DEBUG,"nslcd_alias_byname DONE"); /* we're done */ return 0; diff --git a/server/common.c b/server/common.c index 4f9c597..9ada651 100644 --- a/server/common.c +++ b/server/common.c @@ -30,10 +30,10 @@ int nss2nslcd(enum nss_status code) { switch (code) { - case NSS_STATUS_UNAVAIL: return NSLCD_RS_UNAVAIL; - case NSS_STATUS_NOTFOUND: return NSLCD_RS_NOTFOUND; - case NSS_STATUS_SUCCESS: return NSLCD_RS_SUCCESS; + case NSS_STATUS_UNAVAIL: return NSLCD_RESULT_UNAVAIL; + case NSS_STATUS_NOTFOUND: return NSLCD_RESULT_NOTFOUND; + case NSS_STATUS_SUCCESS: return NSLCD_RESULT_SUCCESS; /* case NSS_STATUS_TRYAGAIN: return NSLCD_RS_SMALLBUF; */ - default: return NSLCD_RS_UNAVAIL; + default: return NSLCD_RESULT_UNAVAIL; } } diff --git a/server/passwd.c b/server/passwd.c index 83f97b9..25f8f3d 100644 --- a/server/passwd.c +++ b/server/passwd.c @@ -221,7 +221,7 @@ static enum nss_status _nss_ldap_endpwent(void) } /* the caller should take care of opening and closing the stream */ -int nslcd_getpwnam(FILE *fp) +int nslcd_passwd_byname(FILE *fp) { int32_t tmpint32; char *name; @@ -234,26 +234,26 @@ int nslcd_getpwnam(FILE *fp) READ_STRING_ALLOC(fp,name); /* FIXME: free() this buffer somewhere */ /* log call */ - log_log(LOG_DEBUG,"nslcd_getpwnam(%s)",name); + log_log(LOG_DEBUG,"nslcd_passwd_byname(%s)",name); /* do the LDAP request */ retv=nss2nslcd(_nss_ldap_getpwnam_r(name,&result,buffer,1024,&errnop)); /* no more need for this */ free(name); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); - WRITE_INT32(fp,NSLCD_RT_GETPWBYNAME); + WRITE_INT32(fp,NSLCD_ACTION_PASSWD_BYNAME); WRITE_INT32(fp,retv); - if (retv==NSLCD_RS_SUCCESS) + if (retv==NSLCD_RESULT_SUCCESS) { LDF_PASSWD; } WRITE_FLUSH(fp); - log_log(LOG_DEBUG,"nslcd_getpwnam DONE"); + log_log(LOG_DEBUG,"nslcd_passwd_byname DONE"); /* we're done */ return 0; } -int nslcd_getpwuid(FILE *fp) +int nslcd_passwd_byuid(FILE *fp) { int32_t tmpint32; uid_t uid; @@ -265,24 +265,24 @@ int nslcd_getpwuid(FILE *fp) /* read request parameters */ READ_TYPE(fp,uid,uid_t); /* log call */ - log_log(LOG_DEBUG,"nslcd_getpwuid(%d)",(int)uid); + log_log(LOG_DEBUG,"nslcd_passwd_byuid(%d)",(int)uid); /* do the LDAP request */ retv=nss2nslcd(_nss_ldap_getpwuid_r(uid,&result,buffer,1024,&errnop)); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); - WRITE_INT32(fp,NSLCD_RT_GETPWBYUID); + WRITE_INT32(fp,NSLCD_ACTION_PASSWD_BYUID); WRITE_INT32(fp,retv); - if (retv==NSLCD_RS_SUCCESS) + if (retv==NSLCD_RESULT_SUCCESS) { LDF_PASSWD; } WRITE_FLUSH(fp); - log_log(LOG_DEBUG,"nslcd_getpwuid DONE"); + log_log(LOG_DEBUG,"nslcd_passwd_byuid DONE"); /* we're done */ return 0; } -int nslcd_getpwall(FILE *fp) +int nslcd_passwd_all(FILE *fp) { int32_t tmpint32; /* these are here for now until we rewrite the LDAP code */ @@ -291,13 +291,13 @@ int nslcd_getpwall(FILE *fp) int errnop; int retv; /* log call */ - log_log(LOG_DEBUG,"nslcd_getpwall"); + log_log(LOG_DEBUG,"nslcd_passwd_all"); /* write the response header */ WRITE_INT32(fp,NSLCD_VERSION); - WRITE_INT32(fp,NSLCD_RT_GETPWALL); + WRITE_INT32(fp,NSLCD_ACTION_PASSWD_ALL); /* loop over all results */ _nss_ldap_setpwent(); - while ((retv=nss2nslcd(_nss_ldap_getpwent_r(&result,buffer,1024,&errnop)))==NSLCD_RS_SUCCESS) + while ((retv=nss2nslcd(_nss_ldap_getpwent_r(&result,buffer,1024,&errnop)))==NSLCD_RESULT_SUCCESS) { /* write the result code */ WRITE_INT32(fp,retv); @@ -309,7 +309,7 @@ int nslcd_getpwall(FILE *fp) WRITE_INT32(fp,retv); /* FIXME: if a previous call returns what happens to the context? */ _nss_ldap_endpwent(); - log_log(LOG_DEBUG,"nslcd_getpwall DONE"); + log_log(LOG_DEBUG,"nslcd_passwd_all DONE"); /* we're done */ return 0; } |