mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
Adjust samba 3 to the new gpo API. Still untested code.
Signed-off-by: Günther Deschner <gd@samba.org>
This commit is contained in:
parent
b939638dc7
commit
3e010e3eb8
@ -662,9 +662,9 @@ void debug_gpext_header(int lvl,
|
||||
DEBUGADD(lvl,("\tsnapin: %s (%s)\n", snapin_guid,
|
||||
cse_snapin_gpo_guid_string_to_name(snapin_guid)));
|
||||
|
||||
flags_str = gpo_flag_str(flags);
|
||||
flags_str = gpo_flag_str(NULL, flags);
|
||||
DEBUGADD(lvl,("\tflags: 0x%08x %s\n", flags, flags_str));
|
||||
SAFE_FREE(flags_str);
|
||||
TALLOC_FREE(flags_str);
|
||||
}
|
||||
|
||||
NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads,
|
||||
|
12
libgpo/gpo.h
12
libgpo/gpo.h
@ -22,6 +22,8 @@
|
||||
|
||||
#if _SAMBA_BUILD_ == 4
|
||||
#include "source4/libgpo/ads_convenience.h"
|
||||
#else
|
||||
struct loadparm_context;
|
||||
#endif
|
||||
|
||||
enum GPO_LINK_TYPE {
|
||||
@ -169,7 +171,7 @@ struct cli_state;
|
||||
/* The following definitions come from libgpo/gpo_fetch.c */
|
||||
|
||||
NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
const char *file_sys_path,
|
||||
char **server,
|
||||
char **service,
|
||||
@ -178,7 +180,7 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
|
||||
ADS_STRUCT *ads,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct GROUP_POLICY_OBJECT *gpo);
|
||||
NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx,
|
||||
const char *unix_path,
|
||||
@ -255,18 +257,18 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
||||
uint32_t flags);
|
||||
NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct loadparm_context *lp_ctx,
|
||||
uint32_t flags,
|
||||
struct GROUP_POLICY_OBJECT *gpo);
|
||||
NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct loadparm_context *lp_ctx,
|
||||
uint32_t flags,
|
||||
struct GROUP_POLICY_OBJECT *gpo_list);
|
||||
NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct GROUP_POLICY_OBJECT *gpo,
|
||||
char **unix_path);
|
||||
char *gpo_flag_str(TALLOC_CTX *mem_ctx, uint32_t flags);
|
||||
|
@ -37,7 +37,7 @@
|
||||
****************************************************************/
|
||||
|
||||
NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
const char *file_sys_path,
|
||||
char **server,
|
||||
char **service,
|
||||
@ -73,7 +73,7 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||
|
||||
if ((path = talloc_asprintf(mem_ctx,
|
||||
"%s/%s",
|
||||
cache_path,
|
||||
cache_dir,
|
||||
file_sys_path)) == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
@ -98,21 +98,21 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||
****************************************************************/
|
||||
|
||||
static NTSTATUS gpo_prepare_local_store(TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
const char *unix_path)
|
||||
{
|
||||
char *current_dir;
|
||||
char *tok;
|
||||
|
||||
current_dir = talloc_strdup(mem_ctx, cache_path);
|
||||
current_dir = talloc_strdup(mem_ctx, cache_dir);
|
||||
NT_STATUS_HAVE_NO_MEMORY(current_dir);
|
||||
|
||||
if ((mkdir(cache_path, 0644)) < 0 && errno != EEXIST) {
|
||||
if ((mkdir(cache_dir, 0644)) < 0 && errno != EEXIST) {
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
while (next_token_talloc(mem_ctx, &unix_path, &tok, "/")) {
|
||||
if (strequal(tok, GPO_CACHE_DIR)) {
|
||||
if (strequal(tok, cache_dir)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -151,8 +151,7 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads, struct loadparm_context *lp_
|
||||
DEBUG(10,("check_refresh_gpo: "
|
||||
"failed to connect: %s\n",
|
||||
nt_errstr(result)));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
*(struct cli_state **) ret_cli = cli;
|
||||
#else
|
||||
@ -191,7 +190,7 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads, struct loadparm_context *lp_
|
||||
NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
|
||||
ADS_STRUCT *ads,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct GROUP_POLICY_OBJECT *gpo)
|
||||
{
|
||||
NTSTATUS result;
|
||||
@ -204,7 +203,7 @@ NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
|
||||
#endif
|
||||
|
||||
|
||||
result = gpo_explode_filesyspath(mem_ctx, cache_path, gpo->file_sys_path,
|
||||
result = gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
|
||||
&server, &service, &nt_path,
|
||||
&unix_path);
|
||||
NT_STATUS_NOT_OK_RETURN(result);
|
||||
@ -213,7 +212,7 @@ NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
|
||||
result = gpo_connect_server(ads, lp_ctx, server, service, &cli);
|
||||
|
||||
|
||||
result = gpo_prepare_local_store(mem_ctx, cache_path, unix_path);
|
||||
result = gpo_prepare_local_store(mem_ctx, cache_dir, unix_path);
|
||||
NT_STATUS_NOT_OK_RETURN(result);
|
||||
|
||||
unix_ini_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
|
||||
|
@ -551,8 +551,9 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
||||
struct gp_extension *gp_ext = NULL;
|
||||
struct registry_key *root_key = NULL;
|
||||
struct gp_registry_context *reg_ctx = NULL;
|
||||
#if 0
|
||||
WERROR werr;
|
||||
|
||||
#endif
|
||||
status = ADS_ERROR_NT(init_gp_extensions(mem_ctx));
|
||||
if (!ADS_ERR_OK(status)) {
|
||||
return status;
|
||||
@ -574,11 +575,11 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
||||
token,
|
||||
®_ctx);
|
||||
}
|
||||
#endif
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
talloc_free(reg_ctx);
|
||||
return ADS_ERROR_NT(werror_to_ntstatus(werr));
|
||||
}
|
||||
#endif
|
||||
|
||||
root_key = reg_ctx->curr_key;
|
||||
|
||||
@ -626,7 +627,7 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
||||
|
||||
NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct loadparm_context *lp_ctx,
|
||||
uint32_t flags,
|
||||
struct GROUP_POLICY_OBJECT *gpo)
|
||||
@ -639,7 +640,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
||||
uint32_t sysvol_gpt_version = 0;
|
||||
char *display_name = NULL;
|
||||
|
||||
result = gpo_explode_filesyspath(mem_ctx, cache_path, gpo->file_sys_path,
|
||||
result = gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
|
||||
&server, &share, &nt_path, &unix_path);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
@ -667,7 +668,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
||||
|
||||
DEBUG(1,("check_refresh_gpo: need to refresh GPO\n"));
|
||||
|
||||
result = gpo_fetch_files(mem_ctx, ads, lp_ctx, cache_path, gpo);
|
||||
result = gpo_fetch_files(mem_ctx, ads, lp_ctx, cache_dir, gpo);
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
goto out;
|
||||
}
|
||||
@ -713,7 +714,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
||||
|
||||
NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct loadparm_context *lp_ctx,
|
||||
uint32_t flags,
|
||||
struct GROUP_POLICY_OBJECT *gpo_list)
|
||||
@ -727,7 +728,7 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
|
||||
|
||||
for (gpo = gpo_list; gpo; gpo = gpo->next) {
|
||||
|
||||
result = check_refresh_gpo(ads, mem_ctx, cache_path, lp_ctx, flags, gpo);
|
||||
result = check_refresh_gpo(ads, mem_ctx, cache_dir, lp_ctx, flags, gpo);
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
goto out;
|
||||
}
|
||||
@ -745,12 +746,12 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
|
||||
****************************************************************/
|
||||
|
||||
NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
|
||||
const char *cache_path,
|
||||
const char *cache_dir,
|
||||
struct GROUP_POLICY_OBJECT *gpo,
|
||||
char **unix_path)
|
||||
{
|
||||
char *server, *share, *nt_path;
|
||||
return gpo_explode_filesyspath(mem_ctx, cache_path, gpo->file_sys_path,
|
||||
return gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
|
||||
&server, &share, &nt_path, unix_path);
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ LIBADDNS_OBJ = $(LIBADDNS_OBJ0) $(SOCKET_WRAPPER_OBJ)
|
||||
|
||||
GPEXT_OBJ = ../libgpo/gpext/gpext.o @GPEXT_STATIC@
|
||||
|
||||
LIBGPO_OBJ0 = libgpo/gpo_ldap.o libgpo/gpo_ini.o ../libgpo/gpo_util.o \
|
||||
LIBGPO_OBJ0 = ../libgpo/gpo_ldap.o libgpo/gpo_ini.o ../libgpo/gpo_util.o \
|
||||
../libgpo/gpo_fetch.o libgpo/gpo_filesync.o ../libgpo/gpo_sec.o \
|
||||
libgpo/gpo_reg.o \
|
||||
$(GPEXT_OBJ)
|
||||
|
@ -73,7 +73,7 @@ static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **arg
|
||||
|
||||
d_printf("* fetching token ");
|
||||
if (uac & UF_WORKSTATION_TRUST_ACCOUNT) {
|
||||
status = gp_get_machine_token(ads, mem_ctx, dn, &token);
|
||||
status = gp_get_machine_token(ads, mem_ctx, NULL, dn, &token);
|
||||
} else {
|
||||
status = ads_get_sid_token(ads, mem_ctx, dn, &token);
|
||||
}
|
||||
@ -94,6 +94,8 @@ static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **arg
|
||||
|
||||
d_printf("* refreshing Group Policy Data ");
|
||||
if (!NT_STATUS_IS_OK(result = check_refresh_gpo_list(ads, mem_ctx,
|
||||
cache_path(GPO_CACHE_DIR),
|
||||
NULL,
|
||||
flags,
|
||||
gpo_list))) {
|
||||
d_printf("failed: %s\n", nt_errstr(result));
|
||||
@ -326,7 +328,7 @@ static int net_ads_gpo_list(struct net_context *c, int argc, const char **argv)
|
||||
argv[0], dn);
|
||||
|
||||
if (uac & UF_WORKSTATION_TRUST_ACCOUNT) {
|
||||
status = gp_get_machine_token(ads, mem_ctx, dn, &token);
|
||||
status = gp_get_machine_token(ads, mem_ctx, NULL, dn, &token);
|
||||
} else {
|
||||
status = ads_get_sid_token(ads, mem_ctx, dn, &token);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user