예제 #1
0
static NTSTATUS make_system_session_info_from_pw(TALLOC_CTX *mem_ctx,
						 struct passwd *pwd,
						 struct auth_serversupplied_info **server_info)
{
	const char *domain = global_myname();
	struct netr_SamInfo3 info3;
	TALLOC_CTX *tmp_ctx;
	NTSTATUS status;

	tmp_ctx = talloc_stackframe();
	if (tmp_ctx == NULL) {
		return NT_STATUS_NO_MEMORY;
	}

	ZERO_STRUCT(info3);

	status = get_system_info3(tmp_ctx, pwd, &info3);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Failed creating system info3 with %s\n",
			  nt_errstr(status)));
		goto done;
	}

	status = make_server_info_info3(mem_ctx,
					pwd->pw_name,
					domain,
					server_info,
					&info3);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("make_server_info_info3 failed with %s\n",
			  nt_errstr(status)));
		goto done;
	}

	(*server_info)->nss_token = true;

	/* Now turn the server_info into a session_info with the full token etc */
	status = create_local_token(*server_info);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("create_local_token failed: %s\n",
			  nt_errstr(status)));
		goto done;
	}

	status = NT_STATUS_OK;
done:
	TALLOC_FREE(tmp_ctx);
	return status;
}
예제 #2
0
파일: auth_util.c 프로젝트: AIdrifter/samba
static NTSTATUS make_new_session_info_system(TALLOC_CTX *mem_ctx,
					    struct auth_session_info **session_info)
{
	NTSTATUS status;
	struct auth_serversupplied_info *server_info;
	TALLOC_CTX *tmp_ctx;

	tmp_ctx = talloc_stackframe();
	if (tmp_ctx == NULL) {
		return NT_STATUS_NO_MEMORY;
	}

	server_info = make_server_info(tmp_ctx);
	if (!server_info) {
		status = NT_STATUS_NO_MEMORY;
		DEBUG(0, ("failed making server_info\n"));
		goto done;
	}

	server_info->info3 = talloc_zero(server_info, struct netr_SamInfo3);
	if (!server_info->info3) {
		status = NT_STATUS_NO_MEMORY;
		DEBUG(0, ("talloc failed setting info3\n"));
		goto done;
	}

	status = get_system_info3(server_info, server_info->info3);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Failed creating system info3 with %s\n",
			  nt_errstr(status)));
		goto done;
	}

	server_info->utok.uid = sec_initial_uid();
	server_info->utok.gid = sec_initial_gid();
	server_info->unix_name = talloc_asprintf(server_info,
						 "NT AUTHORITY%cSYSTEM",
						 *lp_winbind_separator());

	if (!server_info->unix_name) {
		status = NT_STATUS_NO_MEMORY;
		DEBUG(0, ("talloc_asprintf failed setting unix_name\n"));
		goto done;
	}

	server_info->security_token = talloc_zero(server_info, struct security_token);
	if (!server_info->security_token) {
		status = NT_STATUS_NO_MEMORY;
		DEBUG(0, ("talloc failed setting security token\n"));
		goto done;
	}

	status = add_sid_to_array_unique(server_info->security_token->sids,
					 &global_sid_System,
					 &server_info->security_token->sids,
					 &server_info->security_token->num_sids);
	if (!NT_STATUS_IS_OK(status)) {
		goto done;
	}

	/* SYSTEM has all privilages */
	server_info->security_token->privilege_mask = ~0;

	/* Now turn the server_info into a session_info with the full token etc */
	status = create_local_token(mem_ctx, server_info, NULL, "SYSTEM", session_info);
	talloc_free(server_info);

	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("create_local_token failed: %s\n",
			  nt_errstr(status)));
		goto done;
	}

	talloc_steal(mem_ctx, *session_info);

done:
	TALLOC_FREE(tmp_ctx);
	return status;
}