mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
r23770: Some minor cleanups in libgpo
(including some valgrind errors, uninitialized vars, etc.)
Guenther
(This used to be commit 1a2878db2d
)
This commit is contained in:
parent
5e4962d9e7
commit
5512dacbca
@ -24,13 +24,12 @@
|
|||||||
explode the GPO CIFS URI into their components
|
explode the GPO CIFS URI into their components
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
NTSTATUS ads_gpo_explode_filesyspath(ADS_STRUCT *ads,
|
NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
const char *file_sys_path,
|
||||||
const char *file_sys_path,
|
char **server,
|
||||||
char **server,
|
char **service,
|
||||||
char **service,
|
char **nt_path,
|
||||||
char **nt_path,
|
char **unix_path)
|
||||||
char **unix_path)
|
|
||||||
{
|
{
|
||||||
fstring tok;
|
fstring tok;
|
||||||
pstring path;
|
pstring path;
|
||||||
@ -40,6 +39,10 @@ NTSTATUS ads_gpo_explode_filesyspath(ADS_STRUCT *ads,
|
|||||||
*nt_path = NULL;
|
*nt_path = NULL;
|
||||||
*unix_path = NULL;
|
*unix_path = NULL;
|
||||||
|
|
||||||
|
if (!file_sys_path) {
|
||||||
|
return NT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!next_token(&file_sys_path, tok, "\\", sizeof(tok))) {
|
if (!next_token(&file_sys_path, tok, "\\", sizeof(tok))) {
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@ -76,9 +79,8 @@ NTSTATUS ads_gpo_explode_filesyspath(ADS_STRUCT *ads,
|
|||||||
prepare the local disc storage for "unix_path"
|
prepare the local disc storage for "unix_path"
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
NTSTATUS ads_gpo_prepare_local_store(ADS_STRUCT *ads,
|
static NTSTATUS gpo_prepare_local_store(TALLOC_CTX *mem_ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
const char *unix_path)
|
||||||
const char *unix_path)
|
|
||||||
{
|
{
|
||||||
const char *top_dir = lock_path(GPO_CACHE_DIR);
|
const char *top_dir = lock_path(GPO_CACHE_DIR);
|
||||||
char *current_dir;
|
char *current_dir;
|
||||||
@ -115,21 +117,20 @@ NTSTATUS ads_gpo_prepare_local_store(ADS_STRUCT *ads,
|
|||||||
download a full GPO via CIFS
|
download a full GPO via CIFS
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
NTSTATUS ads_fetch_gpo_files(ADS_STRUCT *ads,
|
NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
struct cli_state *cli,
|
||||||
struct cli_state *cli,
|
struct GROUP_POLICY_OBJECT *gpo)
|
||||||
struct GROUP_POLICY_OBJECT *gpo)
|
|
||||||
{
|
{
|
||||||
NTSTATUS result;
|
NTSTATUS result;
|
||||||
char *server, *service, *nt_path, *unix_path, *nt_ini_path, *unix_ini_path;
|
char *server, *service, *nt_path, *unix_path, *nt_ini_path, *unix_ini_path;
|
||||||
|
|
||||||
result = ads_gpo_explode_filesyspath(ads, mem_ctx, gpo->file_sys_path,
|
result = gpo_explode_filesyspath(mem_ctx, gpo->file_sys_path,
|
||||||
&server, &service, &nt_path, &unix_path);
|
&server, &service, &nt_path, &unix_path);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ads_gpo_prepare_local_store(ads, mem_ctx, unix_path);
|
result = gpo_prepare_local_store(mem_ctx, unix_path);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -161,23 +162,26 @@ NTSTATUS ads_fetch_gpo_files(ADS_STRUCT *ads,
|
|||||||
get the locally stored gpt.ini version number
|
get the locally stored gpt.ini version number
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
NTSTATUS ads_gpo_get_sysvol_gpt_version(ADS_STRUCT *ads,
|
NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
const char *unix_path,
|
||||||
const char *unix_path,
|
uint32 *sysvol_version,
|
||||||
uint32 *sysvol_version,
|
char **display_name)
|
||||||
char **display_name)
|
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
uint32 version;
|
uint32 version = 0;
|
||||||
char *local_path = NULL;
|
char *local_path = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
|
if (!unix_path) {
|
||||||
|
return NT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
local_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
|
local_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
|
||||||
NT_STATUS_HAVE_NO_MEMORY(local_path);
|
NT_STATUS_HAVE_NO_MEMORY(local_path);
|
||||||
|
|
||||||
status = parse_gpt_ini(mem_ctx, local_path, &version, &name);
|
status = parse_gpt_ini(mem_ctx, local_path, &version, &name);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(10,("ads_gpo_get_sysvol_gpt_version: failed to parse ini [%s]: %s\n",
|
DEBUG(10,("gpo_get_sysvol_gpt_version: failed to parse ini [%s]: %s\n",
|
||||||
unix_path, nt_errstr(status)));
|
unix_path, nt_errstr(status)));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,24 @@
|
|||||||
|
|
||||||
ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
||||||
const char *extension_raw,
|
const char *extension_raw,
|
||||||
struct GP_EXT *gp_ext)
|
struct GP_EXT **gp_ext)
|
||||||
{
|
{
|
||||||
|
struct GP_EXT *ext = NULL;
|
||||||
char **ext_list;
|
char **ext_list;
|
||||||
char **ext_strings = NULL;
|
char **ext_strings = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!extension_raw) {
|
||||||
|
goto parse_error;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(20,("ads_parse_gp_ext: %s\n", extension_raw));
|
DEBUG(20,("ads_parse_gp_ext: %s\n", extension_raw));
|
||||||
|
|
||||||
|
ext = TALLOC_ZERO_P(mem_ctx, struct GP_EXT);
|
||||||
|
if (!ext) {
|
||||||
|
goto parse_error;
|
||||||
|
}
|
||||||
|
|
||||||
ext_list = str_list_make_talloc(mem_ctx, extension_raw, "]");
|
ext_list = str_list_make_talloc(mem_ctx, extension_raw, "]");
|
||||||
if (ext_list == NULL) {
|
if (ext_list == NULL) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
@ -45,28 +55,28 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
/* no op */
|
/* no op */
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_ext->num_exts = i;
|
ext->num_exts = i;
|
||||||
|
|
||||||
if (gp_ext->num_exts) {
|
if (ext->num_exts) {
|
||||||
gp_ext->extensions = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts);
|
ext->extensions = TALLOC_ZERO_ARRAY(mem_ctx, char *, ext->num_exts);
|
||||||
gp_ext->extensions_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts);
|
ext->extensions_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, ext->num_exts);
|
||||||
gp_ext->snapins = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts);
|
ext->snapins = TALLOC_ZERO_ARRAY(mem_ctx, char *, ext->num_exts);
|
||||||
gp_ext->snapins_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts);
|
ext->snapins_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, ext->num_exts);
|
||||||
} else {
|
} else {
|
||||||
gp_ext->extensions = NULL;
|
ext->extensions = NULL;
|
||||||
gp_ext->extensions_guid = NULL;
|
ext->extensions_guid = NULL;
|
||||||
gp_ext->snapins = NULL;
|
ext->snapins = NULL;
|
||||||
gp_ext->snapins_guid = NULL;
|
ext->snapins_guid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gp_ext->extensions == NULL || gp_ext->extensions_guid == NULL ||
|
ext->gp_extension = talloc_strdup(mem_ctx, extension_raw);
|
||||||
gp_ext->snapins == NULL || gp_ext->snapins_guid == NULL ||
|
|
||||||
gp_ext->gp_extension == NULL) {
|
if (ext->extensions == NULL || ext->extensions_guid == NULL ||
|
||||||
|
ext->snapins == NULL || ext->snapins_guid == NULL ||
|
||||||
|
ext->gp_extension == NULL) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_ext->gp_extension = talloc_strdup(mem_ctx, extension_raw);
|
|
||||||
|
|
||||||
for (i = 0; ext_list[i] != NULL; i++) {
|
for (i = 0; ext_list[i] != NULL; i++) {
|
||||||
|
|
||||||
int k;
|
int k;
|
||||||
@ -95,11 +105,11 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
q++;
|
q++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_ext->extensions[i] = talloc_strdup(mem_ctx, cse_gpo_guid_string_to_name(q));
|
ext->extensions[i] = talloc_strdup(mem_ctx, cse_gpo_guid_string_to_name(q));
|
||||||
gp_ext->extensions_guid[i] = talloc_strdup(mem_ctx, q);
|
ext->extensions_guid[i] = talloc_strdup(mem_ctx, q);
|
||||||
|
|
||||||
/* we might have no name for the guid */
|
/* we might have no name for the guid */
|
||||||
if (gp_ext->extensions_guid[i] == NULL) {
|
if (ext->extensions_guid[i] == NULL) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,11 +122,11 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: theoretically there could be more than one snapin per extension */
|
/* FIXME: theoretically there could be more than one snapin per extension */
|
||||||
gp_ext->snapins[i] = talloc_strdup(mem_ctx, cse_snapin_gpo_guid_string_to_name(m));
|
ext->snapins[i] = talloc_strdup(mem_ctx, cse_snapin_gpo_guid_string_to_name(m));
|
||||||
gp_ext->snapins_guid[i] = talloc_strdup(mem_ctx, m);
|
ext->snapins_guid[i] = talloc_strdup(mem_ctx, m);
|
||||||
|
|
||||||
/* we might have no name for the guid */
|
/* we might have no name for the guid */
|
||||||
if (gp_ext->snapins_guid[i] == NULL) {
|
if (ext->snapins_guid[i] == NULL) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,6 +139,8 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
str_list_free_talloc(mem_ctx, &ext_strings);
|
str_list_free_talloc(mem_ctx, &ext_strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*gp_ext = ext;
|
||||||
|
|
||||||
return ADS_ERROR(LDAP_SUCCESS);
|
return ADS_ERROR(LDAP_SUCCESS);
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
@ -146,15 +158,15 @@ parse_error:
|
|||||||
parse the raw link string into a GP_LINK structure
|
parse the raw link string into a GP_LINK structure
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS ads_parse_gplink(TALLOC_CTX *mem_ctx,
|
static ADS_STATUS gpo_parse_gplink(TALLOC_CTX *mem_ctx,
|
||||||
const char *gp_link_raw,
|
const char *gp_link_raw,
|
||||||
uint32 options,
|
uint32 options,
|
||||||
struct GP_LINK *gp_link)
|
struct GP_LINK *gp_link)
|
||||||
{
|
{
|
||||||
char **link_list;
|
char **link_list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUG(10,("ads_parse_gplink: gPLink: %s\n", gp_link_raw));
|
DEBUG(10,("gpo_parse_gplink: gPLink: %s\n", gp_link_raw));
|
||||||
|
|
||||||
link_list = str_list_make_talloc(mem_ctx, gp_link_raw, "]");
|
link_list = str_list_make_talloc(mem_ctx, gp_link_raw, "]");
|
||||||
if (link_list == NULL) {
|
if (link_list == NULL) {
|
||||||
@ -186,7 +198,7 @@ ADS_STATUS ads_parse_gplink(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
DEBUGADD(10,("ads_parse_gplink: processing link #%d\n", i));
|
DEBUGADD(10,("gpo_parse_gplink: processing link #%d\n", i));
|
||||||
|
|
||||||
q = link_list[i];
|
q = link_list[i];
|
||||||
if (q[0] == '[') {
|
if (q[0] == '[') {
|
||||||
@ -207,8 +219,8 @@ ADS_STATUS ads_parse_gplink(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
gp_link->link_opts[i] = atoi(p + 1);
|
gp_link->link_opts[i] = atoi(p + 1);
|
||||||
|
|
||||||
DEBUGADD(10,("ads_parse_gplink: link: %s\n", gp_link->link_names[i]));
|
DEBUGADD(10,("gpo_parse_gplink: link: %s\n", gp_link->link_names[i]));
|
||||||
DEBUGADD(10,("ads_parse_gplink: opt: %d\n", gp_link->link_opts[i]));
|
DEBUGADD(10,("gpo_parse_gplink: opt: %d\n", gp_link->link_opts[i]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +274,7 @@ ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads,
|
|||||||
return ADS_ERROR(LDAP_NO_SUCH_ATTRIBUTE);
|
return ADS_ERROR(LDAP_NO_SUCH_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* perfectly leggal to have no options */
|
/* perfectly legal to have no options */
|
||||||
if (!ads_pull_uint32(ads, res, "gPOptions", &gp_options)) {
|
if (!ads_pull_uint32(ads, res, "gPOptions", &gp_options)) {
|
||||||
DEBUG(10,("ads_get_gpo_link: no 'gPOptions' attribute found\n"));
|
DEBUG(10,("ads_get_gpo_link: no 'gPOptions' attribute found\n"));
|
||||||
gp_options = 0;
|
gp_options = 0;
|
||||||
@ -270,7 +282,7 @@ ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads,
|
|||||||
|
|
||||||
ads_msgfree(ads, res);
|
ads_msgfree(ads, res);
|
||||||
|
|
||||||
return ads_parse_gplink(mem_ctx, gp_link, gp_options, gp_link_struct);
|
return gpo_parse_gplink(mem_ctx, gp_link, gp_options, gp_link_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
@ -518,14 +530,14 @@ ADS_STATUS ads_get_gpo(ADS_STRUCT *ads,
|
|||||||
add a gplink to the GROUP_POLICY_OBJECT linked list
|
add a gplink to the GROUP_POLICY_OBJECT linked list
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS add_gplink_to_gpo_list(ADS_STRUCT *ads,
|
static ADS_STATUS add_gplink_to_gpo_list(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct GROUP_POLICY_OBJECT **gpo_list,
|
struct GROUP_POLICY_OBJECT **gpo_list,
|
||||||
const char *link_dn,
|
const char *link_dn,
|
||||||
struct GP_LINK *gp_link,
|
struct GP_LINK *gp_link,
|
||||||
enum GPO_LINK_TYPE link_type,
|
enum GPO_LINK_TYPE link_type,
|
||||||
BOOL only_add_forced_gpos,
|
BOOL only_add_forced_gpos,
|
||||||
struct GPO_SID_TOKEN *token)
|
struct GPO_SID_TOKEN *token)
|
||||||
{
|
{
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
int i;
|
int i;
|
||||||
@ -581,10 +593,10 @@ ADS_STATUS add_gplink_to_gpo_list(ADS_STRUCT *ads,
|
|||||||
/****************************************************************
|
/****************************************************************
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS ads_get_gpo_sid_token(ADS_STRUCT *ads,
|
static ADS_STATUS ads_get_gpo_sid_token(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
const char *dn,
|
const char *dn,
|
||||||
struct GPO_SID_TOKEN **token)
|
struct GPO_SID_TOKEN **token)
|
||||||
{
|
{
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
DOM_SID object_sid;
|
DOM_SID object_sid;
|
||||||
@ -684,11 +696,11 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
|
|||||||
|
|
||||||
status = ads_get_gpo_link(ads, mem_ctx, site_dn, &gp_link);
|
status = ads_get_gpo_link(ads, mem_ctx, site_dn, &gp_link);
|
||||||
if (ADS_ERR_OK(status)) {
|
if (ADS_ERR_OK(status)) {
|
||||||
|
|
||||||
if (DEBUGLEVEL >= 100) {
|
if (DEBUGLEVEL >= 100) {
|
||||||
dump_gplink(ads, mem_ctx, &gp_link);
|
dump_gplink(ads, mem_ctx, &gp_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = add_gplink_to_gpo_list(ads, mem_ctx, gpo_list,
|
status = add_gplink_to_gpo_list(ads, mem_ctx, gpo_list,
|
||||||
site_dn, &gp_link, GP_LINK_SITE,
|
site_dn, &gp_link, GP_LINK_SITE,
|
||||||
add_only_forced_gpos,
|
add_only_forced_gpos,
|
||||||
@ -696,11 +708,11 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
|
|||||||
if (!ADS_ERR_OK(status)) {
|
if (!ADS_ERR_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & GPO_LIST_FLAG_SITEONLY) {
|
if (flags & GPO_LIST_FLAG_SITEONLY) {
|
||||||
return ADS_ERROR(LDAP_SUCCESS);
|
return ADS_ERROR(LDAP_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* inheritance can't be blocked at the site level */
|
/* inheritance can't be blocked at the site level */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,54 +221,71 @@ void dump_gpo(TALLOC_CTX *mem_ctx, struct GROUP_POLICY_OBJECT *gpo, int debuglev
|
|||||||
DEBUGADD(lvl,("link:\t\t\t%s\n", gpo->link));
|
DEBUGADD(lvl,("link:\t\t\t%s\n", gpo->link));
|
||||||
DEBUGADD(lvl,("link_type:\t\t%d ", gpo->link_type));
|
DEBUGADD(lvl,("link_type:\t\t%d ", gpo->link_type));
|
||||||
switch (gpo->link_type) {
|
switch (gpo->link_type) {
|
||||||
case GP_LINK_UNKOWN:
|
case GP_LINK_UNKOWN:
|
||||||
DEBUGADD(lvl,("GP_LINK_UNKOWN\n"));
|
DEBUGADD(lvl,("GP_LINK_UNKOWN\n"));
|
||||||
break;
|
break;
|
||||||
case GP_LINK_OU:
|
case GP_LINK_OU:
|
||||||
DEBUGADD(lvl,("GP_LINK_OU\n"));
|
DEBUGADD(lvl,("GP_LINK_OU\n"));
|
||||||
break;
|
break;
|
||||||
case GP_LINK_DOMAIN:
|
case GP_LINK_DOMAIN:
|
||||||
DEBUGADD(lvl,("GP_LINK_DOMAIN\n"));
|
DEBUGADD(lvl,("GP_LINK_DOMAIN\n"));
|
||||||
break;
|
break;
|
||||||
case GP_LINK_SITE:
|
case GP_LINK_SITE:
|
||||||
DEBUGADD(lvl,("GP_LINK_SITE\n"));
|
DEBUGADD(lvl,("GP_LINK_SITE\n"));
|
||||||
break;
|
break;
|
||||||
case GP_LINK_MACHINE:
|
case GP_LINK_MACHINE:
|
||||||
DEBUGADD(lvl,("GP_LINK_MACHINE\n"));
|
DEBUGADD(lvl,("GP_LINK_MACHINE\n"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUGADD(lvl,("machine_extensions:\t%s\n", gpo->machine_extensions));
|
||||||
|
|
||||||
if (gpo->machine_extensions) {
|
if (gpo->machine_extensions) {
|
||||||
|
|
||||||
struct GP_EXT gp_ext;
|
struct GP_EXT *gp_ext = NULL;
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
|
|
||||||
DEBUGADD(lvl,("machine_extensions:\t%s\n", gpo->machine_extensions));
|
|
||||||
|
|
||||||
status = ads_parse_gp_ext(mem_ctx, gpo->machine_extensions, &gp_ext);
|
status = ads_parse_gp_ext(mem_ctx, gpo->machine_extensions, &gp_ext);
|
||||||
if (!ADS_ERR_OK(status)) {
|
if (!ADS_ERR_OK(status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dump_gp_ext(&gp_ext, lvl);
|
dump_gp_ext(gp_ext, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUGADD(lvl,("user_extensions:\t%s\n", gpo->user_extensions));
|
||||||
|
|
||||||
if (gpo->user_extensions) {
|
if (gpo->user_extensions) {
|
||||||
|
|
||||||
struct GP_EXT gp_ext;
|
struct GP_EXT *gp_ext = NULL;
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
|
|
||||||
DEBUGADD(lvl,("user_extensions:\t%s\n", gpo->user_extensions));
|
|
||||||
|
|
||||||
status = ads_parse_gp_ext(mem_ctx, gpo->user_extensions, &gp_ext);
|
status = ads_parse_gp_ext(mem_ctx, gpo->user_extensions, &gp_ext);
|
||||||
if (!ADS_ERR_OK(status)) {
|
if (!ADS_ERR_OK(status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dump_gp_ext(&gp_ext, lvl);
|
dump_gp_ext(gp_ext, lvl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void dump_gpo_list(TALLOC_CTX *mem_ctx,
|
||||||
|
struct GROUP_POLICY_OBJECT *gpo_list,
|
||||||
|
int debuglevel)
|
||||||
|
{
|
||||||
|
struct GROUP_POLICY_OBJECT *gpo = NULL;
|
||||||
|
|
||||||
|
for (gpo = gpo_list; gpo; gpo = gpo->next) {
|
||||||
|
dump_gpo(mem_ctx, gpo, debuglevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
|
void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
|
||||||
{
|
{
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
@ -284,14 +301,14 @@ void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
|
|||||||
DEBUGADD(lvl,("gplink: %s\n", gp_link->gp_link));
|
DEBUGADD(lvl,("gplink: %s\n", gp_link->gp_link));
|
||||||
DEBUGADD(lvl,("gpopts: %d ", gp_link->gp_opts));
|
DEBUGADD(lvl,("gpopts: %d ", gp_link->gp_opts));
|
||||||
switch (gp_link->gp_opts) {
|
switch (gp_link->gp_opts) {
|
||||||
case GPOPTIONS_INHERIT:
|
case GPOPTIONS_INHERIT:
|
||||||
DEBUGADD(lvl,("GPOPTIONS_INHERIT\n"));
|
DEBUGADD(lvl,("GPOPTIONS_INHERIT\n"));
|
||||||
break;
|
break;
|
||||||
case GPOPTIONS_BLOCK_INHERITANCE:
|
case GPOPTIONS_BLOCK_INHERITANCE:
|
||||||
DEBUGADD(lvl,("GPOPTIONS_BLOCK_INHERITANCE\n"));
|
DEBUGADD(lvl,("GPOPTIONS_BLOCK_INHERITANCE\n"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGADD(lvl,("num links: %d\n", gp_link->num_links));
|
DEBUGADD(lvl,("num links: %d\n", gp_link->num_links));
|
||||||
@ -326,6 +343,9 @@ void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS process_extension_with_snapin(ADS_STRUCT *ads,
|
ADS_STATUS process_extension_with_snapin(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
const char *extension_guid,
|
const char *extension_guid,
|
||||||
@ -348,14 +368,17 @@ ADS_STATUS process_extension_with_snapin(ADS_STRUCT *ads,
|
|||||||
return ADS_SUCCESS;
|
return ADS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
|
ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct GROUP_POLICY_OBJECT *gpo,
|
struct GROUP_POLICY_OBJECT *gpo,
|
||||||
const char *extension_guid,
|
const char *extension_guid_filter,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
{
|
{
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
struct GP_EXT gp_ext;
|
struct GP_EXT *gp_ext = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (flags & GPO_LIST_FLAG_MACHINE) {
|
if (flags & GPO_LIST_FLAG_MACHINE) {
|
||||||
@ -388,14 +411,15 @@ ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<gp_ext.num_exts; i++) {
|
for (i=0; i<gp_ext->num_exts; i++) {
|
||||||
|
|
||||||
if (extension_guid && !strequal(extension_guid, gp_ext.extensions_guid[i])) {
|
if (extension_guid_filter && !strequal(extension_guid_filter, gp_ext->extensions_guid[i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = process_extension_with_snapin(ads, mem_ctx, gp_ext.extensions_guid[i],
|
status = process_extension_with_snapin(ads, mem_ctx,
|
||||||
gp_ext.snapins_guid[i]);
|
gp_ext->extensions_guid[i],
|
||||||
|
gp_ext->snapins_guid[i]);
|
||||||
if (!ADS_ERR_OK(status)) {
|
if (!ADS_ERR_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -404,16 +428,19 @@ ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
|
|||||||
return ADS_SUCCESS;
|
return ADS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct GROUP_POLICY_OBJECT **gpo_list,
|
struct GROUP_POLICY_OBJECT *gpo_list,
|
||||||
const char *extensions_guid,
|
const char *extensions_guid,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
{
|
{
|
||||||
ADS_STATUS status;
|
ADS_STATUS status;
|
||||||
struct GROUP_POLICY_OBJECT *gpo = *gpo_list;
|
struct GROUP_POLICY_OBJECT *gpo;
|
||||||
|
|
||||||
for (gpo = *gpo_list; gpo; gpo = gpo->next) {
|
for (gpo = gpo_list; gpo; gpo = gpo->next) {
|
||||||
|
|
||||||
status = gpo_process_a_gpo(ads, mem_ctx, gpo,
|
status = gpo_process_a_gpo(ads, mem_ctx, gpo,
|
||||||
extensions_guid, flags);
|
extensions_guid, flags);
|
||||||
@ -455,6 +482,9 @@ ADS_STATUS gpo_lockout_policy(ADS_STRUCT *ads,
|
|||||||
return ADS_ERROR_NT(NT_STATUS_NOT_IMPLEMENTED);
|
return ADS_ERROR_NT(NT_STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
|
ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
@ -512,7 +542,7 @@ ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
|
|||||||
|
|
||||||
ads_memfree(ads, dn);
|
ads_memfree(ads, dn);
|
||||||
|
|
||||||
status = gpo_process_gpo_list(ads, mem_ctx, &gpo_list,
|
status = gpo_process_gpo_list(ads, mem_ctx, gpo_list,
|
||||||
cse_gpo_name_to_guid_string("Security"),
|
cse_gpo_name_to_guid_string("Security"),
|
||||||
GPO_LIST_FLAG_MACHINE);
|
GPO_LIST_FLAG_MACHINE);
|
||||||
if (!ADS_ERR_OK(status)) {
|
if (!ADS_ERR_OK(status)) {
|
||||||
@ -533,22 +563,25 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
|||||||
struct cli_state **cli_out)
|
struct cli_state **cli_out)
|
||||||
{
|
{
|
||||||
NTSTATUS result;
|
NTSTATUS result;
|
||||||
char *server, *share, *nt_path, *unix_path;
|
char *server = NULL;
|
||||||
|
char *share = NULL;
|
||||||
|
char *nt_path = NULL;
|
||||||
|
char *unix_path = NULL;
|
||||||
uint32 sysvol_gpt_version = 0;
|
uint32 sysvol_gpt_version = 0;
|
||||||
char *display_name;
|
char *display_name = NULL;
|
||||||
struct cli_state *cli = NULL;
|
struct cli_state *cli = NULL;
|
||||||
|
|
||||||
result = ads_gpo_explode_filesyspath(ads, mem_ctx, gpo->file_sys_path,
|
result = gpo_explode_filesyspath(mem_ctx, gpo->file_sys_path,
|
||||||
&server, &share, &nt_path, &unix_path);
|
&server, &share, &nt_path, &unix_path);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ads_gpo_get_sysvol_gpt_version(ads, mem_ctx,
|
result = gpo_get_sysvol_gpt_version(mem_ctx,
|
||||||
unix_path,
|
unix_path,
|
||||||
&sysvol_gpt_version,
|
&sysvol_gpt_version,
|
||||||
&display_name);
|
&display_name);
|
||||||
if (!NT_STATUS_IS_OK(result) &&
|
if (!NT_STATUS_IS_OK(result) &&
|
||||||
!NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_FILE)) {
|
!NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_FILE)) {
|
||||||
DEBUG(10,("check_refresh_gpo: failed to get local gpt version: %s\n",
|
DEBUG(10,("check_refresh_gpo: failed to get local gpt version: %s\n",
|
||||||
@ -577,15 +610,15 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
|
|||||||
*cli_out = cli;
|
*cli_out = cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ads_fetch_gpo_files(ads, mem_ctx, *cli_out, gpo);
|
result = gpo_fetch_files(mem_ctx, *cli_out, gpo);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ads_gpo_get_sysvol_gpt_version(ads, mem_ctx,
|
result = gpo_get_sysvol_gpt_version(mem_ctx,
|
||||||
unix_path,
|
unix_path,
|
||||||
&sysvol_gpt_version,
|
&sysvol_gpt_version,
|
||||||
&display_name);
|
&display_name);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
DEBUG(10,("check_refresh_gpo: failed to get local gpt version: %s\n",
|
DEBUG(10,("check_refresh_gpo: failed to get local gpt version: %s\n",
|
||||||
nt_errstr(result)));
|
nt_errstr(result)));
|
||||||
@ -627,6 +660,10 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
|
|||||||
struct cli_state *cli = NULL;
|
struct cli_state *cli = NULL;
|
||||||
struct GROUP_POLICY_OBJECT *gpo;
|
struct GROUP_POLICY_OBJECT *gpo;
|
||||||
|
|
||||||
|
if (!gpo_list) {
|
||||||
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
for (gpo = gpo_list; gpo; gpo = gpo->next) {
|
for (gpo = gpo_list; gpo; gpo = gpo->next) {
|
||||||
|
|
||||||
result = check_refresh_gpo(ads, mem_ctx, gpo, &cli);
|
result = check_refresh_gpo(ads, mem_ctx, gpo, &cli);
|
||||||
|
@ -50,7 +50,7 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
|
|||||||
LDAPMessage *res = NULL;
|
LDAPMessage *res = NULL;
|
||||||
const char *filter;
|
const char *filter;
|
||||||
char *dn = NULL;
|
char *dn = NULL;
|
||||||
struct GROUP_POLICY_OBJECT *gpo_list;
|
struct GROUP_POLICY_OBJECT *gpo_list = NULL;
|
||||||
uint32 uac = 0;
|
uint32 uac = 0;
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
struct GROUP_POLICY_OBJECT *gpo;
|
struct GROUP_POLICY_OBJECT *gpo;
|
||||||
@ -127,8 +127,8 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
|
|||||||
GPO_VERSION_USER(gpo->version),
|
GPO_VERSION_USER(gpo->version),
|
||||||
GPO_VERSION_MACHINE(gpo->version));
|
GPO_VERSION_MACHINE(gpo->version));
|
||||||
|
|
||||||
result = ads_gpo_explode_filesyspath(ads, mem_ctx, gpo->file_sys_path,
|
result = gpo_explode_filesyspath(mem_ctx, gpo->file_sys_path,
|
||||||
&server, &share, &nt_path, &unix_path);
|
&server, &share, &nt_path, &unix_path);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
printf("got: %s\n", nt_errstr(result));
|
printf("got: %s\n", nt_errstr(result));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user