From 3dddbb5e26c4fc74cbdd0f6fa68669fe4d07a84e Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Tue, 18 Mar 2008 10:53:25 +0100 Subject: make: Fix make valgrindtest-env (This used to be commit f56912e3b545325e941ee898337c5483ec435e39) --- source4/script/valgrind_run | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/script/valgrind_run b/source4/script/valgrind_run index 45361c22b1..5171d171a7 100755 --- a/source4/script/valgrind_run +++ b/source4/script/valgrind_run @@ -4,4 +4,6 @@ ENV="$1" shift 1 -$ENV valgrind -q --db-attach=yes --num-callers=30 $@ +CMD="$ENV valgrind -q --db-attach=yes --num-callers=30 $@" +echo $CMD +eval $CMD -- cgit From a1875b039bb77bad9c3cef4e1ebe037a7e645938 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Thu, 6 Mar 2008 00:52:37 +0100 Subject: idmap: Map SIDs to unixids instead of uids/gids (This used to be commit 73ac7c4a1ce937bddd3c52d048665cd0078c6aaa) --- source4/winbind/config.mk | 2 + source4/winbind/idmap.c | 722 +++++++++++------------------------------ source4/winbind/idmap.h | 20 ++ source4/winbind/wb_gid2sid.c | 47 ++- source4/winbind/wb_sid2gid.c | 48 ++- source4/winbind/wb_sid2uid.c | 50 ++- source4/winbind/wb_sids2xids.c | 82 +++++ source4/winbind/wb_uid2sid.c | 49 ++- source4/winbind/wb_xids2sids.c | 82 +++++ 9 files changed, 519 insertions(+), 583 deletions(-) create mode 100644 source4/winbind/wb_sids2xids.c create mode 100644 source4/winbind/wb_xids2sids.c (limited to 'source4') diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk index 2567d617da..8c9b3f1225 100644 --- a/source4/winbind/config.mk +++ b/source4/winbind/config.mk @@ -16,6 +16,8 @@ OBJ_FILES = \ wb_dom_info_trusted.o \ wb_sid2domain.o \ wb_name2domain.o \ + wb_sids2xids.o \ + wb_xids2sids.o \ wb_gid2sid.o \ wb_sid2uid.o \ wb_sid2gid.o \ diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index 3372ad51ee..de8a43ec02 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - Map SIDs to uids/gids and back + Map SIDs to unixids and back Copyright (C) Kai Blin 2008 @@ -177,39 +177,46 @@ struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx, return NULL; } + idmap_ctx->unix_groups_sid = dom_sid_parse_talloc(mem_ctx, "S-1-22-2"); + if (idmap_ctx->unix_groups_sid == NULL) { + return NULL; + } + + idmap_ctx->unix_users_sid = dom_sid_parse_talloc(mem_ctx, "S-1-22-1"); + if (idmap_ctx->unix_users_sid == NULL) { + return NULL; + } + return idmap_ctx; } /** - * Convert a uid to the corresponding SID + * Convert an unixid to the corresponding SID * * \param idmap_ctx idmap context to use * \param mem_ctx talloc context the memory for the struct dom_sid is allocated * from. - * \param uid Unix uid to map to a SID - * \param sid Pointer that will take the struct dom_sid pointer if the mapping + * \param unixid pointer to a unixid struct to convert + * \param sid pointer that will take the struct dom_sid pointer if the mapping * succeeds. * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping not * possible or some other NTSTATUS that is more descriptive on failure. */ -NTSTATUS idmap_uid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, - const uid_t uid, struct dom_sid **sid) +NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const struct unixid *unixid, struct dom_sid **sid) { int ret; NTSTATUS status = NT_STATUS_NONE_MAPPED; struct ldb_context *ldb = idmap_ctx->ldb_ctx; - struct ldb_message *msg; struct ldb_result *res = NULL; - int trans = -1; - uid_t low, high; - char *sid_string, *uid_string; - struct dom_sid *unix_users_sid, *new_sid; + uint32_t low, high; + struct dom_sid *unix_sid, *new_sid; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(uidNumber=%u))", - uid); + NULL, "(&(objectClass=sidMap)(xidNumber=%u))", + unixid->id); if (ret != LDB_SUCCESS) { DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); status = NT_STATUS_NONE_MAPPED; @@ -228,19 +235,13 @@ NTSTATUS idmap_uid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - DEBUG(6, ("uid not found in idmap db, trying to allocate SID.\n")); - - trans = ldb_transaction_start(ldb); - if (trans != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } + DEBUG(6, ("xid not found in idmap db, trying to allocate SID.\n")); /* Now redo the search to make sure noone added a mapping for that SID * while we weren't looking.*/ ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(uidNumber=%u))", - uid); + NULL, "(&(objectClass=sidMap)(xidNumber=%u))", + unixid->id); if (ret != LDB_SUCCESS) { DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); status = NT_STATUS_NONE_MAPPED; @@ -260,285 +261,58 @@ NTSTATUS idmap_uid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - if (uid >= low && uid <= high) { - /* An existing user would have been mapped before */ - status = NT_STATUS_NO_SUCH_USER; + if (unixid->id >= low && unixid->id <= high) { + /* An existing xid would have been mapped before */ + status = NT_STATUS_NONE_MAPPED; goto failed; } /* For local users, we just create a rid = uid +1, so root doesn't end * up with a 0 rid */ - unix_users_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-1"); - if (unix_users_sid == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - new_sid = dom_sid_add_rid(mem_ctx, unix_users_sid, uid + 1); - if (new_sid == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - sid_string = dom_sid_string(tmp_ctx, new_sid); - if (sid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - uid_string = talloc_asprintf(tmp_ctx, "%u", uid); - if (uid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - msg = ldb_msg_new(tmp_ctx); - if (msg == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); - if (msg->dn == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - ret = ldb_msg_add_string(msg, "uidNumber", uid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, msg, "objectSid", - new_sid); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(msg, "objectClass", "sidMap"); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(msg, "cn", sid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_add(ldb, msg); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - trans = ldb_transaction_commit(ldb); - if (trans != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - *sid = new_sid; - talloc_free(tmp_ctx); - return NT_STATUS_OK; - -failed: - if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); - talloc_free(tmp_ctx); - return status; -} - -/** - * Map a Unix gid to the corresponding SID - * - * \param idmap_ctx idmap context to use - * \param mem_ctx talloc context the memory for the struct dom_sid is allocated - * from. - * \param gid Unix gid to map to a SID - * \param sid Pointer that will take the struct dom_sid pointer if mapping - * succeeds. - * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping not - * possible or some other NTSTATUS that is more descriptive on failure. - */ -NTSTATUS idmap_gid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, - const gid_t gid, struct dom_sid **sid) -{ - int ret; - NTSTATUS status = NT_STATUS_NONE_MAPPED; - struct ldb_context *ldb = idmap_ctx->ldb_ctx; - struct ldb_message *msg; - struct ldb_result *res = NULL; - int trans = -1; - gid_t low, high; - char *sid_string, *gid_string; - struct dom_sid *unix_groups_sid, *new_sid; - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(gidNumber=%u))", gid); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - if (res->count == 1) { - *sid = idmap_msg_get_dom_sid(mem_ctx, res->msgs[0], - "objectSid"); - if (*sid == NULL) { - DEBUG(1, ("Failed to get sid from db: %u\n", ret)); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - /* No change, so cancel the transaction */ - ldb_transaction_cancel(ldb); - talloc_free(tmp_ctx); - return NT_STATUS_OK; - } - - DEBUG(6, ("gid not found in idmap db, trying to allocate SID.\n")); - - trans = ldb_transaction_start(ldb); - if (trans != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - /* Now redo the search to make sure noone added a mapping for that SID - * while we weren't looking.*/ - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(gidNumber=%u))", - gid); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - if (res->count > 0) { - DEBUG(1, ("sidMap modified while trying to add a mapping.\n")); - status = NT_STATUS_RETRY; - goto failed; - } - - ret = idmap_get_bounds(idmap_ctx, &low, &high); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to get id bounds from db: %u\n", ret)); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - if (gid >= low && gid <= high) { - /* An existing group would have been mapped before */ - status = NT_STATUS_NO_SUCH_USER; - goto failed; + if (unixid->type == ID_TYPE_UID) { + unix_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-1"); + } else { + unix_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-2"); } - - /* For local groups, we just create a rid = gid +1, so root doesn't end - * up with a 0 rid */ - unix_groups_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-2"); - if (unix_groups_sid == NULL) { + if (unix_sid == NULL) { status = NT_STATUS_NO_MEMORY; goto failed; } - new_sid = dom_sid_add_rid(mem_ctx, unix_groups_sid, gid + 1); + new_sid = dom_sid_add_rid(mem_ctx, unix_sid, unixid->id + 1); if (new_sid == NULL) { status = NT_STATUS_NO_MEMORY; goto failed; } - sid_string = dom_sid_string(tmp_ctx, new_sid); - if (sid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - gid_string = talloc_asprintf(tmp_ctx, "%u", gid); - if (gid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - msg = ldb_msg_new(tmp_ctx); - if (msg == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); - if (msg->dn == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - ret = ldb_msg_add_string(msg, "gidNumber", gid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, msg, "objectSid", - new_sid); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(msg, "objectClass", "sidMap"); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(msg, "cn", sid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_add(ldb, msg); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - trans = ldb_transaction_commit(ldb); - if (trans != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - *sid = new_sid; talloc_free(tmp_ctx); return NT_STATUS_OK; failed: - if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); talloc_free(tmp_ctx); return status; } + /** - * Map a SID to a Unix uid. + * Map a SID to an unixid struct. * * If no mapping exists, a new mapping will be created. * * \todo Check if SIDs can be resolved if lp_idmap_trusted_only() == true + * \todo Fix backwards compatibility for Samba3 * * \param idmap_ctx idmap context to use * \param mem_ctx talloc context to use - * \param sid SID to map to a Unix uid - * \param uid pointer to receive the mapped uid + * \param sid SID to map to an unixid struct + * \param unixid pointer to a unixid struct pointer * \return NT_STATUS_OK on success, NT_STATUS_INVALID_SID if the sid is not from * a trusted domain and idmap trusted only = true, NT_STATUS_NONE_MAPPED if the * mapping failed. */ -NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, - const struct dom_sid *sid, uid_t *uid) +NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const struct dom_sid *sid, struct unixid **unixid) { int ret; NTSTATUS status = NT_STATUS_NONE_MAPPED; @@ -547,8 +321,8 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *hwm_msg, *map_msg; struct ldb_result *res = NULL; int trans; - uid_t low, high, hwm, new_uid; - char *sid_string, *uid_string, *hwm_string; + uint32_t low, high, hwm, new_xid; + char *sid_string, *unixid_string, *hwm_string; bool hwm_entry_exists; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); @@ -562,20 +336,65 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, } if (res->count == 1) { - new_uid = ldb_msg_find_attr_as_uint(res->msgs[0], "uidNumber", + new_xid = ldb_msg_find_attr_as_uint(res->msgs[0], "xidNumber", -1); - if (new_uid == (uid_t) -1) { - DEBUG(1, ("Invalid uid mapping.\n")); + if (new_xid == (uint32_t) -1) { + DEBUG(1, ("Invalid xid mapping.\n")); status = NT_STATUS_NONE_MAPPED; goto failed; } - *uid = new_uid; + + *unixid = talloc(mem_ctx, struct unixid); + if (*unixid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + (*unixid)->id = new_xid; + (*unixid)->type = ID_TYPE_BOTH; + talloc_free(tmp_ctx); return NT_STATUS_OK; } DEBUG(6, ("No existing mapping found, attempting to create one.\n")); + if (dom_sid_in_domain(idmap_ctx->unix_users_sid, sid)) { + uint32_t rid; + DEBUG(6, ("This is a local unix uid, just calculate that.\n")); + status = dom_sid_split_rid(tmp_ctx, sid, NULL, &rid); + if (!NT_STATUS_IS_OK(status)) goto failed; + + *unixid = talloc(mem_ctx, struct unixid); + if (*unixid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + (*unixid)->id = rid - 1; + (*unixid)->type = ID_TYPE_UID; + + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + + if (dom_sid_in_domain(idmap_ctx->unix_groups_sid, sid)) { + uint32_t rid; + DEBUG(6, ("This is a local unix gid, just calculate that.\n")); + status = dom_sid_split_rid(tmp_ctx, sid, NULL, &rid); + if (!NT_STATUS_IS_OK(status)) goto failed; + + *unixid = talloc(mem_ctx, struct unixid); + if (*unixid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + (*unixid)->id = rid - 1; + (*unixid)->type = ID_TYPE_GID; + + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + trans = ldb_transaction_start(ldb); if (trans != LDB_SUCCESS) { status = NT_STATUS_NONE_MAPPED; @@ -629,8 +448,8 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - hwm = ldb_msg_find_attr_as_uint(res->msgs[0], "uidNumber", -1); - if (hwm == (uid_t)-1) { + hwm = ldb_msg_find_attr_as_uint(res->msgs[0], "xidNumber", -1); + if (hwm == (uint32_t)-1) { hwm = low; hwm_entry_exists = false; } else { @@ -638,7 +457,7 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, } if (hwm > high) { - DEBUG(1, ("Out of uids to allocate.\n")); + DEBUG(1, ("Out of xids to allocate.\n")); status = NT_STATUS_NONE_MAPPED; goto failed; } @@ -652,7 +471,7 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, hwm_msg->dn = dn; - new_uid = hwm; + new_xid = hwm; hwm++; hwm_string = talloc_asprintf(tmp_ctx, "%u", hwm); @@ -667,8 +486,8 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - uid_string = talloc_asprintf(tmp_ctx, "%u", new_uid); - if (uid_string == NULL) { + unixid_string = talloc_asprintf(tmp_ctx, "%u", new_xid); + if (unixid_string == NULL) { status = NT_STATUS_NO_MEMORY; goto failed; } @@ -696,7 +515,7 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, els[0].num_values = 1; els[0].values = &vals[0]; els[0].flags = LDB_FLAG_MOD_DELETE; - els[0].name = talloc_strdup(tmp_ctx, "uidNumber"); + els[0].name = talloc_strdup(tmp_ctx, "xidNumber"); if (els[0].name == NULL) { status = NT_STATUS_NO_MEMORY; goto failed; @@ -707,19 +526,19 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, els[1].flags = LDB_FLAG_MOD_ADD; els[1].name = els[0].name; - vals[0].data = (uint8_t *)uid_string; - vals[0].length = strlen(uid_string); + vals[0].data = (uint8_t *)unixid_string; + vals[0].length = strlen(unixid_string); vals[1].data = (uint8_t *)hwm_string; vals[1].length = strlen(hwm_string); } else { - ret = ldb_msg_add_empty(hwm_msg, "uidNumber", LDB_FLAG_MOD_ADD, + ret = ldb_msg_add_empty(hwm_msg, "xidNumber", LDB_FLAG_MOD_ADD, NULL); if (ret != LDB_SUCCESS) { status = NT_STATUS_NONE_MAPPED; goto failed; } - ret = ldb_msg_add_string(hwm_msg, "uidNumber", hwm_string); + ret = ldb_msg_add_string(hwm_msg, "xidNumber", hwm_string); if (ret != LDB_SUCCESS) { status = NT_STATUS_NONE_MAPPED; @@ -729,7 +548,7 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, ret = ldb_modify(ldb, hwm_msg); if (ret != LDB_SUCCESS) { - DEBUG(1, ("Updating the uid high water mark failed: %s\n", + DEBUG(1, ("Updating the xid high water mark failed: %s\n", ldb_errstring(ldb))); status = NT_STATUS_NONE_MAPPED; goto failed; @@ -747,7 +566,7 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - ret = ldb_msg_add_string(map_msg, "uidNumber", uid_string); + ret = ldb_msg_add_string(map_msg, "xidNumber", unixid_string); if (ret != LDB_SUCCESS) { status = NT_STATUS_NONE_MAPPED; goto failed; @@ -786,7 +605,14 @@ NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - *uid = new_uid; + *unixid = talloc(mem_ctx, struct unixid); + if (*unixid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + (*unixid)->id = new_xid; + (*unixid)->type = ID_TYPE_BOTH; talloc_free(tmp_ctx); return NT_STATUS_OK; @@ -797,276 +623,92 @@ failed: } /** - * Map a SID to a Unix gid. - * - * If no mapping exist, a new mapping will be created. - * - * \todo Check if SID resolve when lp_idmap_trusted_only() == true + * Convert an array of unixids to the corresponding array of SIDs * * \param idmap_ctx idmap context to use - * \param mem_ctx talloc context to use - * \param sid SID to map to a Unix gid - * \param gid pointer to receive the mapped gid - * \return NT_STATUS_OK on success, NT_STATUS_INVALID_SID if the sid is not from - * a trusted domain and idmap trusted only = true, NT_STATUS_NONE_MAPPED if the - * mapping failed. + * \param mem_ctx talloc context the memory for the dom_sids is allocated + * from. + * \param count length of id_mapping array. + * \param id array of id_mappings. + * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping is not + * possible at all, NT_STATUS_SOME_UNMAPPED if some mappings worked and some + * did not. */ -NTSTATUS idmap_sid_to_gid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, - const struct dom_sid *sid, gid_t *gid) -{ - int ret; - NTSTATUS status = NT_STATUS_NONE_MAPPED; - struct ldb_context *ldb = idmap_ctx->ldb_ctx; - struct ldb_dn *dn; - struct ldb_message *hwm_msg, *map_msg; - struct ldb_result *res = NULL; - int trans = -1; - gid_t low, high, hwm, new_gid; - char *sid_string, *gid_string, *hwm_string; - bool hwm_entry_exists; - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(objectSid=%s))", - ldap_encode_ndr_dom_sid(tmp_ctx, sid)); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - if (res->count == 1) { - new_gid = ldb_msg_find_attr_as_uint(res->msgs[0], "gidNumber", - -1); - if (new_gid == (gid_t) -1) { - DEBUG(1, ("Invalid gid mapping.\n")); - status = NT_STATUS_NONE_MAPPED; - goto failed; +NTSTATUS idmap_xids_to_sids(struct idmap_context *idmap_ctx, + TALLOC_CTX *mem_ctx, int count, + struct id_mapping *id) +{ + int i; + int error_count = 0; + + for (i = 0; i < count; ++i) { + id[i].status = idmap_xid_to_sid(idmap_ctx, mem_ctx, + id[i].unixid, &id[i].sid); + if (NT_STATUS_EQUAL(id[i].status, NT_STATUS_RETRY)) { + id[i].status = idmap_xid_to_sid(idmap_ctx, mem_ctx, + id[i].unixid, + &id[i].sid); + } + if (!NT_STATUS_IS_OK(id[i].status)) { + DEBUG(1, ("idmapping failed for id[%d]\n", i)); + error_count++; } - *gid = new_gid; - talloc_free(tmp_ctx); - return NT_STATUS_OK; - } - - DEBUG(6, ("No existing mapping found, attempting to create one.\n")); - - trans = ldb_transaction_start(ldb); - if (trans != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - /* Redo the search to make sure noone changed the mapping while we - * weren't looking */ - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, - NULL, "(&(objectClass=sidMap)(objectSid=%s))", - ldap_encode_ndr_dom_sid(tmp_ctx, sid)); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - if (res->count > 0) { - DEBUG(1, ("Database changed while trying to add a sidmap.\n")); - status = NT_STATUS_RETRY; - goto failed; - } - - /*FIXME: if lp_idmap_trusted_only() == true, check if SID can be - * resolved here. */ - - ret = idmap_get_bounds(idmap_ctx, &low, &high); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); - if (dn == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - talloc_steal(tmp_ctx, res); - - if (res->count != 1) { - DEBUG(1, ("No CN=CONFIG record, idmap database is broken.\n")); - status = NT_STATUS_NONE_MAPPED; - goto failed; } - hwm = ldb_msg_find_attr_as_uint(res->msgs[0], "gidNumber", -1); - if (hwm == (gid_t)-1) { - hwm = low; - hwm_entry_exists = false; + if (error_count == count) { + /* Mapping did not work at all. */ + return NT_STATUS_NONE_MAPPED; + } else if (error_count > 0) { + /* Some mappings worked, some did not. */ + return STATUS_SOME_UNMAPPED; } else { - hwm_entry_exists = true; - } - - if (hwm > high) { - DEBUG(1, ("Out of gids to allocate.\n")); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - hwm_msg = ldb_msg_new(tmp_ctx); - if (hwm_msg == NULL) { - DEBUG(1, ("Out of memory when creating ldb_message\n")); - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - hwm_msg->dn = dn; - - new_gid = hwm; - hwm++; - - hwm_string = talloc_asprintf(tmp_ctx, "%u", hwm); - if (hwm_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - sid_string = dom_sid_string(tmp_ctx, sid); - if (sid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - gid_string = talloc_asprintf(tmp_ctx, "%u", new_gid); - if (gid_string == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; + return NT_STATUS_OK; } +} - if (hwm_entry_exists) { - struct ldb_message_element *els; - struct ldb_val *vals; - - /* We're modifying the entry, not just adding a new one. */ - els = talloc_array(tmp_ctx, struct ldb_message_element, 2); - if (els == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - vals = talloc_array(tmp_ctx, struct ldb_val, 2); - if (els == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - hwm_msg->num_elements = 2; - hwm_msg->elements = els; - - els[0].num_values = 1; - els[0].values = &vals[0]; - els[0].flags = LDB_FLAG_MOD_DELETE; - els[0].name = talloc_strdup(tmp_ctx, "gidNumber"); - if (els[0].name == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - els[1].num_values = 1; - els[1].values = &vals[1]; - els[1].flags = LDB_FLAG_MOD_ADD; - els[1].name = els[0].name; +/** + * Convert an array of SIDs to the corresponding array of unixids + * + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context the memory for the unixids is allocated + * from. + * \param count length of id_mapping array. + * \param id array of id_mappings. + * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping is not + * possible at all, NT_STATUS_SOME_UNMAPPED if some mappings worked and some + * did not. + */ - vals[0].data = (uint8_t *)gid_string; - vals[0].length = strlen(gid_string); - vals[1].data = (uint8_t *)hwm_string; - vals[1].length = strlen(hwm_string); - } else { - ret = ldb_msg_add_empty(hwm_msg, "gidNumber", LDB_FLAG_MOD_ADD, - NULL); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; +NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx, + TALLOC_CTX *mem_ctx, int count, + struct id_mapping *id) +{ + int i; + int error_count = 0; + + for (i = 0; i < count; ++i) { + id[i].status = idmap_sid_to_xid(idmap_ctx, mem_ctx, + id[i].sid, &id[i].unixid); + if (NT_STATUS_EQUAL(id[i].status, NT_STATUS_RETRY)) { + id[i].status = idmap_sid_to_xid(idmap_ctx, mem_ctx, + id[i].sid, + &id[i].unixid); } - - ret = ldb_msg_add_string(hwm_msg, "gidNumber", hwm_string); - if (ret != LDB_SUCCESS) - { - status = NT_STATUS_NONE_MAPPED; - goto failed; + if (!NT_STATUS_IS_OK(id[i].status)) { + DEBUG(1, ("idmapping failed for id[%d]\n", i)); + error_count++; } } - ret = ldb_modify(ldb, hwm_msg); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Updating the gid high water mark failed: %s\n", - ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - map_msg = ldb_msg_new(tmp_ctx); - if (map_msg == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - map_msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); - if (map_msg->dn == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } - - ret = ldb_msg_add_string(map_msg, "gidNumber", gid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, map_msg, "objectSid", - sid); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(map_msg, "objectClass", "sidMap"); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_msg_add_string(map_msg, "cn", sid_string); - if (ret != LDB_SUCCESS) { - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - ret = ldb_add(ldb, map_msg); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Adding a sidmap failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; - } - - trans = ldb_transaction_commit(ldb); - if (trans != LDB_SUCCESS) { - DEBUG(1, ("Transaction failed: %s\n", ldb_errstring(ldb))); - status = NT_STATUS_NONE_MAPPED; - goto failed; + if (error_count == count) { + /* Mapping did not work at all. */ + return NT_STATUS_NONE_MAPPED; + } else if (error_count > 0) { + /* Some mappings worked, some did not. */ + return STATUS_SOME_UNMAPPED; + } else { + return NT_STATUS_OK; } - - *gid = new_gid; - talloc_free(tmp_ctx); - return NT_STATUS_OK; - -failed: - if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); - talloc_free(tmp_ctx); - return status; } diff --git a/source4/winbind/idmap.h b/source4/winbind/idmap.h index 8781819be0..045d50c568 100644 --- a/source4/winbind/idmap.h +++ b/source4/winbind/idmap.h @@ -25,6 +25,26 @@ struct idmap_context { struct loadparm_context *lp_ctx; struct ldb_context *ldb_ctx; + struct dom_sid *unix_groups_sid; + struct dom_sid *unix_users_sid; +}; + +enum id_type { + ID_TYPE_NOT_SPECIFIED = 0, + ID_TYPE_UID, + ID_TYPE_GID, + ID_TYPE_BOTH +}; + +struct unixid { + uint32_t id; + enum id_type type; +}; + +struct id_mapping { + struct unixid *unixid; + struct dom_sid *sid; + NTSTATUS status; }; #include "winbind/idmap_proto.h" diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c index f2577029aa..834d869845 100644 --- a/source4/winbind/wb_gid2sid.c +++ b/source4/winbind/wb_gid2sid.c @@ -3,7 +3,7 @@ Command backend for wbinfo -G - Copyright (C) Kai Blin 2007 + Copyright (C) 2007-2008 Kai Blin 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 @@ -33,35 +33,60 @@ struct gid2sid_state { struct dom_sid *sid; }; +static void gid2sid_recv_sid(struct composite_context *ctx); + struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, gid_t gid) { - struct composite_context *result; + struct composite_context *result, *ctx; struct gid2sid_state *state; + struct unixid *unixid; + struct id_mapping *ids; DEBUG(5, ("wb_gid2sid_send called\n")); result = composite_create(mem_ctx, service->task->event_ctx); if (!result) return NULL; - state = talloc(mem_ctx, struct gid2sid_state); + state = talloc(result, struct gid2sid_state); if (composite_nomem(state, result)) return result; state->ctx = result; result->private_data = state; state->service = service; - state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, mem_ctx, gid, - &state->sid); - if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { - state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, - mem_ctx, gid, - &state->sid); + unixid = talloc(result, struct unixid); + if (composite_nomem(unixid, result)) return result; + unixid->id = gid; + unixid->type = ID_TYPE_GID; + + ids = talloc(result, struct id_mapping); + if (composite_nomem(ids, result)) return result; + ids->unixid = unixid; + ids->sid = NULL; + + ctx = wb_xids2sids_send(result, service, 1, ids); + if (composite_nomem(ctx, result)) return result; + + composite_continue(result, ctx, gid2sid_recv_sid, state); + return result; +} + +static void gid2sid_recv_sid(struct composite_context *ctx) +{ + struct gid2sid_state *state = talloc_get_type(ctx->async.private_data, + struct gid2sid_state); + struct id_mapping *ids = NULL; + state->ctx->status = wb_xids2sids_recv(ctx, &ids); + if (!composite_is_ok(state->ctx)) return; + + if (!NT_STATUS_IS_OK(ids->status)) { + composite_error(state->ctx, ids->status); + return; } - if (!composite_is_ok(state->ctx)) return result; + state->sid = ids->sid; composite_done(state->ctx); - return result; } NTSTATUS wb_gid2sid_recv(struct composite_context *ctx, TALLOC_CTX *mem_ctx, diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c index 12129226be..d68956ce85 100644 --- a/source4/winbind/wb_sid2gid.c +++ b/source4/winbind/wb_sid2gid.c @@ -3,7 +3,7 @@ Map a SID to a gid - Copyright (C) Kai Blin 2007 + Copyright (C) 2007-2008 Kai Blin 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 @@ -33,11 +33,14 @@ struct sid2gid_state { gid_t gid; }; +static void sid2gid_recv_gid(struct composite_context *ctx); + struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, const struct dom_sid *sid) { - struct composite_context *result; + struct composite_context *result, *ctx; struct sid2gid_state *state; + struct id_mapping *ids; DEBUG(5, ("wb_sid2gid_send called\n")); @@ -51,18 +54,43 @@ struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, sid, - &state->gid); - if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { - state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, - sid, &state->gid); - } - if (!composite_is_ok(state->ctx)) return result; + ids = talloc(result, struct id_mapping); + if (composite_nomem(ids, result)) return result; + + ids->sid = dom_sid_dup(result, sid); + if (composite_nomem(ids->sid, result)) return result; + + ctx = wb_sids2xids_send(result, service, 1, ids); + if (composite_nomem(ctx, result)) return result; - composite_done(state->ctx); + composite_continue(result, ctx, sid2gid_recv_gid, state); return result; } +static void sid2gid_recv_gid(struct composite_context *ctx) +{ + struct sid2gid_state *state = talloc_get_type(ctx->async.private_data, + struct sid2gid_state); + + struct id_mapping *ids = NULL; + + state->ctx->status = wb_sids2xids_recv(ctx, &ids); + if (!composite_is_ok(state->ctx)) return; + + if (!NT_STATUS_IS_OK(ids->status)) { + composite_error(state->ctx, ids->status); + return; + } + + if (ids->unixid->type == ID_TYPE_BOTH || + ids->unixid->type == ID_TYPE_GID) { + state->gid = ids->unixid->id; + composite_done(state->ctx); + } else { + composite_error(state->ctx, NT_STATUS_INVALID_SID); + } +} + NTSTATUS wb_sid2gid_recv(struct composite_context *ctx, gid_t *gid) { NTSTATUS status = composite_wait(ctx); diff --git a/source4/winbind/wb_sid2uid.c b/source4/winbind/wb_sid2uid.c index 0de45fdea9..b65e41978c 100644 --- a/source4/winbind/wb_sid2uid.c +++ b/source4/winbind/wb_sid2uid.c @@ -3,7 +3,7 @@ Map a SID to a uid - Copyright (C) Kai Blin 2007-2008 + Copyright (C) 2007-2008 Kai Blin 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 @@ -33,11 +33,14 @@ struct sid2uid_state { uid_t uid; }; +static void sid2uid_recv_uid(struct composite_context *ctx); + struct composite_context *wb_sid2uid_send(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, const struct dom_sid *sid) { - struct composite_context *result; + struct composite_context *result, *ctx; struct sid2uid_state *state; + struct id_mapping *ids; DEBUG(5, ("wb_sid2uid_send called\n")); @@ -45,24 +48,49 @@ struct composite_context *wb_sid2uid_send(TALLOC_CTX *mem_ctx, if (!result) return NULL; state = talloc(result, struct sid2uid_state); - if(composite_nomem(state, result)) return result; + if (composite_nomem(state, result)) return result; state->ctx = result; result->private_data = state; state->service = service; - state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state, sid, - &state->uid); - if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { - state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state, - sid, &state->uid); - } - if (!composite_is_ok(state->ctx)) return result; + ids = talloc(result, struct id_mapping); + if (composite_nomem(ids, result)) return result; + + ids->sid = dom_sid_dup(result, sid); + if (composite_nomem(ids->sid, result)) return result; + + ctx = wb_sids2xids_send(result, service, 1, ids); + if (composite_nomem(ctx, result)) return result; - composite_done(state->ctx); + composite_continue(result, ctx, sid2uid_recv_uid, state); return result; } +static void sid2uid_recv_uid(struct composite_context *ctx) +{ + struct sid2uid_state *state = talloc_get_type(ctx->async.private_data, + struct sid2uid_state); + + struct id_mapping *ids = NULL; + + state->ctx->status = wb_sids2xids_recv(ctx, &ids); + if (!composite_is_ok(state->ctx)) return; + + if (!NT_STATUS_IS_OK(ids->status)) { + composite_error(state->ctx, ids->status); + return; + } + + if (ids->unixid->type == ID_TYPE_BOTH || + ids->unixid->type == ID_TYPE_UID) { + state->uid = ids->unixid->id; + composite_done(state->ctx); + } else { + composite_error(state->ctx, NT_STATUS_INVALID_SID); + } +} + NTSTATUS wb_sid2uid_recv(struct composite_context *ctx, uid_t *uid) { NTSTATUS status = composite_wait(ctx); diff --git a/source4/winbind/wb_sids2xids.c b/source4/winbind/wb_sids2xids.c new file mode 100644 index 0000000000..302b915ff5 --- /dev/null +++ b/source4/winbind/wb_sids2xids.c @@ -0,0 +1,82 @@ +/* + Unix SMB/CIFS implementation. + + Map SIDs to unixids. + + Copyright (C) 2008 Kai Blin + + 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 . +*/ + +#include "includes.h" +#include "libcli/composite/composite.h" +#include "winbind/wb_server.h" +#include "smbd/service_task.h" +#include "winbind/wb_helper.h" +#include "libcli/security/proto.h" +#include "winbind/idmap.h" + +struct sids2xids_state { + struct composite_context *ctx; + struct wbsrv_service *service; + struct id_mapping *ids; + int count; +}; + +struct composite_context *wb_sids2xids_send(TALLOC_CTX *mem_ctx, + struct wbsrv_service *service, + int count, struct id_mapping *ids) +{ + struct composite_context *result; + struct sids2xids_state *state; + + DEBUG(5, ("wb_sids2xids_send called\n")); + + result = composite_create(mem_ctx, service->task->event_ctx); + if (!result) return NULL; + + state = talloc(result, struct sids2xids_state); + if (composite_nomem(state, result)) return result; + + state->ctx = result; + result->private_data = state; + state->service = service; + state->count = count; + state->ids = ids; + + state->ctx->status = idmap_sids_to_xids(service->idmap_ctx, mem_ctx, + count, state->ids); + if (!composite_is_ok(state->ctx)) return result; + + composite_done(state->ctx); + return result; +} + +NTSTATUS wb_sids2xids_recv(struct composite_context *ctx, + struct id_mapping **ids) +{ + NTSTATUS status = composite_wait(ctx); + + DEBUG(5, ("wb_sids2xids_recv called\n")); + + if (NT_STATUS_IS_OK(status)) { + struct sids2xids_state *state = + talloc_get_type(ctx->private_data, + struct sids2xids_state); + *ids = state->ids; + } + talloc_free(ctx); + return status; +} + diff --git a/source4/winbind/wb_uid2sid.c b/source4/winbind/wb_uid2sid.c index e81d2e4671..fd43dd64b9 100644 --- a/source4/winbind/wb_uid2sid.c +++ b/source4/winbind/wb_uid2sid.c @@ -3,7 +3,7 @@ Command backend for wbinfo -U - Copyright (C) Kai Blin 2007-2008 + Copyright (C) 2007-2008 Kai Blin 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 @@ -33,35 +33,62 @@ struct uid2sid_state { struct dom_sid *sid; }; +static void uid2sid_recv_sid(struct composite_context *ctx); + struct composite_context *wb_uid2sid_send(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, uid_t uid) { - struct composite_context *result; + struct composite_context *result, *ctx; struct uid2sid_state *state; + struct unixid *unixid; + struct id_mapping *ids; DEBUG(5, ("wb_uid2sid_send called\n")); result = composite_create(mem_ctx, service->task->event_ctx); if (!result) return NULL; - state = talloc(mem_ctx, struct uid2sid_state); + state = talloc(result, struct uid2sid_state); if (composite_nomem(state, result)) return result; state->ctx = result; result->private_data = state; state->service = service; - state->ctx->status = idmap_uid_to_sid(service->idmap_ctx, mem_ctx, uid, - &state->sid); - if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { - state->ctx->status = idmap_uid_to_sid(service->idmap_ctx, - mem_ctx, uid, - &state->sid); + unixid = talloc(result, struct unixid); + if (composite_nomem(unixid, result)) return result; + unixid->id = uid; + unixid->type = ID_TYPE_UID; + + ids = talloc(result, struct id_mapping); + if (composite_nomem(ids, result)) return result; + ids->unixid = unixid; + ids->sid = NULL; + + ctx = wb_xids2sids_send(result, service, 1, ids); + if (composite_nomem(ctx, result)) return result; + + composite_continue(result, ctx, uid2sid_recv_sid, state); + return result; +} + +static void uid2sid_recv_sid(struct composite_context *ctx) +{ + struct uid2sid_state *state = talloc_get_type(ctx->async.private_data, + struct uid2sid_state); + struct id_mapping *ids = NULL; + + state->ctx->status = wb_xids2sids_recv(ctx, &ids); + if (!composite_is_ok(state->ctx)) return; + + if (!NT_STATUS_IS_OK(ids->status)) { + composite_error(state->ctx, ids->status); + return; } - if (!composite_is_ok(state->ctx)) return result; + + state->sid = ids->sid; composite_done(state->ctx); - return result; } NTSTATUS wb_uid2sid_recv(struct composite_context *ctx, TALLOC_CTX *mem_ctx, diff --git a/source4/winbind/wb_xids2sids.c b/source4/winbind/wb_xids2sids.c new file mode 100644 index 0000000000..843d292c07 --- /dev/null +++ b/source4/winbind/wb_xids2sids.c @@ -0,0 +1,82 @@ +/* + Unix SMB/CIFS implementation. + + Convet an unixid struct to a SID + + Copyright (C) 2008 Kai Blin + + 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 . +*/ + +#include "includes.h" +#include "libcli/composite/composite.h" +#include "winbind/wb_server.h" +#include "smbd/service_task.h" +#include "winbind/wb_helper.h" +#include "libcli/security/proto.h" +#include "winbind/idmap.h" + +struct xids2sids_state { + struct composite_context *ctx; + struct wbsrv_service *service; + struct id_mapping *ids; + int count; +}; + +struct composite_context *wb_xids2sids_send(TALLOC_CTX *mem_ctx, + struct wbsrv_service *service, + int count, struct id_mapping *ids) +{ + struct composite_context *result; + struct xids2sids_state *state; + + DEBUG(0, ("wb_xids2sids_send called\n")); + + result = composite_create(mem_ctx, service->task->event_ctx); + if (!result) return NULL; + + state = talloc(mem_ctx, struct xids2sids_state); + if (composite_nomem(state, result)) return result; + + state->ctx = result; + result->private_data = state; + state->service = service; + state->count = count; + state->ids = ids; + + state->ctx->status = idmap_xids_to_sids(service->idmap_ctx, mem_ctx, + count, state->ids); + if (!composite_is_ok(state->ctx)) return result; + + composite_done(state->ctx); + return result; +} + +NTSTATUS wb_xids2sids_recv(struct composite_context *ctx, + struct id_mapping **ids) +{ + NTSTATUS status = composite_wait(ctx); + + DEBUG(0, ("wb_xids2sids_recv called.\n")); + + if (NT_STATUS_IS_OK(status)) { + struct xids2sids_state *state = + talloc_get_type(ctx->private_data, + struct xids2sids_state); + *ids = state->ids; + } + talloc_free(ctx); + return status; +} + -- cgit From 297399d877476bd72fbf8055cd728b6f8230ba09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 09:36:29 +0100 Subject: selftest: use a separate var for printing out sub parts of lines with \r This restores the bahavior of the $_ variable in the code that detects expected failures. metze (This used to be commit 903eb9a23d80576f5df2d90a0e025f2366ffe4c6) --- source4/selftest/Subunit.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index f8a7794aac..1c279437c8 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -17,6 +17,7 @@ sub parse_results($$$$$) while(1) { my $line = ""; + my $subline = ""; my $char = ""; my $eof = 0; my $error = 0; @@ -33,9 +34,10 @@ sub parse_results($$$$$) } $line .= $char; + $subline .= $char; if ($char eq "\r") { - $msg_ops->output_msg($line); - $line = ""; + $msg_ops->output_msg($subline); + $subline = ""; } } -- cgit From 3b63333cf272fae301e22e9a021f0bbf60d1c413 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 21:47:22 +0100 Subject: Allocate one 0-byte in asprintf replacement when len==0 Some S3 code depends on this. (cherry picked from commit dc3d5e16452bf30055638ba3cfe99097fb557156) (This used to be commit 842d144b4fb0981250157f72956e732709663107) --- source4/lib/replace/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 9f8a7657e5..a174dcffed 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1264,7 +1264,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, VA_COPY(ap2, ap); ret = vsnprintf(NULL, 0, format, ap2); va_end(ap2); - if (ret <= 0) return ret; + if (ret < 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; -- cgit From 5b35e551300419d75b2405ba76bff8e7ec5a01af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 15:36:03 +0100 Subject: selftest: fix parsing of Subunit results This reverts parts of 903eb9a23d80576f5df2d90a0e025f2366ffe4c6 and 9196213c49532ac60349ff55e66430b7c80b09c2. metze (This used to be commit 5f5fa368c2ca472409c0082400b6e26029dfd7b5) --- source4/selftest/Subunit.pm | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'source4') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index 1c279437c8..e5c61ca9ba 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -15,36 +15,7 @@ sub parse_results($$$$$) my $unexpected_err = 0; my $orig_open_len = $#$open_tests; - while(1) { - my $line = ""; - my $subline = ""; - my $char = ""; - my $eof = 0; - my $error = 0; - - while ($char ne "\n") { - my $ret = sysread($fh, $char, 1); - if (not defined($ret)) { - $error = $!; - last; - } - if ($ret == 0) { - $eof = 1; - last; - } - - $line .= $char; - $subline .= $char; - if ($char eq "\r") { - $msg_ops->output_msg($subline); - $subline = ""; - } - } - - last if ($eof or $error); - - $_ = $line; - + while(<$fh>) { if (/^test: (.+)\n/) { $msg_ops->control_msg($_); $msg_ops->start_test($open_tests, $1); -- cgit From 92f6333535a57c034e2ceb3305b420c921a48094 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:29:13 +0100 Subject: ldb: fix the standalone build metze (This used to be commit 91b49365abed6f67e2b3c18b0090b4e6ff1df935) --- source4/lib/ldb/common/ldb.c | 2 +- source4/lib/ldb/common/ldb_modules.c | 10 +++++----- source4/lib/ldb/include/ldb_private.h | 4 ++-- source4/lib/ldb/ldb_ldap/ldb_ldap.c | 6 +++--- source4/lib/ldb/tests/sample_module.c | 2 +- source4/lib/ldb/tests/test-soloading.sh | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 3c9ef3ff69..b51c288993 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -65,7 +65,7 @@ static struct backends_list_entry { #ifdef HAVE_LDB_LDAP #define LDAP_INIT &ldb_ldap_backend_ops, \ - &ldb_ildap_backend_ops, \ + &ldb_ldapi_backend_ops, \ &ldb_ldaps_backend_ops, #else #define LDAP_INIT diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 7da7b9ba34..34e0afbf93 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -129,11 +129,11 @@ static struct ops_list_entry { #ifndef STATIC_LIBLDB_MODULES #define STATIC_LIBLDB_MODULES \ - ldb_operational_module_ops, \ - ldb_rdn_name_module_ops, \ - ldb_paged_results_module_ops, \ - ldb_sort_module_ops, \ - ldb_asq_module_ops, \ + &ldb_operational_module_ops, \ + &ldb_rdn_name_module_ops, \ + &ldb_paged_results_module_ops, \ + &ldb_server_sort_module_ops, \ + &ldb_asq_module_ops, \ NULL #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d2dcc675a5..0ffba9d99b 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -185,7 +185,7 @@ extern const struct ldb_module_ops ldb_paged_results_module_ops; extern const struct ldb_module_ops ldb_rdn_name_module_ops; extern const struct ldb_module_ops ldb_schema_module_ops; extern const struct ldb_module_ops ldb_asq_module_ops; -extern const struct ldb_module_ops ldb_sort_module_ops; +extern const struct ldb_module_ops ldb_server_sort_module_ops; extern const struct ldb_module_ops ldb_ldap_module_ops; extern const struct ldb_module_ops ldb_ildap_module_ops; extern const struct ldb_module_ops ldb_tdb_module_ops; @@ -194,7 +194,7 @@ extern const struct ldb_module_ops ldb_sqlite3_module_ops; extern const struct ldb_backend_ops ldb_tdb_backend_ops; extern const struct ldb_backend_ops ldb_sqlite3_backend_ops; extern const struct ldb_backend_ops ldb_ldap_backend_ops; -extern const struct ldb_backend_ops ldb_ildap_backend_ops; +extern const struct ldb_backend_ops ldb_ldapi_backend_ops; extern const struct ldb_backend_ops ldb_ldaps_backend_ops; int ldb_match_msg(struct ldb_context *ldb, diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 3f6ff3fd5b..a4534c549a 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -826,17 +826,17 @@ failed: return -1; } -_PUBLIC_ struct ldb_backend_ops ldb_ldap_backend_ops = { +const struct ldb_backend_ops ldb_ldap_backend_ops = { .name = "ldap", .connect_fn = lldb_connect }; -_PUBLIC_ struct ldb_backend_ops ldb_ldapi_backend_ops = { +const struct ldb_backend_ops ldb_ldapi_backend_ops = { .name = "ldapi", .connect_fn = lldb_connect }; -_PUBLIC_ struct ldb_backend_ops ldb_ldaps_backend_ops = { +const struct ldb_backend_ops ldb_ldaps_backend_ops = { .name = "ldaps", .connect_fn = lldb_connect }; diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c index 98d8e865dd..1a9e72c907 100644 --- a/source4/lib/ldb/tests/sample_module.c +++ b/source4/lib/ldb/tests/sample_module.c @@ -32,7 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req) return ldb_next_request(mod, req); } -_PUBLIC_ const struct ldb_module_ops ldb_sample_module_ops = { +const struct ldb_module_ops ldb_sample_module_ops = { .name = "sample", .add = sample_add, }; diff --git a/source4/lib/ldb/tests/test-soloading.sh b/source4/lib/ldb/tests/test-soloading.sh index c42c9b22ba..da6d57541e 100755 --- a/source4/lib/ldb/tests/test-soloading.sh +++ b/source4/lib/ldb/tests/test-soloading.sh @@ -19,7 +19,7 @@ fi cat < Date: Tue, 18 Mar 2008 14:29:43 +0100 Subject: ldb: nothing uses "system/network.h" so don't include it metze (This used to be commit 087667e0cd66ea615b5aa43538192fe1d7de87ae) --- source4/lib/ldb/include/ldb_includes.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index e2bcca2b04..cc9b46ac1f 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -18,7 +18,6 @@ #include "replace.h" #include "system/filesys.h" -#include "system/network.h" #include "system/time.h" #include "talloc.h" #include "ldb.h" -- cgit From d53467b9afbd90928ce51c5c6adcf51f2c6643c3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:31:49 +0100 Subject: ldb: remove configure with 'make realdistclean' configure.in doesn't exist at all... metze (This used to be commit ca414d4e9e96b90100c46b006825bc8e935ba0b4) --- source4/lib/ldb/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index d88f82b726..a53c5542da 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -121,7 +121,7 @@ distclean:: clean rm -f Makefile realdistclean:: distclean - rm -f configure.in include/config.h.in + rm -f configure include/config.h.in check:: test @PYTHON_CHECK_TARGET@ -- cgit From cbc5e58b8f8d6a7ec34f17e263b88a3e7e39b095 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:52:36 +0100 Subject: libreplace: combine SOCKET_LIBS and NSL_LIBS to LIBREPLACE_NETWORK_LIBS But keep the old ones untill the callers are fixed. metze (This used to be commit e7115dcc8a0a4f420de7a901e3a21d4f35a6fcf9) --- source4/lib/replace/socket.m4 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index c0c8f93e81..ab948c1445 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -7,10 +7,10 @@ dnl only looks in /etc/hosts), so we only look for -lsocket if we need dnl it. AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) dnl We can't just call AC_CHECK_FUNCS(connect) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || @@ -24,9 +24,9 @@ fi AC_CHECK_FUNCS(gethostbyname) if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || @@ -38,3 +38,5 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" +NSL_LIBS="" -- cgit From 1ef171f6e00470276b65289878d0006dc9b7f97f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:53:59 +0100 Subject: libreplace: use LIBREPLACE_NETWORK_LIBS within some configure checks ...instead of using SOCKET_LIBS and NSL_LIBS. metze (This used to be commit cef2e8d748756f61c248ad6660e85dd1ac36308a) --- source4/lib/replace/configure.ac | 2 +- source4/lib/replace/getifaddrs.m4 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 298f5a67f9..02dc08bf72 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -21,7 +21,7 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi -LIBS="$SOCKET_LIBS $NSL_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" AC_SUBST(LIBS) AC_SUBST(LDFLAGS) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index f4cf4e48a2..927bc677db 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -34,10 +34,10 @@ fi ################## # look for a method of finding the list of network interfaces # -# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" +# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" # old_LIBS=$LIBS -LIBS="$NSL_LIBS $SOCKET_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir" iface=no; -- cgit From 23c35481fa0e0168d89c91c8bc3cb8d3cf82c213 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:55:05 +0100 Subject: libreplace: for samba4 create LIBREPLACE_NETWORK as EXT_LIB metze (This used to be commit 79037c31334e271a718fcac234148038814b591e) --- source4/lib/replace/samba.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index a2e04f53b1..e62c3d3cd1 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -3,6 +3,9 @@ AC_LIBREPLACE_BROKEN_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) +SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) +SMB_ENABLE(LIBREPLACE_NETWORK) + # remove leading ./ LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` -- cgit From 7b412ccade76ebd7b64096eb522fdaf1590cd694 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:59:10 +0100 Subject: lib/socket: use LIBREPLACE_NETWORK instead of EXT_SOCKET and EXT_NSL The configure checks are also in libreplace now. metze (This used to be commit 07e931a77f21e025281b6285f4ce7aebf1106b86) --- source4/lib/socket/config.m4 | 44 -------------------------------------------- source4/lib/socket/config.mk | 6 +++--- 2 files changed, 3 insertions(+), 47 deletions(-) (limited to 'source4') diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4 index a713090c6d..b40002b321 100644 --- a/source4/lib/socket/config.m4 +++ b/source4/lib/socket/config.m4 @@ -11,50 +11,6 @@ if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property]) fi -# The following test taken from the cvs sources -# If we can't find connect, try looking in -lsocket, -lnsl, and -linet. -# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has -# libsocket.so which has a bad implementation of gethostbyname (it -# only looks in /etc/hosts), so we only look for -lsocket if we need -# it. -AC_CHECK_FUNCS(connect) -if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) - SMB_ENABLE(EXT_SOCKET,YES) - dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value - dnl has been cached. - if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || - test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || - test x"$ac_cv_lib_ext_socket_connect" = x"yes" || - test x"$ac_cv_lib_ext_inet_connect" = x"yes"; then - AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) - else - AC_MSG_ERROR([no connect() function available!]) - fi -fi - -SMB_EXT_LIB(EXT_SOCKET,[${SOCKET_LIBS}],[${SOCKET_CFLAGS}],[${SOCKET_CPPFLAGS}],[${SOCKET_LDFLAGS}]) - -AC_CHECK_FUNCS(gethostbyname) -if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) - SMB_ENABLE(EXT_NSL,YES) - dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, because the value - dnl has been cached. - if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" != x"yes" && - test x"$ac_cv_lib_ext_nsl_gethostbyname" != x"yes" && - test x"$ac_cv_lib_ext_socket_gethostbyname" != x"yes"; then - AC_MSG_ERROR([no gethostbyname() function available!]) - fi -fi - -SMB_EXT_LIB(EXT_NSL,[${NSL_LIBS}],[],[],[]) - ############################################ # check for unix domain sockets AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [ diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk index 5a7a62d8ae..777882f6e0 100644 --- a/source4/lib/socket/config.mk +++ b/source4/lib/socket/config.mk @@ -5,7 +5,7 @@ PRIVATE_PROTO_HEADER = netif_proto.h OBJ_FILES = \ interface.o \ netif.o -PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL EXT_SOCKET EXT_NSL +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBREPLACE_NETWORK # End SUBSYSTEM LIBNETIF ############################## @@ -16,7 +16,7 @@ SUBSYSTEM = samba-socket OUTPUT_TYPE = MERGED_OBJ OBJ_FILES = \ socket_ip.o -PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL LIBSAMBA-ERRORS +PRIVATE_DEPENDENCIES = LIBSAMBA-ERRORS LIBREPLACE_NETWORK # End MODULE socket_ip ################################################ @@ -27,7 +27,7 @@ SUBSYSTEM = samba-socket OUTPUT_TYPE = MERGED_OBJ OBJ_FILES = \ socket_unix.o -PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL +PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK # End MODULE socket_unix ################################################ -- cgit From 7a5438ae111416ce33ffd8f0468fd031ae58577a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 15:01:34 +0100 Subject: libreplace: remove unused SOCKET_LIBS and NSL_LIBS metze (This used to be commit 62bb177a6e4a3e1f949b78c7cd7583f2e1271739) --- source4/lib/replace/socket.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index ab948c1445..984f81f15f 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -37,6 +37,3 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then [Whether the system has gethostbyname()]) fi fi - -SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" -NSL_LIBS="" -- cgit From 195853464a883b1dd29f7eca73e6b0a057ceae4c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 13:02:32 +0100 Subject: smbtorture: fix typos in RAW-OPLOCK output. Michael (This used to be commit 9fa4b53b61064c910b8f5c9c676c971023b8670c) --- source4/torture/raw/oplock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 5ab43d5e78..8b2e4fb177 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -2539,7 +2539,7 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ int te; if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT22 disabled against samba3\n"); + torture_skip(tctx, "BATCH22 disabled against samba3\n"); } if (!torture_setup_dir(cli1, BASEDIR)) { @@ -2629,7 +2629,7 @@ static bool test_raw_oplock_batch23(struct torture_context *tctx, struct smbcli_ struct smbcli_state *cli3 = NULL; if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT23 disabled against samba3\n"); + torture_skip(tctx, "BATCH23 disabled against samba3\n"); } if (!torture_setup_dir(cli1, BASEDIR)) { -- cgit From 58dfb0ff3cb9a75e8caad89819f586b64df05f8a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 15:53:38 +0100 Subject: libreplace: put inet_aton.c under LGPL instead of GPL. Michael (This used to be commit cca5d6626fe395f08fd4c8b2344e4e43646cb987) --- source4/lib/replace/inet_aton.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c index 3eb58f000c..c6b3bb11a7 100644 --- a/source4/lib/replace/inet_aton.c +++ b/source4/lib/replace/inet_aton.c @@ -3,18 +3,22 @@ * replacement functions * Copyright (C) Michael Adam 2008 * - * 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. + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL * - * This program is distributed in the hope that it will be useful, + * 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 + * version 3 of the License, or (at your option) any later version. + * + * This library 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser 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 . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . */ #include "replace.h" -- cgit From 87b48a812683794935db950446e9fb1db8e3da48 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 12:16:47 +0100 Subject: libreplace: replace inet_ntoa() when it is missing ...not only replace it when it is broken. This moves the defintion of rep_inet_ntoa from replace.c to inet_ntoa.c and adds configure checks for existence of inet_ntoa(). Checks are moved to an include file of its own. NOTE: The original rep_inet_ntoa in replace.c was wrapped into a "#ifndef WITH_PTHREADS" but the prototype in replace.h and the define in system/network.h were not. I removed that ifndef since the inet_ntoa() function is usually not thread safe anyways, since it returns a pointer to a static buffer. So whoever calls inet_ntoa() should be aware that it is not thread safe anyways. Michael (This used to be commit 974c0c45ad42644348e0b55454715b12158f1028) --- source4/lib/replace/inet_ntoa.c | 39 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/inet_ntoa.m4 | 19 ++++++++++++++++++ source4/lib/replace/libreplace.m4 | 19 +----------------- source4/lib/replace/replace.c | 14 ------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/system/network.h | 2 +- 6 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 source4/lib/replace/inet_ntoa.c create mode 100644 source4/lib/replace/inet_ntoa.m4 (limited to 'source4') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c new file mode 100644 index 0000000000..f3e733fa61 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.c @@ -0,0 +1,39 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Andrew Tridgell 2003 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** 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 + * version 3 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +/** + * NOTE: this is not thread safe, but it can't be, either + * since it returns a pointer to static memory. + */ +char *rep_inet_ntoa(struct in_addr ip) +{ + uint8_t *p = (uint8_t *)&ip.s_addr; + static char buf[18]; + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); + return buf; +} diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 new file mode 100644 index 0000000000..c1de4134d9 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.m4 @@ -0,0 +1,19 @@ +AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) + +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index e6e7198abf..3da2a90a99 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -120,24 +120,6 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -main() { struct in_addr ip; ip.s_addr = 0x12345678; -if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } -exit(1);}], - libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) -if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) -fi - AC_HAVE_TYPE([socklen_t],[#include ]) AC_HAVE_TYPE([sa_family_t],[#include ]) AC_HAVE_TYPE([struct addrinfo], [#include ]) @@ -348,6 +330,7 @@ m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b2a240e8ab..c16bded963 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -295,20 +295,6 @@ char *rep_strdup(const char *s) } #endif /* HAVE_STRDUP */ -#ifndef WITH_PTHREADS -/* REWRITE: not thread safe */ -#ifdef REPLACE_INET_NTOA -char *rep_inet_ntoa(struct in_addr ip) -{ - uint8_t *p = (uint8_t *)&ip.s_addr; - static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", - (int)p[0], (int)p[1], (int)p[2], (int)p[3]); - return buf; -} -#endif /* REPLACE_INET_NTOA */ -#endif - #ifndef HAVE_SETLINEBUF void rep_setlinebuf(FILE *stream) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 00c8230e6b..383536da65 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -325,7 +325,7 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif -#ifdef REPLACE_INET_NTOA +#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) #define inet_ntoa rep_inet_ntoa /* prototype is in "system/network.h" */ #endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 8c606c8f2d..7c2377301b 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -88,7 +88,7 @@ typedef int socklen_t; #endif -#ifdef REPLACE_INET_NTOA +#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); #endif -- cgit From 4500b95c89b6b692bd2842e902367663ac2351ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 13:10:22 +0100 Subject: libreplace: remove trailing white spaces. Michael (This used to be commit 1f9ca7eed965904f67cf78fbac007432b8a057fd) --- source4/lib/replace/inet_ntoa.c | 2 +- source4/lib/replace/inet_ntoa.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c index f3e733fa61..e3b80ebef8 100644 --- a/source4/lib/replace/inet_ntoa.c +++ b/source4/lib/replace/inet_ntoa.c @@ -33,7 +33,7 @@ char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", + slprintf(buf, 17, "%d.%d.%d.%d", (int)p[0], (int)p[1], (int)p[2], (int)p[3]); return buf; } diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 index c1de4134d9..5aaa9350c5 100644 --- a/source4/lib/replace/inet_ntoa.m4 +++ b/source4/lib/replace/inet_ntoa.m4 @@ -11,7 +11,7 @@ AC_TRY_RUN([ #endif main() { struct in_addr ip; ip.s_addr = 0x12345678; if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then -- cgit From 4d16e17e04c6fd62ebfa36085bcf38d2507737e6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 16:31:15 +0100 Subject: libreplace: remove duplicate entry of inet_ntoa from README. Michael (This used to be commit 98ee8c84300757d778733a458c6ca3e6022b40ea) --- source4/lib/replace/README | 1 - 1 file changed, 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index aae1ccb56f..43f7b08572 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -15,7 +15,6 @@ rename initgroups memmove strdup -inet_ntoa setlinebuf vsyslog timegm -- cgit From 7fb3963032ce8f6b7f5c652dd69d3315cae897ea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:42:43 +0100 Subject: Check the return value of fgets (cherry picked from commit b8aaa9a69fd6217ce0387ef8e84f316706186d70) (This used to be commit 8f58d39c0c621e9da85308d721a146352cc4939e) --- source4/lib/replace/getpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index d91d029f6a..57e28eb981 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt) buf[0] = 0; if (!gotintr) { in_fd = fileno(in); - fgets(buf, bufsize, in); + if (fgets(buf, bufsize, in) == NULL) { + buf[0] = 0; + return buf; + } } nread = strlen(buf); if (nread) { -- cgit From 6f6d38d24a69aec614e443c6a5cd0d6ed6b1b70e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 22:27:05 +0100 Subject: Fix Coverity ID 554 (cherry picked from commit 471b1b0c58bc2def5d2fe9d98401def34724d447) (This used to be commit effda48a2670325fed56e158539417c6f95381b8) --- source4/lib/replace/getpass.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 57e28eb981..73333b9021 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,6 +187,9 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; + if (in && in != stdin) { + fclose(in); + } return buf; } } -- cgit From 1268be9f88a1716c9b01b10fef0de5428ef65b3c Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Thu, 28 Feb 2008 11:58:05 -0600 Subject: Fix macro name (no 's' in ifr_addr). Interface detection on Solaris still failing due to items pointed out here: http://lists.samba.org/archive/samba-technical/2007-November/056701.html (cherry picked from commit 37c87acc9d48c1fb5d4806374ca8e992300db1ff) (This used to be commit 5757d8dfe9e6cf7b662acdf5c3d825f0021822c0) --- source4/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 7c2377301b..f943a7fd87 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -310,7 +310,7 @@ struct addrinfo { /* Needed for some systems that don't define it (Solaris). */ #ifndef ifr_netmask -#define ifr_netmask ifr_addrs +#define ifr_netmask ifr_addr #endif #ifdef SOCKET_WRAPPER -- cgit From 7d336254cedea6c7afd70bae287050f9ee61c506 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 16:53:21 +0100 Subject: ldb: not every shell supports '==' so use '=' metze (This used to be commit b5eeaf9b27e0116e57825b664642d2b5cfd895f0) --- source4/lib/ldb/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/ldb/rules.mk b/source4/lib/ldb/rules.mk index 534ba016ab..ff5dc02742 100644 --- a/source4/lib/ldb/rules.mk +++ b/source4/lib/ldb/rules.mk @@ -7,7 +7,7 @@ ctags: .SUFFIXES: _wrap.c .i .i_wrap.c: - [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -python -keyword $< + [ "$(SWIG)" = "no" ] || $(SWIG) -O -Wall -python -keyword $< .SUFFIXES: .1 .1.xml .3 .3.xml .xml .html .c .o -- cgit From 124f82efe13a453a3f5857c1e25584536147c3dc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:20:47 +0100 Subject: libreplace: move rep_socketpair() to its own module. Prototype is now in system/network.h, implementation in socketpair.c, and check in socketpair.m4. Now the last networking function has vanished from replace.c. Michael (This used to be commit 94ac8a25be15b55f66eff96fdddc2fdc71a43b1e) --- source4/lib/replace/libreplace.m4 | 3 ++- source4/lib/replace/replace.c | 22 ----------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/socketpair.c | 46 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/socketpair.m4 | 1 + source4/lib/replace/system/network.h | 5 ++++ 6 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 source4/lib/replace/socketpair.c create mode 100644 source4/lib/replace/socketpair.m4 (limited to 'source4') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 3da2a90a99..8e17258918 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -158,7 +158,7 @@ fi AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_CHECK_FUNCS(isatty) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) @@ -334,6 +334,7 @@ m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) +m4_include(socketpair.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c16bded963..a6a8c0b6ed 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -585,25 +585,3 @@ int rep_unsetenv(const char *name) return 0; } #endif - -#ifndef HAVE_SOCKETPAIR -int rep_socketpair(int d, int type, int protocol, int sv[2]) -{ - if (d != AF_UNIX) { - errno = EAFNOSUPPORT; - return -1; - } - - if (protocol != 0) { - errno = EPROTONOSUPPORT; - return -1; - } - - if (type != SOCK_STREAM) { - errno = EOPNOTSUPP; - return -1; - } - - return pipe(sv); -} -#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 383536da65..5fe79394eb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -212,7 +212,7 @@ int rep_dlclose(void *handle); #ifndef HAVE_SOCKETPAIR #define socketpair rep_socketpair -int rep_socketpair(int d, int type, int protocol, int sv[2]); +/* prototype is in system/network.h */ #endif #ifndef PRINTF_ATTRIBUTE diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c new file mode 100644 index 0000000000..c775730952 --- /dev/null +++ b/source4/lib/replace/socketpair.c @@ -0,0 +1,46 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Jelmer Vernooij 2006 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** 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 + * version 3 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +int rep_socketpair(int d, int type, int protocol, int sv[2]) +{ + if (d != AF_UNIX) { + errno = EAFNOSUPPORT; + return -1; + } + + if (protocol != 0) { + errno = EPROTONOSUPPORT; + return -1; + } + + if (type != SOCK_STREAM) { + errno = EOPNOTSUPP; + return -1; + } + + return pipe(sv); +} diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4 new file mode 100644 index 0000000000..7088334cda --- /dev/null +++ b/source4/lib/replace/socketpair.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index f943a7fd87..a5fb813aa1 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -143,6 +143,11 @@ int rep_getifaddrs(struct ifaddrs **); void rep_freeifaddrs(struct ifaddrs *); #endif +#ifndef HAVE_SOCKETPAIR +/* define is in "replace.h" */ +int rep_socketpair(int d, int type, int protocol, int sv[2]); +#endif + /* * Some systems have getaddrinfo but not the * defines needed to use it. -- cgit From a310b0b84369da95c059ddb6ae90a524062eadd5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:50:23 +0100 Subject: libreplace: replace.c does not need system/network.h anymore. Michael (This used to be commit 2d3c2f34f33338ff422047dae9cc262522689328) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index a6a8c0b6ed..6930f9b079 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -27,7 +27,6 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" -#include "system/network.h" #include "system/locale.h" #include "system/wait.h" -- cgit From 0372704fa2e24c6e0bcfe5fb431058d3186dc621 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 17:58:36 +0100 Subject: heimdal_build: use LIBREPLACE_NETWORK because EXT_SOCKET and EXT_NSL doesn't exist anymore metze (This used to be commit 0fb3d246212e2e7d68c1276dff1628ece9794283) --- source4/heimdal_build/config.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk index 45bfd8e81f..e6bb73a385 100644 --- a/source4/heimdal_build/config.mk +++ b/source4/heimdal_build/config.mk @@ -415,7 +415,7 @@ PUBLIC_DEPENDENCIES = \ HEIMDAL_ROKEN_GETPROGNAME \ HEIMDAL_ROKEN_CLOSEFROM \ RESOLV \ - EXT_SOCKET + LIBREPLACE_NETWORK # End SUBSYSTEM HEIMDAL_ROKEN ####################### @@ -475,7 +475,7 @@ OBJ_FILES = \ ../heimdal/lib/vers/print_version.ho \ ../lib/socket_wrapper/socket_wrapper.ho \ replace.ho -PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H EXT_SOCKET EXT_NSL +PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK # End BINARY asn1_compile ####################### @@ -502,7 +502,7 @@ OBJ_FILES = ../heimdal/lib/vers/print_version.ho \ ../heimdal/lib/roken/setprogname.ho \ ../lib/socket_wrapper/socket_wrapper.ho \ replace.ho -PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H EXT_SOCKET EXT_NSL +PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK # End BINARY compile_et ####################### -- cgit From d46636950d44d02de207b88e9c1a26721c4c7d95 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 17:59:31 +0100 Subject: socket_wrapper: use LIBREPLACE_NETWORK because EXT_SOCKET and EXT_NSL doesn't exist anymore metze (This used to be commit 1dd8e3775686badfd35dca23d291af93d8cf5695) --- source4/lib/socket_wrapper/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk index cc52a99801..2b9f30a7bb 100644 --- a/source4/lib/socket_wrapper/config.mk +++ b/source4/lib/socket_wrapper/config.mk @@ -2,7 +2,7 @@ # Start SUBSYSTEM SOCKET_WRAPPER [SUBSYSTEM::SOCKET_WRAPPER] OBJ_FILES = socket_wrapper.o -PRIVATE_DEPENDENCIES = EXT_SOCKET +PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK # End SUBSYSTEM SOCKET_WRAPPER ############################## -- cgit From 96197fa871db99ce3ca82ad718f3c442cec2ae3a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 18:02:23 +0100 Subject: libndr: EXT_NSL doesn't exist anymore, but it wasn't needed anyway metze (This used to be commit 33347928e17dead3485de7dcfb0915da4638da05) --- source4/librpc/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 7abc693960..a316e059b3 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -10,7 +10,7 @@ OBJ_FILES = \ ndr/ndr_basic.o \ ndr/ndr_string.o \ ndr/uuid.o -PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET EXT_NSL \ +PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET \ LIBSAMBA-CONFIG # End SUBSYSTEM LIBNDR ################################################ -- cgit From 52669d84722c175555e17a222077f845d9aa958f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 18:03:18 +0100 Subject: lib/util: use LIBREPLACE_NETWORK as EXT_NSL doesn't exist anymore metze (This used to be commit b7dad8674a3aaa27bc1103a83be75434d413239b) --- source4/lib/util/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index 16a0357df8..22e6617f7c 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -21,7 +21,7 @@ OBJ_FILES = xfile.o \ become_daemon.o PUBLIC_DEPENDENCIES = \ LIBTALLOC LIBCRYPTO \ - SOCKET_WRAPPER EXT_NSL \ + SOCKET_WRAPPER LIBREPLACE_NETWORK \ CHARSET EXECINFO PUBLIC_HEADERS += $(addprefix lib/util/, util.h \ -- cgit