summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2002-09-26 09:50:53 +0000
committerSimo Sorce <idra@samba.org>2002-09-26 09:50:53 +0000
commit9e70b39ab29b877906ca3e20bc25700c2e05ae1b (patch)
tree1c709fecafd012a49fd14b66b448397a3702077e /source3/passdb
parent2c33710351e2bf5b2c13060a87a5c7d917ab8116 (diff)
downloadsamba-9e70b39ab29b877906ca3e20bc25700c2e05ae1b.tar.gz
samba-9e70b39ab29b877906ca3e20bc25700c2e05ae1b.tar.bz2
samba-9e70b39ab29b877906ca3e20bc25700c2e05ae1b.zip
move all the passdb internal interface to NTSTATUS
only the interface has been fully moved to NTSTATUS not all the plugins make full use of it, but have been all converted. My testings passed completely, however a bit of more testing is welcome Simo. (This used to be commit 102a26e06591928a03b49cd312a65811ed46314f)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_interface.c116
-rw-r--r--source3/passdb/pdb_ldap.c133
-rw-r--r--source3/passdb/pdb_nisplus.c111
-rw-r--r--source3/passdb/pdb_smbpasswd.c71
-rw-r--r--source3/passdb/pdb_tdb.c70
-rw-r--r--source3/passdb/pdb_unix.c62
6 files changed, 307 insertions, 256 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index f965dd727c..a94b8b8992 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -39,26 +39,28 @@ const struct pdb_init_function_entry builtin_pdb_init_functions[] = {
{ NULL, NULL}
};
-static BOOL context_setsampwent(struct pdb_context *context, BOOL update)
+static NTSTATUS context_setsampwent(struct pdb_context *context, BOOL update)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
if (!context) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
context->pwent_methods = context->pdb_methods;
if (!context->pwent_methods) {
/* No passdbs at all */
- return True;
+ return ret;
}
- while (!(context->pwent_methods->setsampwent) || !(context->pwent_methods->setsampwent(context->pwent_methods, update))) {
+ while (NT_STATUS_IS_ERR(ret = context->pwent_methods->setsampwent(context->pwent_methods, update))) {
context->pwent_methods = context->pwent_methods->next;
if (context->pwent_methods == NULL)
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
- return True;
+ return ret;
}
static void context_endsampwent(struct pdb_context *context)
@@ -75,81 +77,82 @@ static void context_endsampwent(struct pdb_context *context)
context->pwent_methods = NULL;
}
-static BOOL context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user)
+static NTSTATUS context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
if ((!context) || (!context->pwent_methods)) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
/* Loop until we find something useful */
- while ((!context->pwent_methods->getsampwent) ||
- context->pwent_methods->getsampwent(context->pwent_methods, user) == False){
+ while (NT_STATUS_IS_ERR(ret = context->pwent_methods->getsampwent(context->pwent_methods, user))) {
- if (context->pwent_methods->endsampwent)
- context->pwent_methods->endsampwent(context->pwent_methods);
+ context->pwent_methods->endsampwent(context->pwent_methods);
context->pwent_methods = context->pwent_methods->next;
/* All methods are checked now. There are no more entries */
if (context->pwent_methods == NULL)
- return False;
+ return ret;
- if (!context->pwent_methods->setsampwent){
- DEBUG(5, ("next backend does not implment setsampwent\n"));
- return False;
- }
-
context->pwent_methods->setsampwent(context->pwent_methods, False);
}
user->methods = context->pwent_methods;
- return True;
+ return ret;
}
-static BOOL context_getsampwnam(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const char *username)
+static NTSTATUS context_getsampwnam(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const char *username)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
struct pdb_methods *curmethods;
if ((!context)) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
curmethods = context->pdb_methods;
while (curmethods){
- if (curmethods->getsampwnam && curmethods->getsampwnam(curmethods, sam_acct, username) == True){
+ if (NT_STATUS_IS_OK(ret = curmethods->getsampwnam(curmethods, sam_acct, username))) {
sam_acct->methods = curmethods;
- return True;
+ return ret;
}
curmethods = curmethods->next;
}
- return False;
+ return ret;
}
-static BOOL context_getsampwsid(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
+static NTSTATUS context_getsampwsid(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
struct pdb_methods *curmethods;
if ((!context)) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
curmethods = context->pdb_methods;
while (curmethods){
- if (curmethods->getsampwsid && curmethods->getsampwsid(curmethods, sam_acct, sid) == True){
+ if (NT_STATUS_IS_OK(ret = curmethods->getsampwsid(curmethods, sam_acct, sid))) {
sam_acct->methods = curmethods;
- return True;
+ return ret;
}
curmethods = curmethods->next;
}
- return False;
+ return ret;
}
-static BOOL context_add_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
+static NTSTATUS context_add_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
{
- if ((!context) || (!context->pdb_methods) || (!context->pdb_methods->add_sam_account)) {
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
+ if ((!context) || (!context->pdb_methods)) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
/** @todo This is where a 're-read on add' should be done */
@@ -159,21 +162,18 @@ static BOOL context_add_sam_account(struct pdb_context *context, SAM_ACCOUNT *sa
return context->pdb_methods->add_sam_account(context->pdb_methods, sam_acct);
}
-static BOOL context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
+static NTSTATUS context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
if (!context) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
if (!sam_acct || !sam_acct->methods){
DEBUG(0, ("invalid sam_acct specified\n"));
- return False;
- }
-
- if (!sam_acct->methods->update_sam_account){
- DEBUG(0, ("invalid sam_acct->methods\n"));
- return False;
+ return ret;
}
/** @todo This is where a 're-read on update' should be done */
@@ -181,12 +181,14 @@ static BOOL context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT
return sam_acct->methods->update_sam_account(sam_acct->methods, sam_acct);
}
-static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
+static NTSTATUS context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
struct pdb_methods *pdb_selected;
if (!context) {
DEBUG(0, ("invalid pdb_context specified!\n"));
- return False;
+ return ret;
}
if (!sam_acct->methods){
@@ -197,17 +199,17 @@ static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT
* in /etc/passwd.
*/
while (pdb_selected){
- if (pdb_selected->delete_sam_account && pdb_selected->delete_sam_account(pdb_selected, sam_acct)){
- return True;
+ if (NT_STATUS_IS_OK(ret = pdb_selected->delete_sam_account(pdb_selected, sam_acct))) {
+ return ret;
}
pdb_selected = pdb_selected->next;
}
- return False;
+ return ret;
}
if (!sam_acct->methods->delete_sam_account){
DEBUG(0,("invalid sam_acct->methods->delete_sam_account\n"));
- return False;
+ return ret;
}
return sam_acct->methods->delete_sam_account(sam_acct->methods, sam_acct);
@@ -223,9 +225,7 @@ static void free_pdb_context(struct pdb_context **context)
struct pdb_methods *pdb_selected = (*context)->pdb_methods;
while (pdb_selected){
- if (pdb_selected->free_private_data) {
- pdb_selected->free_private_data(&(pdb_selected->private_data));
- }
+ pdb_selected->free_private_data(&(pdb_selected->private_data));
pdb_selected = pdb_selected->next;
}
@@ -371,13 +371,13 @@ static struct pdb_context *pdb_get_static_context(BOOL reload)
if ((pdb_context) && (reload)) {
pdb_context->free_fn(&pdb_context);
- if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
+ if (NT_STATUS_IS_ERR(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
return NULL;
}
}
if (!pdb_context) {
- if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
+ if (NT_STATUS_IS_ERR(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
return NULL;
}
}
@@ -399,7 +399,7 @@ BOOL pdb_setsampwent(BOOL update)
return False;
}
- return pdb_context->pdb_setsampwent(pdb_context, update);
+ return NT_STATUS_IS_OK(pdb_context->pdb_setsampwent(pdb_context, update));
}
void pdb_endsampwent(void)
@@ -421,7 +421,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user)
return False;
}
- return pdb_context->pdb_getsampwent(pdb_context, user);
+ return NT_STATUS_IS_OK(pdb_context->pdb_getsampwent(pdb_context, user));
}
BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
@@ -432,7 +432,7 @@ BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
return False;
}
- return pdb_context->pdb_getsampwnam(pdb_context, sam_acct, username);
+ return NT_STATUS_IS_OK(pdb_context->pdb_getsampwnam(pdb_context, sam_acct, username));
}
BOOL pdb_getsampwsid(SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
@@ -443,7 +443,7 @@ BOOL pdb_getsampwsid(SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
return False;
}
- return pdb_context->pdb_getsampwsid(pdb_context, sam_acct, sid);
+ return NT_STATUS_IS_OK(pdb_context->pdb_getsampwsid(pdb_context, sam_acct, sid));
}
BOOL pdb_add_sam_account(SAM_ACCOUNT *sam_acct)
@@ -454,7 +454,7 @@ BOOL pdb_add_sam_account(SAM_ACCOUNT *sam_acct)
return False;
}
- return pdb_context->pdb_add_sam_account(pdb_context, sam_acct);
+ return NT_STATUS_IS_OK(pdb_context->pdb_add_sam_account(pdb_context, sam_acct));
}
BOOL pdb_update_sam_account(SAM_ACCOUNT *sam_acct)
@@ -465,7 +465,7 @@ BOOL pdb_update_sam_account(SAM_ACCOUNT *sam_acct)
return False;
}
- return pdb_context->pdb_update_sam_account(pdb_context, sam_acct);
+ return NT_STATUS_IS_OK(pdb_context->pdb_update_sam_account(pdb_context, sam_acct));
}
BOOL pdb_delete_sam_account(SAM_ACCOUNT *sam_acct)
@@ -476,7 +476,7 @@ BOOL pdb_delete_sam_account(SAM_ACCOUNT *sam_acct)
return False;
}
- return pdb_context->pdb_delete_sam_account(pdb_context, sam_acct);
+ return NT_STATUS_IS_OK(pdb_context->pdb_delete_sam_account(pdb_context, sam_acct));
}
#endif /* !defined(WITH_NISPLUS_SAM) */
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 71a8c256a3..c7badb50e7 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1183,18 +1183,19 @@ static uint32 ldapsam_get_next_available_nua_rid(struct ldapsam_privates *ldap_s
/**********************************************************************
Connect to LDAP server for password enumeration
*********************************************************************/
-static BOOL ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
+static NTSTATUS ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
int rc;
pstring filter;
if (!ldapsam_open_connection(ldap_state, &ldap_state->ldap_struct)) {
- return False;
+ return ret;
}
if (!ldapsam_connect_system(ldap_state, ldap_state->ldap_struct)) {
ldap_unbind(ldap_state->ldap_struct);
- return False;
+ return ret;
}
pstrcpy(filter, lp_ldap_filter());
@@ -1211,7 +1212,7 @@ static BOOL ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
ldap_unbind(ldap_state->ldap_struct);
ldap_state->ldap_struct = NULL;
ldap_state->result = NULL;
- return False;
+ return ret;
}
DEBUG(2, ("ldapsam_setsampwent: %d entries in the base!\n",
@@ -1222,7 +1223,7 @@ static BOOL ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
ldap_state->result);
ldap_state->index = 0;
- return True;
+ return NT_STATUS_OK;
}
/**********************************************************************
@@ -1242,56 +1243,58 @@ static void ldapsam_endsampwent(struct pdb_methods *my_methods)
/**********************************************************************
Get the next entry in the LDAP password database
*********************************************************************/
-static BOOL ldapsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
+static NTSTATUS ldapsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
- BOOL ret = False;
+ BOOL bret = False;
/* The rebind proc needs this *HACK*. We are not multithreaded, so
this will work, but it's not nice. */
static_ldap_state = ldap_state;
- while (!ret) {
+ while (!bret) {
if (!ldap_state->entry)
- return False;
+ return ret;
ldap_state->index++;
- ret = init_sam_from_ldap(ldap_state, user, ldap_state->ldap_struct,
+ bret = init_sam_from_ldap(ldap_state, user, ldap_state->ldap_struct,
ldap_state->entry);
ldap_state->entry = ldap_next_entry(ldap_state->ldap_struct,
ldap_state->entry);
}
- return True;
+ return NT_STATUS_OK;
}
/**********************************************************************
Get SAM_ACCOUNT entry from LDAP by username
*********************************************************************/
-static BOOL ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
LDAP *ldap_struct;
LDAPMessage *result;
LDAPMessage *entry;
if (!ldapsam_open_connection(ldap_state, &ldap_struct))
- return False;
+ return ret;
if (!ldapsam_connect_system(ldap_state, ldap_struct)) {
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
if (ldapsam_search_one_user_by_name(ldap_state, ldap_struct, sname, &result) != LDAP_SUCCESS) {
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
if (ldap_count_entries(ldap_struct, result) < 1) {
DEBUG(4,
("We don't find this user [%s] count=%d\n", sname,
ldap_count_entries(ldap_struct, result)));
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
entry = ldap_first_entry(ldap_struct, result);
if (entry) {
@@ -1299,39 +1302,39 @@ static BOOL ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT *use
DEBUG(1,("ldapsam_getsampwnam: init_sam_from_ldap failed for user '%s'!\n", sname));
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return True;
+ ret = NT_STATUS_OK;
} else {
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
}
+ return ret;
}
/**********************************************************************
Get SAM_ACCOUNT entry from LDAP by rid
*********************************************************************/
-static BOOL ldapsam_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *user, uint32 rid)
+static NTSTATUS ldapsam_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *user, uint32 rid)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
LDAP *ldap_struct;
LDAPMessage *result;
LDAPMessage *entry;
if (!ldapsam_open_connection(ldap_state, &ldap_struct))
- return False;
+ return ret;
if (!ldapsam_connect_system(ldap_state, ldap_struct)) {
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
- if (ldapsam_search_one_user_by_rid(ldap_state, ldap_struct, rid, &result) !=
- LDAP_SUCCESS) {
+ if (ldapsam_search_one_user_by_rid(ldap_state, ldap_struct, rid, &result) != LDAP_SUCCESS) {
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
if (ldap_count_entries(ldap_struct, result) < 1) {
@@ -1339,7 +1342,7 @@ static BOOL ldapsam_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *use
("We don't find this rid [%i] count=%d\n", rid,
ldap_count_entries(ldap_struct, result)));
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
entry = ldap_first_entry(ldap_struct, result);
@@ -1348,28 +1351,29 @@ static BOOL ldapsam_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *use
DEBUG(1,("ldapsam_getsampwrid: init_sam_from_ldap failed!\n"));
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return True;
+ ret = NT_STATUS_OK;
} else {
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
}
+ return ret;
}
-static BOOL ldapsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS ldapsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
{
uint32 rid;
if (!sid_peek_check_rid(get_global_sam_sid(), sid, &rid))
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
return ldapsam_getsampwrid(my_methods, user, rid);
}
-static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,LDAPMod **mods,int ldap_op)
+static NTSTATUS ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,LDAPMod **mods,int ldap_op)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
int version;
int rc;
@@ -1386,7 +1390,7 @@ static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,
pdb_get_username(newpwd), ldap_err2string(rc),
ld_error));
free(ld_error);
- return False;
+ return ret;
}
break;
case LDAP_MOD_REPLACE:
@@ -1399,12 +1403,12 @@ static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,
pdb_get_username(newpwd), ldap_err2string(rc),
ld_error));
free(ld_error);
- return False;
+ return ret;
}
break;
default:
DEBUG(0,("Wrong LDAP operation type: %d!\n",ldap_op));
- return False;
+ return ret;
}
#ifdef LDAP_EXOP_X_MODIFY_PASSWD
@@ -1425,7 +1429,7 @@ static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,
if ((ber = ber_alloc_t(LBER_USE_DER))==NULL) {
DEBUG(0,("ber_alloc_t returns NULL\n"));
- return False;
+ return ret;
}
ber_printf (ber, "{");
ber_printf (ber, "ts", LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID,dn);
@@ -1434,7 +1438,7 @@ static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,
if ((rc = ber_flatten (ber, &bv))<0) {
DEBUG(0,("ber_flatten returns a value <0\n"));
- return False;
+ return ret;
}
ber_free(ber,1);
@@ -1454,14 +1458,15 @@ static BOOL ldapsam_modify_entry(LDAP *ldap_struct,SAM_ACCOUNT *newpwd,char *dn,
#else
DEBUG(10,("LDAP PASSWORD SYNC is not supported!\n"));
#endif /* LDAP_EXOP_X_MODIFY_PASSWD */
- return True;
+ return NT_STATUS_OK;
}
/**********************************************************************
Delete entry from LDAP for username
*********************************************************************/
-static BOOL ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * sam_acct)
+static NTSTATUS ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * sam_acct)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
const char *sname;
int rc;
@@ -1472,20 +1477,20 @@ static BOOL ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
if (!sam_acct) {
DEBUG(0, ("sam_acct was NULL!\n"));
- return False;
+ return ret;
}
sname = pdb_get_username(sam_acct);
if (!ldapsam_open_connection(ldap_state, &ldap_struct))
- return False;
+ return ret;
DEBUG (3, ("Deleting user %s from LDAP.\n", sname));
if (!ldapsam_connect_system(ldap_state, ldap_struct)) {
ldap_unbind (ldap_struct);
DEBUG(0, ("Failed to delete user %s from LDAP.\n", sname));
- return False;
+ return ret;
}
rc = ldapsam_search_one_user_by_name(ldap_state, ldap_struct, sname, &result);
@@ -1493,7 +1498,7 @@ static BOOL ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
DEBUG (0, ("User doesn't exit!\n"));
ldap_msgfree (result);
ldap_unbind (ldap_struct);
- return False;
+ return ret;
}
entry = ldap_first_entry (ldap_struct, result);
@@ -1510,19 +1515,20 @@ static BOOL ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
sname, ldap_err2string (rc), ld_error));
free (ld_error);
ldap_unbind (ldap_struct);
- return False;
+ return ret;
}
DEBUG (2,("successfully deleted uid = %s from the LDAP database\n", sname));
ldap_unbind (ldap_struct);
- return True;
+ return NT_STATUS_OK;
}
/**********************************************************************
Update SAM_ACCOUNT
*********************************************************************/
-static BOOL ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
+static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
int rc;
char *dn;
@@ -1532,11 +1538,11 @@ static BOOL ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
LDAPMod **mods;
if (!ldapsam_open_connection(ldap_state, &ldap_struct)) /* open a connection to the server */
- return False;
+ return ret;
if (!ldapsam_connect_system(ldap_state, ldap_struct)) { /* connect as system account */
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
rc = ldapsam_search_one_user_by_name(ldap_state, ldap_struct,
@@ -1546,26 +1552,26 @@ static BOOL ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
DEBUG(0, ("No user to modify!\n"));
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
if (!init_ldap_from_sam(ldap_state, &mods, LDAP_MOD_REPLACE, newpwd)) {
DEBUG(0, ("ldapsam_update_sam_account: init_ldap_from_sam failed!\n"));
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
entry = ldap_first_entry(ldap_struct, result);
dn = ldap_get_dn(ldap_struct, entry);
ldap_msgfree(result);
- if (!ldapsam_modify_entry(ldap_struct,newpwd,dn,mods,LDAP_MOD_REPLACE)) {
+ if (NT_STATUS_IS_ERR(ldapsam_modify_entry(ldap_struct,newpwd,dn,mods,LDAP_MOD_REPLACE))) {
DEBUG(0,("failed to modify user with uid = %s\n",
pdb_get_username(newpwd)));
ldap_mods_free(mods,1);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
@@ -1574,14 +1580,15 @@ static BOOL ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOU
pdb_get_username(newpwd)));
ldap_mods_free(mods, 1);
ldap_unbind(ldap_struct);
- return True;
+ return NT_STATUS_OK;
}
/**********************************************************************
Add SAM_ACCOUNT to LDAP
*********************************************************************/
-static BOOL ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
+static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
{
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
int rc;
pstring filter;
@@ -1595,15 +1602,15 @@ static BOOL ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT
const char *username = pdb_get_username(newpwd);
if (!username || !*username) {
DEBUG(0, ("Cannot add user without a username!\n"));
- return False;
+ return ret;
}
if (!ldapsam_open_connection(ldap_state, &ldap_struct)) /* open a connection to the server */
- return False;
+ return ret;
if (!ldapsam_connect_system(ldap_state, ldap_struct)) { /* connect as system account */
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
rc = ldapsam_search_one_user_by_name (ldap_state, ldap_struct, username, &result);
@@ -1612,7 +1619,7 @@ static BOOL ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT
DEBUG(0,("User already in the base, with samba properties\n"));
ldap_msgfree(result);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
ldap_msgfree(result);
@@ -1623,7 +1630,7 @@ static BOOL ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT
if (num_result > 1) {
DEBUG (0, ("More than one user with that uid exists: bailing out!\n"));
ldap_msgfree(result);
- return False;
+ return ret;
}
/* Check if we need to update an existing entry */
@@ -1654,22 +1661,22 @@ static BOOL ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT
DEBUG(0, ("ldapsam_add_sam_account: init_ldap_from_sam failed!\n"));
ldap_mods_free(mods, 1);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
make_a_mod(&mods, LDAP_MOD_ADD, "objectclass", "sambaAccount");
- if (!ldapsam_modify_entry(ldap_struct,newpwd,dn,mods,ldap_op)) {
+ if (NT_STATUS_IS_ERR(ldapsam_modify_entry(ldap_struct,newpwd,dn,mods,ldap_op))) {
DEBUG(0,("failed to modify/add user with uid = %s (dn = %s)\n",
pdb_get_username(newpwd),dn));
ldap_mods_free(mods,1);
ldap_unbind(ldap_struct);
- return False;
+ return ret;
}
DEBUG(2,("added: uid = %s in the LDAP database\n", pdb_get_username(newpwd)));
ldap_mods_free(mods, 1);
ldap_unbind(ldap_struct);
- return True;
+ return NT_STATUS_OK;
}
static void free_private_data(void **vp)
diff --git a/source3/passdb/pdb_nisplus.c b/source3/passdb/pdb_nisplus.c
index 484e8986e4..de520b6b14 100644
--- a/source3/passdb/pdb_nisplus.c
+++ b/source3/passdb/pdb_nisplus.c
@@ -130,7 +130,7 @@ static nis_result *nisp_get_nis_list (const char *nisname,
Start enumeration of the passwd list.
****************************************************************/
-static BOOL nisplussam_setsampwent (struct pdb_methods *methods, BOOL update)
+static NTSTATUS nisplussam_setsampwent (struct pdb_methods *methods, BOOL update)
{
struct nisplus_private_info *private =
(struct nisplus_private_info *) methods->private_data;
@@ -148,7 +148,10 @@ static BOOL nisplussam_setsampwent (struct pdb_methods *methods, BOOL update)
pdb_endsampwent (); /* just in case */
global_nisp_ent->result = nisp_get_nis_list (pfiletmp, 0);
global_nisp_ent->enum_entry = 0;
- return global_nisp_ent->result != NULL ? True : False;
+ if (global_nisp_ent->result != NULL)
+ return NT_STATUS_UNSUCCESSFUL;
+ else
+ return NT_STATUS_OK;
}
/***************************************************************
@@ -169,10 +172,10 @@ static void nisplussam_endsampwent (struct pdb_methods *methods)
Get one SAM_ACCOUNT from the list (next in line)
*****************************************************************/
-static BOOL nisplussam_getsampwent (struct pdb_methods *methods,
+static NTSTATUS nisplussam_getsampwent (struct pdb_methods *methods,
SAM_ACCOUNT * user)
{
-
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct nisplus_private_info *global_nisp_ent =
(struct nisplus_private_info *) methods->private_data;
int enum_entry = (int) (global_nisp_ent->enum_entry);
@@ -180,33 +183,31 @@ static BOOL nisplussam_getsampwent (struct pdb_methods *methods,
if (user == NULL) {
DEBUG (0, ("SAM_ACCOUNT is NULL.\n"));
- return False;
+ return nt_status;
}
- if (result == NULL ||
- enum_entry < 0 || enum_entry >= (NIS_RES_NUMOBJ (result) - 1)) {
- return False;
+ if (result == NULL || enum_entry < 0 || enum_entry >= (NIS_RES_NUMOBJ (result) - 1)) {
+ return nt_status;
}
- if (!make_sam_from_nisp_object
- (user, &NIS_RES_OBJECT (result)[enum_entry])) {
+ if (!make_sam_from_nisp_object(user, &NIS_RES_OBJECT (result)[enum_entry])) {
DEBUG (0, ("Bad SAM_ACCOUNT entry returned from NIS+!\n"));
- return False;
+ return nt_status;
}
(int) (global_nisp_ent->enum_entry)++;
- return True;
- DEBUG (10, ("nisplussam_getsampwent called\n"));
- return False;
+
+ return nt_status;
}
/******************************************************************
Lookup a name in the SAM database
******************************************************************/
-static BOOL nisplussam_getsampwnam (struct pdb_methods *methods,
+static NTSTATUS nisplussam_getsampwnam (struct pdb_methods *methods,
SAM_ACCOUNT * user, const char *sname)
{
/* Static buffers we will return. */
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
nis_result *result = NULL;
pstring nisname;
BOOL ret;
@@ -215,7 +216,7 @@ static BOOL nisplussam_getsampwnam (struct pdb_methods *methods,
if (!private->location || !(*private->location)) {
DEBUG (0, ("No SMB password file set\n"));
- return False;
+ return nt_status;
}
if (strrchr (private->location, '/'))
private->location = strrchr (private->location, '/') + 1;
@@ -227,25 +228,25 @@ static BOOL nisplussam_getsampwnam (struct pdb_methods *methods,
/* Search the table. */
if (!(result = nisp_get_nis_list (nisname, 0))) {
- return False;
+ return nt_status;
}
ret = make_sam_from_nisresult (user, result);
nis_freeresult (result);
- return ret;
+ if (ret) nt_status = NT_STATUS_OK;
- DEBUG (10, ("nisplussam_getsampwnam called\n"));
- return False;
+ return nt_status;
}
/***************************************************************************
Search by sid
**************************************************************************/
-static BOOL nisplussam_getsampwrid (struct pdb_methods *methods,
+static NTSTATUS nisplussam_getsampwrid (struct pdb_methods *methods,
SAM_ACCOUNT * user, uint32 rid)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
nis_result *result;
char *nisname;
BOOL ret;
@@ -256,7 +257,7 @@ static BOOL nisplussam_getsampwrid (struct pdb_methods *methods,
if (!private->location || !(*private->location)) {
DEBUG (0, ("no SMB password file set\n"));
- return False;
+ return nt_status;
}
if ((sp = strrchr (private->location, '/')))
@@ -273,22 +274,24 @@ static BOOL nisplussam_getsampwrid (struct pdb_methods *methods,
/* Search the table. */
if (!(result = nisp_get_nis_list (nisname, 0))) {
- return False;
+ return nt_status;
}
ret = make_sam_from_nisresult (user, result);
nis_freeresult (result);
- return ret;
+ if (ret) nt_status = NT_STATUS_OK;
+
+ return nt_status;
}
-static BOOL nisplussam_getsampwsid (struct pdb_methods *methods,
+static NTSTATUS nisplussam_getsampwsid (struct pdb_methods *methods,
SAM_ACCOUNT * user, const DOM_SID * sid)
{
uint32 rid;
if (!sid_peek_check_rid (get_global_sam_sid (), sid, &rid))
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
return nisplussam_getsampwrid (methods, user, rid);
}
@@ -298,9 +301,10 @@ static BOOL nisplussam_getsampwsid (struct pdb_methods *methods,
Delete a SAM_ACCOUNT
****************************************************************************/
-static BOOL nisplussam_delete_sam_account (struct pdb_methods *methods,
- SAM_ACCOUNT * user)
+static NTSTATUS nisplussam_delete_sam_account (struct pdb_methods *methods,
+ SAM_ACCOUNT * user)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
const char *sname;
pstring nisname;
nis_result *result, *delresult;
@@ -310,14 +314,14 @@ static BOOL nisplussam_delete_sam_account (struct pdb_methods *methods,
if (!user) {
DEBUG (0, ("no SAM_ACCOUNT specified!\n"));
- return False;
+ return nt_status;
}
sname = pdb_get_username (user);
if (!private->location || !(*private->location)) {
DEBUG (0, ("no SMB password file set\n"));
- return False;
+ return nt_status;
}
if (strrchr (private->location, '/'))
@@ -332,14 +336,14 @@ static BOOL nisplussam_delete_sam_account (struct pdb_methods *methods,
MASTER_ONLY | FOLLOW_LINKS |
FOLLOW_PATH | EXPAND_NAME |
HARD_LOOKUP))) {
- return False;
+ return nt_status;
}
if (result->status != NIS_SUCCESS || NIS_RES_NUMOBJ (result) <= 0) {
/* User not found. */
DEBUG (0, ("user not found in NIS+\n"));
nis_freeresult (result);
- return False;
+ return nt_status;
}
obj = NIS_RES_OBJECT (result);
@@ -358,21 +362,21 @@ static BOOL nisplussam_delete_sam_account (struct pdb_methods *methods,
DEBUG (0, ("NIS+ table update failed: %s %s\n",
nisname, nis_sperrno (delresult->status)));
nis_freeresult (delresult);
- return False;
+ return nt_status;
}
nis_freeresult (delresult);
- return True;
- DEBUG (10, ("nisplussam_delete_sam_account called\n"));
- return False;
+
+ return NT_STATUS_OK;
}
/***************************************************************************
Modifies an existing SAM_ACCOUNT
****************************************************************************/
-static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
+static NTSTATUS nisplussam_update_sam_account (struct pdb_methods *methods,
SAM_ACCOUNT * newpwd)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
nis_result *result, *addresult;
nis_object *obj;
nis_object new_obj;
@@ -384,7 +388,7 @@ static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
if (!private->location || !(*private->location)) {
DEBUG (0, ("no SMB password file set\n"));
- return False;
+ return nt_status;
}
if (strrchr (private->location, '/'))
private->location = strrchr (private->location, '/') + 1;
@@ -401,14 +405,14 @@ static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
nisp_get_nis_list (nisname,
MASTER_ONLY | FOLLOW_LINKS | FOLLOW_PATH |
EXPAND_NAME | HARD_LOOKUP))) {
- return False;
+ return ne_status;
}
if (result->status != NIS_SUCCESS || NIS_RES_NUMOBJ (result) <= 0) {
/* User not found. */
DEBUG (0, ("user not found in NIS+\n"));
nis_freeresult (result);
- return False;
+ return nt_status;
}
obj = NIS_RES_OBJECT (result);
@@ -425,7 +429,7 @@ static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
if (!(ecol = (entry_col *) malloc (ta_maxcol * sizeof (entry_col)))) {
DEBUG (0, ("memory allocation failure\n"));
nis_freeresult (result);
- return False;
+ return nt_status;
}
memmove ((char *) ecol, obj->EN_data.en_cols.en_cols_val,
@@ -449,7 +453,7 @@ static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
nis_freeresult (addresult);
nis_freeresult (result);
free (ecol);
- return False;
+ return nt_status;
}
DEBUG (6, ("password changed\n"));
@@ -461,16 +465,17 @@ static BOOL nisplussam_update_sam_account (struct pdb_methods *methods,
free (ecol);
nis_freeresult (result);
- return True;
+ return NT_STATUS_OK;
}
/***************************************************************************
Adds an existing SAM_ACCOUNT
****************************************************************************/
-static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
+static NTSTATUS nisplussam_add_sam_account (struct pdb_methods *methods,
SAM_ACCOUNT * newpwd)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
int local_user = 0;
char *pfile;
pstring pfiletmp;
@@ -518,7 +523,7 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
nisname = make_nisname_from_name (pdb_get_username (newpwd),
pfiletmp);
} else {
- return False;
+ return nt_status;
}
if (!
@@ -526,20 +531,20 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
nisp_get_nis_list (nisname,
MASTER_ONLY | FOLLOW_LINKS | FOLLOW_PATH |
EXPAND_NAME | HARD_LOOKUP))) {
- return False;
+ return nt_status;
}
if (result->status != NIS_SUCCESS && result->status != NIS_NOTFOUND) {
DEBUG (3, ("nis_list failure: %s: %s\n",
nisname, nis_sperrno (result->status)));
nis_freeresult (result);
- return False;
+ return nt_status;
}
if (result->status == NIS_SUCCESS && NIS_RES_NUMOBJ (result) > 0) {
DEBUG (3, ("User already exists in NIS+ password db: %s\n",
pfile));
nis_freeresult (result);
- return False;
+ return nt_status;
}
nis_freeresult (result); /* no such user, free results */
@@ -565,7 +570,7 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
if (!(passwd = getpwnam_alloc (pdb_get_username (newpwd)))) {
/* no such user in system! */
- return False;
+ return nt_status;
}
passwd_free (&passwd);
@@ -607,7 +612,7 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
nis_freeresult (tblresult);
DEBUG (3, ("nis_lookup failure: %s\n",
nis_sperrno (tblresult->status)));
- return False;
+ return nt_status;
}
/* we need full name for nis_add_entry() */
safe_strcpy (pfiletmp, pfile, sizeof (pfiletmp) - 1);
@@ -636,7 +641,7 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
if (!(ecol = (entry_col *) malloc (ta_maxcol * sizeof (entry_col)))) {
DEBUG (0, ("memory allocation failure\n"));
nis_freeresult (tblresult);
- return False;
+ return nt_status;
}
memset ((char *) ecol, 0, ta_maxcol * sizeof (entry_col));
@@ -655,13 +660,13 @@ static BOOL nisplussam_add_sam_account (struct pdb_methods *methods,
nisname, nis_sperrno (result->status)));
nis_freeresult (tblresult);
nis_freeresult (result);
- return False;
+ return nt_status;
}
nis_freeresult (tblresult);
nis_freeresult (result);
- return True;
+ return NT_STATUS_OK;
}
/***************************************************************
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index 04c0d333e4..257b5fa2aa 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -1248,7 +1248,7 @@ static BOOL build_sam_account(struct smbpasswd_privates *smbpasswd_state,
/*****************************************************************
Functions to be implemented by the new passdb API
****************************************************************/
-static BOOL smbpasswd_setsampwent (struct pdb_methods *my_methods, BOOL update)
+static NTSTATUS smbpasswd_setsampwent (struct pdb_methods *my_methods, BOOL update)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
@@ -1275,7 +1275,10 @@ static BOOL smbpasswd_setsampwent (struct pdb_methods *my_methods, BOOL update)
&(smbpasswd_state->pw_file_lock_depth));
}
- return (smbpasswd_state->pw_file != NULL);
+ if (smbpasswd_state->pw_file != NULL)
+ return NT_STATUS_OK;
+ else
+ return NT_STATUS_UNSUCCESSFUL;
}
static void smbpasswd_endsampwent (struct pdb_methods *my_methods)
@@ -1286,8 +1289,9 @@ static void smbpasswd_endsampwent (struct pdb_methods *my_methods)
/*****************************************************************
****************************************************************/
-static BOOL smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
+static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd *pw_buf=NULL;
BOOL done = False;
@@ -1298,7 +1302,7 @@ static BOOL smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *u
#if 0
smb_panic("NULL pointer passed to getsampwent (smbpasswd)\n");
#endif
- return False;
+ return nt_status;
}
while (!done)
@@ -1306,7 +1310,7 @@ static BOOL smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *u
/* do we have an entry? */
pw_buf = getsmbfilepwent(smbpasswd_state, smbpasswd_state->pw_file);
if (pw_buf == NULL)
- return False;
+ return nt_status;
/* build the SAM_ACCOUNT entry from the smb_passwd struct.
We loop in case the user in the pdb does not exist in
@@ -1318,7 +1322,7 @@ static BOOL smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *u
DEBUG(5,("getsampwent (smbpasswd): done\n"));
/* success */
- return True;
+ return NT_STATUS_OK;
}
@@ -1327,9 +1331,10 @@ static BOOL smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *u
call getpwnam() for unix account information until we have found
the correct entry
***************************************************************/
-static BOOL smbpasswd_getsampwnam(struct pdb_methods *my_methods,
+static NTSTATUS smbpasswd_getsampwnam(struct pdb_methods *my_methods,
SAM_ACCOUNT *sam_acct, const char *username)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd *smb_pw;
void *fp = NULL;
@@ -1343,7 +1348,7 @@ static BOOL smbpasswd_getsampwnam(struct pdb_methods *my_methods,
if (fp == NULL) {
DEBUG(0, ("unable to open passdb database.\n"));
- return False;
+ return nt_status;
}
while ( ((smb_pw=getsmbfilepwent(smbpasswd_state, fp)) != NULL)&& (!strequal(smb_pw->smb_name, username)) )
@@ -1354,7 +1359,7 @@ static BOOL smbpasswd_getsampwnam(struct pdb_methods *my_methods,
/* did we locate the username in smbpasswd */
if (smb_pw == NULL)
- return False;
+ return nt_status;
DEBUG(10, ("getsampwnam (smbpasswd): found by name: %s\n", smb_pw->smb_name));
@@ -1363,19 +1368,20 @@ static BOOL smbpasswd_getsampwnam(struct pdb_methods *my_methods,
#if 0
smb_panic("NULL pointer passed to pdb_getsampwnam\n");
#endif
- return False;
+ return nt_status;
}
/* now build the SAM_ACCOUNT */
if (!build_sam_account(smbpasswd_state, sam_acct, smb_pw))
- return False;
+ return nt_status;
/* success */
- return True;
+ return NT_STATUS_OK;
}
-static BOOL smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_acct,uint32 rid)
+static NTSTATUS smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_acct,uint32 rid)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd *smb_pw;
void *fp = NULL;
@@ -1387,7 +1393,7 @@ static BOOL smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *s
const char *guest_account = lp_guestaccount();
if (!(guest_account && *guest_account)) {
DEBUG(1, ("Guest account not specfied!\n"));
- return False;
+ return nt_status;
}
return smbpasswd_getsampwnam(my_methods, sam_acct, guest_account);
}
@@ -1397,7 +1403,7 @@ static BOOL smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *s
if (fp == NULL) {
DEBUG(0, ("unable to open passdb database.\n"));
- return False;
+ return nt_status;
}
while ( ((smb_pw=getsmbfilepwent(smbpasswd_state, fp)) != NULL) && (fallback_pdb_uid_to_user_rid(smb_pw->smb_userid) != rid) )
@@ -1408,7 +1414,7 @@ static BOOL smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *s
/* did we locate the username in smbpasswd */
if (smb_pw == NULL)
- return False;
+ return nt_status;
DEBUG(10, ("getsampwrid (smbpasswd): found by name: %s\n", smb_pw->smb_name));
@@ -1417,44 +1423,44 @@ static BOOL smbpasswd_getsampwrid(struct pdb_methods *my_methods, SAM_ACCOUNT *s
#if 0
smb_panic("NULL pointer passed to pdb_getsampwrid\n");
#endif
- return False;
+ return nt_status;
}
/* now build the SAM_ACCOUNT */
if (!build_sam_account (smbpasswd_state, sam_acct, smb_pw))
- return False;
+ return nt_status;
/* success */
- return True;
+ return NT_STATUS_OK;
}
-static BOOL smbpasswd_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
{
uint32 rid;
if (!sid_peek_check_rid(get_global_sam_sid(), sid, &rid))
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
return smbpasswd_getsampwrid(my_methods, user, rid);
}
-static BOOL smbpasswd_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd smb_pw;
/* convert the SAM_ACCOUNT */
if (!build_smb_pass(&smb_pw, sampass)) {
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
/* add the entry */
if(!add_smbfilepwd_entry(smbpasswd_state, &smb_pw)) {
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
- return True;
+ return NT_STATUS_OK;
}
-static BOOL smbpasswd_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd smb_pw;
@@ -1462,25 +1468,28 @@ static BOOL smbpasswd_update_sam_account(struct pdb_methods *my_methods, SAM_ACC
/* convert the SAM_ACCOUNT */
if (!build_smb_pass(&smb_pw, sampass)) {
DEBUG(0, ("smbpasswd_update_sam_account: build_smb_pass failed!\n"));
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
/* update the entry */
if(!mod_smbfilepwd_entry(smbpasswd_state, &smb_pw)) {
DEBUG(0, ("smbpasswd_update_sam_account: mod_smbfilepwd_entry failed!\n"));
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
- return True;
+ return NT_STATUS_OK;
}
-static BOOL smbpasswd_delete_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_delete_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
const char *username = pdb_get_username(sampass);
- return del_smbfilepwd_entry(smbpasswd_state, username);
+ if (del_smbfilepwd_entry(smbpasswd_state, username))
+ return NT_STATUS_OK;
+
+ return NT_STATUS_UNSUCCESSFUL;
}
static void free_private_data(void **vp)
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 27453fc1af..241b3298b0 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -484,7 +484,7 @@ static uint32 init_buffer_from_sam (struct tdbsam_privates *tdb_state,
Open the TDB passwd database for SAM account enumeration.
****************************************************************/
-static BOOL tdbsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
+static NTSTATUS tdbsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
{
struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data;
@@ -492,12 +492,12 @@ static BOOL tdbsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
if (!(tdb_state->passwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, update?(O_RDWR|O_CREAT):O_RDONLY, 0600)))
{
DEBUG(0, ("Unable to open/create TDB passwd\n"));
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
tdb_state->key = tdb_firstkey(tdb_state->passwd_tdb);
- return True;
+ return NT_STATUS_OK;
}
static void close_tdb(struct tdbsam_privates *tdb_state)
@@ -524,8 +524,9 @@ static void tdbsam_endsampwent(struct pdb_methods *my_methods)
Get one SAM_ACCOUNT from the TDB (next in line)
*****************************************************************/
-static BOOL tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
+static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data;
TDB_DATA data;
char *prefix = USERPREFIX;
@@ -534,7 +535,7 @@ static BOOL tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user
if (user==NULL) {
DEBUG(0,("pdb_get_sampwent: SAM_ACCOUNT is NULL.\n"));
- return False;
+ return nt_status;
}
/* skip all non-USER entries (eg. RIDs) */
@@ -545,35 +546,36 @@ static BOOL tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user
/* do we have an valid iteration pointer? */
if(tdb_state->passwd_tdb == NULL) {
DEBUG(0,("pdb_get_sampwent: Bad TDB Context pointer.\n"));
- return False;
+ return nt_status;
}
data = tdb_fetch(tdb_state->passwd_tdb, tdb_state->key);
if (!data.dptr) {
DEBUG(5,("pdb_getsampwent: database entry not found.\n"));
- return False;
+ return nt_status;
}
/* unpack the buffer */
if (!init_sam_from_buffer(tdb_state, user, data.dptr, data.dsize)) {
DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
SAFE_FREE(data.dptr);
- return False;
+ return nt_status;
}
SAFE_FREE(data.dptr);
/* increment to next in line */
tdb_state->key = tdb_nextkey(tdb_state->passwd_tdb, tdb_state->key);
- return True;
+ return NT_STATUS_OK;
}
/******************************************************************
Lookup a name in the SAM TDB
******************************************************************/
-static BOOL tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data;
TDB_CONTEXT *pwd_tdb;
TDB_DATA data, key;
@@ -582,7 +584,7 @@ static BOOL tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *use
if (user==NULL) {
DEBUG(0,("pdb_getsampwnam: SAM_ACCOUNT is NULL.\n"));
- return False;
+ return nt_status;
}
/* Data is stored in all lower-case */
@@ -596,7 +598,7 @@ static BOOL tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *use
/* open the accounts TDB */
if (!(pwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, O_RDONLY, 0600))) {
DEBUG(0, ("pdb_getsampwnam: Unable to open TDB passwd (%s)!\n", tdb_state->tdbsam_location));
- return False;
+ return nt_status;
}
/* get the record */
@@ -606,7 +608,7 @@ static BOOL tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *use
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb)));
DEBUGADD(5, (" Key: %s\n", keystr));
tdb_close(pwd_tdb);
- return False;
+ return nt_status;
}
/* unpack the buffer */
@@ -614,22 +616,23 @@ static BOOL tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *use
DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
SAFE_FREE(data.dptr);
tdb_close(pwd_tdb);
- return False;
+ return nt_status;
}
SAFE_FREE(data.dptr);
/* no further use for database, close it now */
tdb_close(pwd_tdb);
- return True;
+ return NT_STATUS_OK;
}
/***************************************************************************
Search by rid
**************************************************************************/
-static BOOL tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *user, uint32 rid)
+static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *user, uint32 rid)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data;
TDB_CONTEXT *pwd_tdb;
TDB_DATA data, key;
@@ -638,7 +641,7 @@ static BOOL tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *use
if (user==NULL) {
DEBUG(0,("pdb_getsampwrid: SAM_ACCOUNT is NULL.\n"));
- return False;
+ return nt_status;
}
/* set search key */
@@ -649,7 +652,7 @@ static BOOL tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *use
/* open the accounts TDB */
if (!(pwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, O_RDONLY, 0600))) {
DEBUG(0, ("pdb_getsampwrid: Unable to open TDB rid database!\n"));
- return False;
+ return nt_status;
}
/* get the record */
@@ -658,7 +661,7 @@ static BOOL tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *use
DEBUG(5,("pdb_getsampwrid (TDB): error looking up RID %d by key %s.\n", rid, keystr));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb)));
tdb_close (pwd_tdb);
- return False;
+ return nt_status;
}
fstrcpy (name, data.dptr);
@@ -669,11 +672,11 @@ static BOOL tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *use
return tdbsam_getsampwnam (my_methods, user, name);
}
-static BOOL tdbsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS tdbsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
{
uint32 rid;
if (!sid_peek_check_rid(get_global_sam_sid(), sid, &rid))
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
return tdbsam_getsampwrid(my_methods, user, rid);
}
@@ -681,8 +684,9 @@ static BOOL tdbsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * use
Delete a SAM_ACCOUNT
****************************************************************************/
-static BOOL tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_pass)
+static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_pass)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data;
TDB_CONTEXT *pwd_tdb;
TDB_DATA key;
@@ -695,7 +699,7 @@ static BOOL tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUN
/* open the TDB */
if (!(pwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, O_RDWR, 0600))) {
DEBUG(0, ("Unable to open TDB passwd!"));
- return False;
+ return nt_status;
}
/* set the search key */
@@ -710,7 +714,7 @@ static BOOL tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUN
DEBUG(5, ("Error deleting entry from tdb passwd database!\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb)));
tdb_close(pwd_tdb);
- return False;
+ return nt_status;
}
/* delete also the RID key */
@@ -725,12 +729,12 @@ static BOOL tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUN
DEBUG(5, ("Error deleting entry from tdb rid database!\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb)));
tdb_close(pwd_tdb);
- return False;
+ return nt_status;
}
tdb_close(pwd_tdb);
- return True;
+ return NT_STATUS_OK;
}
/***************************************************************************
@@ -872,18 +876,24 @@ done:
Modifies an existing SAM_ACCOUNT
****************************************************************************/
-static BOOL tdbsam_update_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS tdbsam_update_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
{
- return (tdb_update_sam(my_methods, newpwd, TDB_MODIFY));
+ if (tdb_update_sam(my_methods, newpwd, TDB_MODIFY))
+ return NT_STATUS_OK;
+ else
+ return NT_STATUS_UNSUCCESSFUL;
}
/***************************************************************************
Adds an existing SAM_ACCOUNT
****************************************************************************/
-static BOOL tdbsam_add_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS tdbsam_add_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
{
- return (tdb_update_sam(my_methods, newpwd, TDB_INSERT));
+ if (tdb_update_sam(my_methods, newpwd, TDB_INSERT))
+ return NT_STATUS_OK;
+ else
+ return NT_STATUS_UNSUCCESSFUL;
}
static void free_private_data(void **vp)
diff --git a/source3/passdb/pdb_unix.c b/source3/passdb/pdb_unix.c
index 06f12164eb..ba5ed0abdf 100644
--- a/source3/passdb/pdb_unix.c
+++ b/source3/passdb/pdb_unix.c
@@ -23,20 +23,20 @@
Lookup a name in the SAM database
******************************************************************/
-static BOOL unixsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS unixsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
{
struct passwd *pass;
if (!methods) {
DEBUG(0,("invalid methods\n"));
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
if (!sname) {
DEBUG(0,("invalid name specified"));
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
}
pass = Get_Pwnam(sname);
- return NT_STATUS_IS_OK(pdb_fill_sam_pw(user, pass));
+ return pdb_fill_sam_pw(user, pass);
}
@@ -44,45 +44,45 @@ static BOOL unixsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user,
Search by rid
**************************************************************************/
-static BOOL unixsam_getsampwrid (struct pdb_methods *methods,
+static NTSTATUS unixsam_getsampwrid (struct pdb_methods *methods,
SAM_ACCOUNT *user, uint32 rid)
{
+ NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct passwd *pass;
- BOOL ret = False;
const char *guest_account = lp_guestaccount();
if (!(guest_account && *guest_account)) {
DEBUG(1, ("NULL guest account!?!?\n"));
- return False;
+ return nt_status;
}
if (!methods) {
DEBUG(0,("invalid methods\n"));
- return False;
+ return nt_status;
}
if (rid == DOMAIN_USER_RID_GUEST) {
pass = getpwnam_alloc(guest_account);
if (!pass) {
DEBUG(1, ("guest account %s does not seem to exist...\n", guest_account));
- return False;
+ return nt_status;
}
} else if (pdb_rid_is_user(rid)) {
pass = getpwuid_alloc(fallback_pdb_user_rid_to_uid (rid));
} else {
- return False;
+ return nt_status;
}
- ret = NT_STATUS_IS_OK(pdb_fill_sam_pw(user, pass));
+ nt_status = pdb_fill_sam_pw(user, pass);
passwd_free(&pass);
- return ret;
+ return nt_status;
}
-static BOOL unixsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS unixsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
{
uint32 rid;
if (!sid_peek_check_rid(get_global_sam_sid(), sid, &rid))
- return False;
+ return NT_STATUS_UNSUCCESSFUL;
return unixsam_getsampwrid(my_methods, user, rid);
}
@@ -90,10 +90,10 @@ static BOOL unixsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * us
Adds an existing SAM_ACCOUNT
****************************************************************************/
-static BOOL unixsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS unixsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
{
DEBUG(0,("pdb_unix should not be listed as the first passdb backend! You can't add users to it.\n"));
- return False;
+ return NT_STATUS_NOT_IMPLEMENTED;
}
/***************************************************************************
@@ -106,11 +106,31 @@ static BOOL unixsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *n
as if the pdb_unix version was modified, but its actually stored somehwere.
****************************************************************************/
-static BOOL unixsam_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS unixsam_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
{
return methods->parent->pdb_add_sam_account(methods->parent, newpwd);
}
+static NTSTATUS unixsam_delete_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *pwd)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS unixsam_setsampwent(struct pdb_methods *methods, BOOL update)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS unixsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static void unixsam_endsampwent(struct pdb_methods *methods)
+{
+ return; /* NT_STATUS_NOT_IMPLEMENTED; */
+}
+
NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
@@ -126,14 +146,14 @@ NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co
(*pdb_method)->name = "unixsam";
- (*pdb_method)->setsampwent = NULL;
- (*pdb_method)->endsampwent = NULL;
- (*pdb_method)->getsampwent = NULL;
+ (*pdb_method)->setsampwent = unixsam_setsampwent;
+ (*pdb_method)->endsampwent = unixsam_endsampwent;
+ (*pdb_method)->getsampwent = unixsam_getsampwent;
(*pdb_method)->getsampwnam = unixsam_getsampwnam;
(*pdb_method)->getsampwsid = unixsam_getsampwsid;
(*pdb_method)->add_sam_account = unixsam_add_sam_account;
(*pdb_method)->update_sam_account = unixsam_update_sam_account;
- (*pdb_method)->delete_sam_account = NULL;
+ (*pdb_method)->delete_sam_account = unixsam_delete_sam_account;
/* There's not very much to initialise here */
return NT_STATUS_OK;