svn commit: samba r16049 - in trunk/source: . passdb

vlendec at samba.org vlendec at samba.org
Mon Jun 5 20:19:23 GMT 2006


Author: vlendec
Date: 2006-06-05 20:19:22 +0000 (Mon, 05 Jun 2006)
New Revision: 16049

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16049

Log:
Get real NTSTATUS out of smbpasswd_add_sam_account
Modified:
   trunk/source/Makefile.in
   trunk/source/passdb/pdb_smbpasswd.c


Changeset:
Modified: trunk/source/Makefile.in
===================================================================
--- trunk/source/Makefile.in	2006-06-05 20:09:24 UTC (rev 16048)
+++ trunk/source/Makefile.in	2006-06-05 20:19:22 UTC (rev 16049)
@@ -509,7 +509,7 @@
 PDBEDIT_OBJ = utils/pdbedit.o utils/passwd_util.o $(PARAM_OBJ) $(PASSDB_OBJ) \
 		$(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) \
 		$(SECRETS_OBJ) $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) libsmb/asn1.o \
-		$(RPC_PARSE_OBJ1) $(DOSERR_OBJ)
+		$(RPC_PARSE_OBJ1) $(DOSERR_OBJ) libsmb/errormap.o
 
 SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ)
 
@@ -781,7 +781,8 @@
 		libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \
 		libads/kerberos_verify.o $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) \
 		libads/authdata.o $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
-		$(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ)
+		$(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \
+		libsmb/errormap.o
 
 ######################################################################
 # now the rules...

Modified: trunk/source/passdb/pdb_smbpasswd.c
===================================================================
--- trunk/source/passdb/pdb_smbpasswd.c	2006-06-05 20:09:24 UTC (rev 16048)
+++ trunk/source/passdb/pdb_smbpasswd.c	2006-06-05 20:19:22 UTC (rev 16049)
@@ -584,7 +584,8 @@
  Routine to add an entry to the smbpasswd file.
 *************************************************************************/
 
-static BOOL add_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state, struct smb_passwd *newpwd)
+static NTSTATUS add_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state,
+				     struct smb_passwd *newpwd)
 {
 	const char *pfile = smbpasswd_state->smbpasswd_file;
 	struct smb_passwd *pwd = NULL;
@@ -605,7 +606,7 @@
 
 	if (fp == NULL) {
 		DEBUG(0, ("add_smbfilepwd_entry: unable to open file.\n"));
-		return False;
+		return map_nt_error_from_unix(errno);
 	}
 
 	/*
@@ -616,7 +617,7 @@
 		if (strequal(newpwd->smb_name, pwd->smb_name)) {
 			DEBUG(0, ("add_smbfilepwd_entry: entry with name %s already exists\n", pwd->smb_name));
 			endsmbfilepwent(fp, &smbpasswd_state->pw_file_lock_depth);
-			return False;
+			return NT_STATUS_USER_EXISTS;
 		}
 	}
 
@@ -630,17 +631,18 @@
 	fd = fileno(fp);
 
 	if((offpos = sys_lseek(fd, 0, SEEK_END)) == -1) {
+		NTSTATUS result = map_nt_error_from_unix(errno);
 		DEBUG(0, ("add_smbfilepwd_entry(sys_lseek): Failed to add entry for user %s to file %s. \
 Error was %s\n", newpwd->smb_name, pfile, strerror(errno)));
 		endsmbfilepwent(fp, &smbpasswd_state->pw_file_lock_depth);
-		return False;
+		return result;
 	}
 
 	if((new_entry = format_new_smbpasswd_entry(newpwd)) == NULL) {
 		DEBUG(0, ("add_smbfilepwd_entry(malloc): Failed to add entry for user %s to file %s. \
 Error was %s\n", newpwd->smb_name, pfile, strerror(errno)));
 		endsmbfilepwent(fp, &smbpasswd_state->pw_file_lock_depth);
-		return False;
+		return NT_STATUS_NO_MEMORY;
 	}
 
 	new_entry_length = strlen(new_entry);
@@ -651,6 +653,7 @@
 #endif
 
 	if ((wr_len = write(fd, new_entry, new_entry_length)) != new_entry_length) {
+		NTSTATUS result = map_nt_error_from_unix(errno);
 		DEBUG(0, ("add_smbfilepwd_entry(write): %d Failed to add entry for user %s to file %s. \
 Error was %s\n", wr_len, newpwd->smb_name, pfile, strerror(errno)));
 
@@ -663,12 +666,12 @@
 
 		endsmbfilepwent(fp, &smbpasswd_state->pw_file_lock_depth);
 		free(new_entry);
-		return False;
+		return result;
 	}
 
 	free(new_entry);
 	endsmbfilepwent(fp, &smbpasswd_state->pw_file_lock_depth);
-	return True;
+	return NT_STATUS_OK;
 }
 
 /************************************************************************
@@ -1423,11 +1426,7 @@
 	}
 	
 	/* add the entry */
-	if(!add_smbfilepwd_entry(smbpasswd_state, &smb_pw)) {
-		return NT_STATUS_UNSUCCESSFUL;
-	}
-	
-	return NT_STATUS_OK;
+	return add_smbfilepwd_entry(smbpasswd_state, &smb_pw);
 }
 
 static NTSTATUS smbpasswd_update_sam_account(struct pdb_methods *my_methods, struct samu *sampass)



More information about the samba-cvs mailing list