-/*
+/*
ldb database library - ldif handlers for Samba
Copyright (C) Andrew Tridgell 2005
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
return ldb_handler_copy(ldb, mem_ctx, in, out);
}
p = talloc_size(mem_ctx, struct_size);
- err = ndr_pull_struct_blob(in, mem_ctx,
+ err = ndr_pull_struct_blob(in, mem_ctx,
p, pull_fn);
if (err != NDR_ERR_SUCCESS) {
/* fail in not in mask_error mode */
out->data = (uint8_t *)ndr_print_struct_string(mem_ctx, print_fn, "NDR", p);
talloc_free(p);
if (out->data == NULL) {
- return ldb_handler_copy(ldb, mem_ctx, in, out);
+ return ldb_handler_copy(ldb, mem_ctx, in, out);
}
out->length = strlen((char *)out->data);
return 0;
char p[in->length+1];
memcpy(p, in->data, in->length);
p[in->length] = '\0';
-
+
ret = dom_sid_parse(p, &sid);
if (ret == false) {
return -1;
}
-
+
*out = data_blob_talloc(mem_ctx, NULL,
ndr_size_dom_sid(&sid, 0));
if (out->data == NULL) {
return -1;
}
-
+
ndr_err = ndr_push_struct_into_fixed_blob(out, &sid,
(ndr_push_flags_fn_t)ndr_push_dom_sid);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
}
if (strncmp("S-", (const char *)v->data, 2) != 0) return false;
-
+
return true;
}
return 0;
}
}
-
+
/* Perhaps not a string after all */
*out = data_blob_talloc(mem_ctx, NULL, in->length/2+1);
if (in->length != 32) {
return -1;
}
-
+
*out = data_blob_talloc(mem_ctx, NULL, in->length/2+1);
-
+
if (!out->data) {
return -1;
}
-
+
(*out).length = strhex_to_str((char *)out->data, out->length,
(const char *)in->data, in->length);
enum ndr_err_code ndr_err;
if (ldb_get_flags(ldb) & LDB_FLG_SHOW_BINARY) {
- return ldif_write_NDR(ldb, mem_ctx, in, out,
+ return ldif_write_NDR(ldb, mem_ctx, in, out,
sizeof(struct security_descriptor),
(ndr_pull_flags_fn_t)ndr_pull_security_descriptor,
(ndr_print_fn_t)ndr_print_security_descriptor,
true);
-
+
}
sd = talloc(mem_ctx, struct security_descriptor);
return ldb_handler_copy(ldb, mem_ctx, in, out);
}
-/*
+/*
canonicalise an objectCategory. We use the long form as the canonical form:
'person' becomes cn=Person,cn=Schema,cn=Configuration,<basedn>
/* If this does not parse, then it is probably the text version, and we should try it that way */
blob->version = PREFIX_MAP_VERSION_DSDB;
-
+
string = talloc_strndup(mem_ctx, (const char *)in->data, in->length);
if (string == NULL) {
talloc_free(blob);
if (line == p) {
break;
}
-
- blob->ctr.dsdb.mappings = talloc_realloc(blob,
- blob->ctr.dsdb.mappings,
+
+ blob->ctr.dsdb.mappings = talloc_realloc(blob,
+ blob->ctr.dsdb.mappings,
struct drsuapi_DsReplicaOIDMapping,
blob->ctr.dsdb.num_mappings+1);
if (!blob->ctr.dsdb.mappings) {
}
}
- ndr_err = ndr_push_struct_blob(out, mem_ctx,
+ ndr_err = ndr_push_struct_blob(out, mem_ctx,
blob,
(ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
talloc_free(tmp_ctx);
if (blob == NULL) {
return -1;
}
- ndr_err = ndr_pull_struct_blob_all(in, blob,
+ ndr_err = ndr_pull_struct_blob_all(in, blob,
blob,
(ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
char *partial_oid = NULL;
if (i > 0) {
- string = talloc_asprintf_append(string, ";");
+ string = talloc_asprintf_append(string, ";");
}
oid_blob = data_blob_const(blob->ctr.dsdb.mappings[i].oid.binary_oid,
blob->ctr.dsdb.mappings[i].id_prefix));
goto failed;
}
- string = talloc_asprintf_append(string, "%u:%s",
+ string = talloc_asprintf_append(string, "%u:%s",
blob->ctr.dsdb.mappings[i].id_prefix,
partial_oid);
talloc_free(discard_const(partial_oid));
if (IVAL(v->data, 0) == PREFIX_MAP_VERSION_DSDB) {
return false;
}
-
+
return true;
}
static int ldif_write_repsFromTo(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
- return ldif_write_NDR(ldb, mem_ctx, in, out,
+ return ldif_write_NDR(ldb, mem_ctx, in, out,
sizeof(struct repsFromToBlob),
(ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob,
(ndr_print_fn_t)ndr_print_repsFromToBlob,
static int ldif_write_replPropertyMetaData(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
- return ldif_write_NDR(ldb, mem_ctx, in, out,
+ return ldif_write_NDR(ldb, mem_ctx, in, out,
sizeof(struct replPropertyMetaDataBlob),
(ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob,
(ndr_print_fn_t)ndr_print_replPropertyMetaDataBlob,
static int ldif_write_replUpToDateVector(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
- return ldif_write_NDR(ldb, mem_ctx, in, out,
+ return ldif_write_NDR(ldb, mem_ctx, in, out,
sizeof(struct replUpToDateVectorBlob),
(ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob,
(ndr_print_fn_t)ndr_print_replUpToDateVectorBlob,
/*
compare two binary objects. This is correct for sorting as the sort order is:
-
+
a
aa
b
b
aa
bb
-
+
*/
static int samba_ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
unsigned int j;
const struct ldb_schema_syntax *s = NULL;
-
+
for (j=0; j < ARRAY_SIZE(samba_syntaxes); j++) {
if (strcmp(name, samba_syntaxes[j].name) == 0) {
s = &samba_syntaxes[j];
break;
}
}
-
+
return s;
}
-/*
+/*
ldb database library
Copyright (C) Andrew Bartlett 2005-2009
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
if (rdn_name == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
-
+
rdn_val_p = ldb_dn_get_rdn_val(msg->dn);
if (rdn_val_p == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
if (i == attribute->num_values) {
char *rdn_errstring = talloc_asprintf(ac,
- "RDN mismatch on %s: %s (%.*s) should match one of:",
- ldb_dn_get_linearized(msg->dn), rdn_name,
+ "RDN mismatch on %s: %s (%.*s) should match one of:",
+ ldb_dn_get_linearized(msg->dn), rdn_name,
(int)rdn_val.length, (const char *)rdn_val.data);
for (i = 0; i < attribute->num_values; i++) {
rdn_errstring = talloc_asprintf_append(
rdn_errstring, " (%.*s)",
- (int)attribute->values[i].length,
+ (int)attribute->values[i].length,
(const char *)attribute->values[i].data);
}
ldb_set_errstring(ldb, rdn_errstring);
-/*
+/*
Unix SMB/CIFS implementation.
-
+
Copyright (C) Andrew Tridgell 2005
Copyright (C) Jelmer Vernooij 2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
while (string && *string) {
size_t len = strcspn(string, sep);
char **ret2;
-
+
if (len == 0) {
string += strspn(string, sep);
continue;
}
/**
- * build a null terminated list of strings from an argv-like input string
+ * build a null terminated list of strings from an argv-like input string
* Entries are separated by spaces and can be enclosed by quotes.
* Does NOT support escaping
*/
size_t len = strcspn(string, sep);
char *element;
char **ret2;
-
+
if (len == 0) {
string += strspn(string, sep);
continue;
}
ret = ret2;
- ret[num_elements] = element;
+ ret[num_elements] = element;
num_elements++;
}
}
/**
- * join a list back to one string
+ * join a list back to one string
*/
_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char separator)
{
char *ret = NULL;
int i;
-
+
if (list[0] == NULL)
return talloc_strdup(mem_ctx, "");
return ret;
}
-/** join a list back to one (shell-like) string; entries
+/** join a list back to one (shell-like) string; entries
* separated by spaces, using quotes where necessary */
_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep)
{
char *ret = NULL;
int i;
-
+
if (list[0] == NULL)
return talloc_strdup(mem_ctx, "");
- if (strchr(list[0], ' ') || strlen(list[0]) == 0)
+ if (strchr(list[0], ' ') || strlen(list[0]) == 0)
ret = talloc_asprintf(mem_ctx, "\"%s\"", list[0]);
- else
+ else
ret = talloc_strdup(mem_ctx, list[0]);
for (i = 1; list[i]; i++) {
- if (strchr(list[i], ' ') || strlen(list[i]) == 0)
+ if (strchr(list[i], ' ') || strlen(list[i]) == 0)
ret = talloc_asprintf_append_buffer(ret, "%c\"%s\"", sep, list[i]);
- else
+ else
ret = talloc_asprintf_append_buffer(ret, "%c%s", sep, list[i]);
}
if (list == NULL)
return NULL;
-
+
ret = talloc_array(mem_ctx, char *, str_list_length(list)+1);
- if (ret == NULL)
+ if (ret == NULL)
return NULL;
for (i=0;list && list[i];i++) {
const char * const *list2)
{
int i;
-
+
if (list1 == NULL || list2 == NULL) {
- return (list1 == list2);
+ return (list1 == list2);
}
-
+
for (i=0;list1[i] && list2[i];i++) {
if (strcmp(list1[i], list2[i]) != 0) {
return false;
if (list == NULL)
return NULL;
-
+
ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1);
- if (ret == NULL)
+ if (ret == NULL)
return NULL;
for (i=0;list && list[i];i++) {
-/*
+/*
Unix SMB/CIFS implementation.
string substitution functions
Copyright (C) Andrew Tridgell 1992-2000
b = a_string;
switch (*(p+1)) {
- case 'U' :
+ case 'U' :
r = strlower_talloc(tmp_ctx, smb_name);
if (r == NULL) {
goto error;
a_string = realloc_string_sub(a_string, "%J", r);
break;
}
- case 'i':
+ case 'i':
a_string = realloc_string_sub(
a_string, "%i",
sub_sockaddr[0] ? sub_sockaddr : "0.0.0.0");
a_string = realloc_string_sub(a_string, "%j", r);
break;
}
- case 'L' :
+ case 'L' :
if ( strncasecmp_m(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
break;
}
if (local_machine_name && *local_machine_name) {
- a_string = realloc_string_sub(a_string, "%L", local_machine_name);
+ a_string = realloc_string_sub(a_string, "%L", local_machine_name);
} else {
a_string = realloc_string_sub(a_string, "%L", lp_netbios_name());
}
slprintf(vnnstr,sizeof(vnnstr)-1, "%u", get_my_vnn());
a_string = realloc_string_sub(a_string, "%V", vnnstr);
break;
- default:
+ default:
break;
}
b = a_string;
switch (*(p+1)) {
- case 'U' :
+ case 'U' :
a_string = talloc_string_sub(
tmp_ctx, a_string, "%U", username);
break;
- case 'u' :
+ case 'u' :
a_string = talloc_string_sub(
tmp_ctx, a_string, "%u", username);
break;
a_string = talloc_string_sub(tmp_ctx, a_string,
"%N", lp_netbios_name());
break;
- default:
+ default:
break;
}
TALLOC_FREE(h);
break;
}
- case 'P':
- a_string = realloc_string_sub(a_string, "%P", connectpath);
+ case 'P':
+ a_string = realloc_string_sub(a_string, "%P", connectpath);
break;
- case 'S':
+ case 'S':
a_string = realloc_string_sub(a_string, "%S", servicename);
break;
- case 'g':
- a_string = realloc_string_sub(a_string, "%g", gidtoname(gid));
+ case 'g':
+ a_string = realloc_string_sub(a_string, "%g", gidtoname(gid));
break;
- case 'u':
- a_string = realloc_string_sub(a_string, "%u", user);
+ case 'u':
+ a_string = realloc_string_sub(a_string, "%u", user);
break;
- default:
+ default:
break;
}
-/*
+/*
Unix SMB/CIFS implementation.
ads (active directory) utility library
Copyright (C) Guenther Deschner 2005-2007
Copyright (C) Gerald (Jerry) Carter 2006
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
char *expr = NULL;
const char *attrs[] = { "lDAPDisplayName", "attributeId", NULL };
int i = 0, p = 0;
-
+
if (!ads || !mem_ctx || !names || !count || !OIDs || !OIDs_out) {
return ADS_ERROR(LDAP_PARAM_ERROR);
}
for (i=0; i<num_OIDs; i++) {
- if ((expr = talloc_asprintf_append_buffer(expr, "(attributeId=%s)",
+ if ((expr = talloc_asprintf_append_buffer(expr, "(attributeId=%s)",
OIDs[i])) == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
return ADS_ERROR(LDAP_NO_MEMORY);
}
- status = ads_do_search_retry(ads, schema_path,
+ status = ads_do_search_retry(ads, schema_path,
LDAP_SCOPE_SUBTREE, expr, attrs, &res);
if (!ADS_ERR_OK(status)) {
return status;
goto out;
}
- for (msg = ads_first_entry(ads, res); msg != NULL;
+ for (msg = ads_first_entry(ads, res); msg != NULL;
msg = ads_next_entry(ads, msg)) {
- (*names)[p] = ads_pull_string(ads, mem_ctx, msg,
+ (*names)[p] = ads_pull_string(ads, mem_ctx, msg,
"lDAPDisplayName");
- (*OIDs_out)[p] = ads_pull_string(ads, mem_ctx, msg,
+ (*OIDs_out)[p] = ads_pull_string(ads, mem_ctx, msg,
"attributeId");
if (((*names)[p] == NULL) || ((*OIDs_out)[p] == NULL)) {
status = ADS_ERROR(LDAP_NO_MEMORY);
return status;
}
-const char *ads_get_attrname_by_guid(ADS_STRUCT *ads,
- const char *schema_path,
- TALLOC_CTX *mem_ctx,
+const char *ads_get_attrname_by_guid(ADS_STRUCT *ads,
+ const char *schema_path,
+ TALLOC_CTX *mem_ctx,
const struct GUID *schema_guid)
{
ADS_STATUS rc;
goto done;
}
- rc = ads_do_search_retry(ads, schema_path, LDAP_SCOPE_SUBTREE,
+ rc = ads_do_search_retry(ads, schema_path, LDAP_SCOPE_SUBTREE,
expr, attrs, &res);
if (!ADS_ERR_OK(rc)) {
goto done;
TALLOC_FREE(guid_bin);
ads_msgfree(ads, res);
return result;
-
+
}
/*********************************************************************
* @param enum mapping type
* @return ADS_STATUS status of search (False if one or more attributes couldn't be
* found in Active Directory)
- **/
+ **/
ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
ADS_STRUCT *ads,
enum wb_posix_mapping map_type,
- struct posix_schema **s )
+ struct posix_schema **s )
{
- TALLOC_CTX *ctx = NULL;
+ TALLOC_CTX *ctx = NULL;
ADS_STATUS status;
char **oids_out, **names_out;
size_t num_names;
DEBUG(10,("ads_check_posix_schema_mapping for schema mode: %d\n", map_type));
switch (map_type) {
-
+
case WB_POSIX_MAP_TEMPLATE:
case WB_POSIX_MAP_UNIXINFO:
DEBUG(10,("ads_check_posix_schema_mapping: nothing to do\n"));
TALLOC_FREE( ctx );
return ADS_ERROR(LDAP_NO_MEMORY);
}
-
+
status = ads_schema_path(ads, ctx, &schema_path);
if (!ADS_ERR_OK(status)) {
DEBUG(3,("ads_check_posix_mapping: Unable to retrieve schema DN!\n"));
switch (map_type) {
case WB_POSIX_MAP_SFU:
- status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_sfu,
- ARRAY_SIZE(oids_sfu),
+ status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_sfu,
+ ARRAY_SIZE(oids_sfu),
&oids_out, &names_out, &num_names);
break;
case WB_POSIX_MAP_SFU20:
- status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_sfu20,
- ARRAY_SIZE(oids_sfu20),
+ status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_sfu20,
+ ARRAY_SIZE(oids_sfu20),
&oids_out, &names_out, &num_names);
break;
case WB_POSIX_MAP_RFC2307:
- status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_rfc2307,
- ARRAY_SIZE(oids_rfc2307),
+ status = ads_get_attrnames_by_oids(ads, ctx, schema_path, oids_rfc2307,
+ ARRAY_SIZE(oids_rfc2307),
&oids_out, &names_out, &num_names);
break;
default:
}
if (!ADS_ERR_OK(status)) {
- DEBUG(3,("ads_check_posix_schema_mapping: failed %s\n",
+ DEBUG(3,("ads_check_posix_schema_mapping: failed %s\n",
ads_errstr(status)));
goto done;
}
strequal(ADS_ATTR_SFU_UIDNUMBER_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU20_UIDNUMBER_OID, oids_out[i])) {
schema->posix_uidnumber_attr = talloc_strdup(schema, names_out[i]);
- continue;
+ continue;
}
if (strequal(ADS_ATTR_RFC2307_GIDNUMBER_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU_GIDNUMBER_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU20_GIDNUMBER_OID, oids_out[i])) {
schema->posix_gidnumber_attr = talloc_strdup(schema, names_out[i]);
- continue;
+ continue;
}
if (strequal(ADS_ATTR_RFC2307_HOMEDIR_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU_HOMEDIR_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU20_HOMEDIR_OID, oids_out[i])) {
schema->posix_homedir_attr = talloc_strdup(schema, names_out[i]);
- continue;
+ continue;
}
if (strequal(ADS_ATTR_RFC2307_SHELL_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU_SHELL_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU20_SHELL_OID, oids_out[i])) {
schema->posix_shell_attr = talloc_strdup(schema, names_out[i]);
- continue;
+ continue;
}
if (strequal(ADS_ATTR_RFC2307_GECOS_OID, oids_out[i]) ||
!schema->posix_shell_attr ||
!schema->posix_gecos_attr) {
status = ADS_ERROR(LDAP_NO_MEMORY);
- TALLOC_FREE( schema );
+ TALLOC_FREE( schema );
goto done;
}
*s = schema;
-
+
status = ADS_ERROR(LDAP_SUCCESS);
-
+
done:
TALLOC_FREE(ctx);
-/*
+/*
Unix SMB/CIFS implementation.
Winbind daemon - miscellaneous other functions
for ( i = 0; i < num_domains; i++ ) {
struct winbindd_domain *domain;
- bool is_online = true;
+ bool is_online = true;
struct winbindd_tdc_domain *d = NULL;
char *trust_type = NULL;
struct dom_sid_buf buf;