--- /dev/null
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+
+ a common place to work out how to define NSS_STATUS on various
+ platforms
+
+ Copyright (C) Tim Potter 2000
+
+ 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., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifdef HAVE_NSS_COMMON_H
+
+/* Sun Solaris */
+
+#include <nss_common.h>
+#include <nss_dbdefs.h>
+#include <nsswitch.h>
+
+typedef nss_status_t NSS_STATUS;
+
+#define NSS_STATUS_SUCCESS NSS_SUCCESS
+#define NSS_STATUS_NOTFOUND NSS_NOTFOUND
+#define NSS_STATUS_UNAVAIL NSS_UNAVAIL
+#define NSS_STATUS_TRYAGAIN NSS_TRYAGAIN
+
+#elif HAVE_NSS_H
+
+/* GNU */
+
+#include <nss.h>
+
+typedef enum nss_status NSS_STATUS;
+
+#else /* Nothing's defined. Neither gnu nor sun */
+
+typedef enum
+{
+ NSS_STATUS_SUCCESS=0,
+ NSS_STATUS_NOTFOUND=1,
+ NSS_STATUS_UNAVAIL=2,
+ NSS_STATUS_TRYAGAIN=3
+} NSS_STATUS;
+
+#endif
+
/* Prototypes from common.h */
-enum nss_status winbindd_request(int req_type,
- struct winbindd_request *request,
- struct winbindd_response *response);
+NSS_STATUS winbindd_request(int req_type,
+ struct winbindd_request *request,
+ struct winbindd_response *response);
/* List groups a user is a member of */
{
struct winbindd_request request;
struct winbindd_response response;
- int result, i;
+ NSS_STATUS result;
+ int i;
ZERO_STRUCT(response);
/* Send request */
- if (winbindd_request(WINBINDD_LIST_TRUSTDOM, NULL, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_LIST_TRUSTDOM, NULL, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
/* Send request */
request.data.uid = uid;
- if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
/* Send request */
request.data.gid = gid;
- if (winbindd_request(WINBINDD_GID_TO_SID, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_GID_TO_SID, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
/* Send request */
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_SID_TO_UID, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_SID_TO_UID, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
/* Send request */
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_SID_TO_GID, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_SID_TO_GID, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
/* Send off request */
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_LOOKUPSID, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_LOOKUPSID, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
ZERO_STRUCT(response);
fstrcpy(request.data.name, name);
- if (winbindd_request(WINBINDD_LOOKUPNAME, &request, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_LOOKUPNAME, &request, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
{
struct winbindd_request request;
struct winbindd_response response;
- enum winbindd_result result;
+ NSS_STATUS result;
char *p;
/* Send off request */
/* Display response */
printf("plaintext password authentication %s\n",
- (result == WINBINDD_OK) ? "succeeded" : "failed");
+ (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
- return result == WINBINDD_OK;
+ return result == NSS_STATUS_SUCCESS;
}
/* Authenticate a user with a challenge/response */
{
struct winbindd_request request;
struct winbindd_response response;
- enum winbindd_result result;
+ NSS_STATUS result;
fstring pass;
char *p;
generate_random_buffer(request.data.auth_crap.chal, 8, False);
- SMBencrypt(pass, request.data.auth_crap.chal,
- request.data.auth_crap.lm_resp);
- SMBNTencrypt(pass, request.data.auth_crap.chal,
- request.data.auth_crap.nt_resp);
+ SMBencrypt((uchar *)pass, request.data.auth_crap.chal,
+ (uchar *)request.data.auth_crap.lm_resp);
+ SMBNTencrypt((uchar *)pass, request.data.auth_crap.chal,
+ (uchar *)request.data.auth_crap.nt_resp);
request.data.auth_crap.lm_resp_len = 24;
request.data.auth_crap.nt_resp_len = 24;
/* Display response */
printf("challenge/response password authentication %s\n",
- (result == WINBINDD_OK) ? "succeeded" : "failed");
+ (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
- return result == WINBINDD_OK;
+ return result == NSS_STATUS_SUCCESS;
}
/* Print domain users */
ZERO_STRUCT(response);
- if (winbindd_request(WINBINDD_LIST_USERS, NULL, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_LIST_USERS, NULL, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}
ZERO_STRUCT(response);
- if (winbindd_request(WINBINDD_LIST_GROUPS, NULL, &response) ==
- WINBINDD_ERROR) {
+ if (winbindd_request(WINBINDD_LIST_GROUPS, NULL, &response) !=
+ NSS_STATUS_SUCCESS) {
return False;
}