126-net_rpc_samsync.c.diff   [plain text]


Index: samba/source/utils/net_rpc_samsync.c
===================================================================
--- samba/source/utils/net_rpc_samsync.c.orig
+++ samba/source/utils/net_rpc_samsync.c
@@ -477,7 +477,7 @@ static NTSTATUS fetch_account_info(uint3
 	struct group *grp;
 	DOM_SID user_sid;
 	DOM_SID group_sid;
-	struct passwd *passwd;
+	struct passwd *passwd=NULL;
 	fstring sid_string;
 
 	fstrcpy(account, unistr2_static(&delta->uni_acct_name));
@@ -513,11 +513,16 @@ static NTSTATUS fetch_account_info(uint3
 			}
 		}
 		
-		/* try and find the possible unix account again */
-		if ( !(passwd = Get_Pwnam(account)) ) {
-			d_fprintf(stderr, "Could not create posix account info for '%s'\n", account);
-			nt_ret = NT_STATUS_NO_SUCH_USER;
-			goto done;
+		/* Try and find the possible unix account again, unless we are
+		 * in Open Directory mode and it's a machine account.
+		 */
+		if (lp_opendirectory() && !strchr_m(account, '$')) {
+			if ( !(passwd = Get_Pwnam(account)) ) {
+				d_fprintf(stderr, "Could not create posix account info for '%s'\n",
+					account);
+				nt_ret = NT_STATUS_NO_SUCH_USER;
+				goto done;
+			}
 		}
 	}
 	
@@ -556,7 +561,7 @@ static NTSTATUS fetch_account_info(uint3
 		DEBUG(0, ("Primary group of %s has no mapping!\n",
 			  pdb_get_username(sam_account)));
 	} else {
-		if (map.gid != passwd->pw_gid) {
+		if (passwd && (map.gid != passwd->pw_gid)) {
 			if (!(grp = getgrgid(map.gid))) {
 				DEBUG(0, ("Could not find unix group %lu for user %s (group SID=%s)\n", 
 					  (unsigned long)map.gid, pdb_get_username(sam_account), sid_string_static(&group_sid)));