[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-814-g05f7f77
Stefan Metzmacher
metze at samba.org
Fri Apr 11 14:00:27 GMT 2008
The branch, v3-2-test has been updated
via 05f7f77135ab997b92b2454871f21543ecbde0ed (commit)
via 2b236c7ace15b4408c31ed918b449d5a22e1769f (commit)
via dc9a3f8db0af03b4e8223068857092fcaff404f2 (commit)
via 364e146805bb74b46da4d3c187e9a684d4b99a01 (commit)
from c4e1439eded7bb4df60b9d4b457e5b7898928c9e (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 05f7f77135ab997b92b2454871f21543ecbde0ed
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Apr 11 15:16:51 2008 +0200
net: 'net' doesn't need wb_common.o anymore.
metze
commit 2b236c7ace15b4408c31ed918b449d5a22e1769f
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Apr 11 12:01:02 2008 +0200
nsswitch: remove unused nsswitch/wb_client.c
metze
commit dc9a3f8db0af03b4e8223068857092fcaff404f2
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Apr 11 12:00:29 2008 +0200
net_idmap: use wbcSet[U|G]idMapping() and wbcSet[U|G]idHwm() functions
metze
commit 364e146805bb74b46da4d3c187e9a684d4b99a01
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Apr 11 09:28:20 2008 +0200
libwbclient: add wbcSet[U|G]idMapping() and wbcSet[U|G]idHwm() functions
metze
-----------------------------------------------------------------------
Summary of changes:
source/Makefile.in | 4 +-
source/nsswitch/libwbclient/wbc_idmap.c | 149 +++++++++++++++++++++++++++++++
source/nsswitch/libwbclient/wbclient.h | 8 ++
source/nsswitch/wb_client.c | 96 --------------------
source/utils/net_idmap.c | 46 ++++++----
5 files changed, 186 insertions(+), 117 deletions(-)
delete mode 100644 source/nsswitch/wb_client.c
Changeset truncated at 500 lines:
diff --git a/source/Makefile.in b/source/Makefile.in
index d89278c..408a2f4 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -862,7 +862,7 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
$(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
utils/net_conf.o \
utils/net_registry.o \
- auth/token_util.o utils/net_dom.o nsswitch/wb_client.o
+ auth/token_util.o utils/net_dom.o
# these are not processed by make proto
NET_OBJ2 = utils/net_registry_util.o
@@ -879,7 +879,7 @@ NET_OBJ = $(NET_OBJ1) \
$(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \
$(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \
$(LIBSMBCONF_OBJ) \
- $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \
+ @LIBWBCLIENT_STATIC@ \
$(PRIVILEGES_BASIC_OBJ)
CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
diff --git a/source/nsswitch/libwbclient/wbc_idmap.c b/source/nsswitch/libwbclient/wbc_idmap.c
index 17f6fb8..e32d66c 100644
--- a/source/nsswitch/libwbclient/wbc_idmap.c
+++ b/source/nsswitch/libwbclient/wbc_idmap.c
@@ -272,3 +272,152 @@ wbcErr wbcAllocateGid(gid_t *pgid)
return wbc_status;
}
+/* we can't include smb.h here... */
+#define _ID_TYPE_UID 1
+#define _ID_TYPE_GID 2
+
+/** @brief Set an user id mapping
+ *
+ * @param uid Uid of the desired mapping.
+ * @param *sid Pointer to the sid of the diresired mapping.
+ *
+ * @return #wbcErr
+ **/
+wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *sid_string = NULL;
+
+ if (!sid) {
+ return WBC_ERR_INVALID_PARAM;
+ }
+
+ /* Initialise request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Make request */
+
+ request.data.dual_idmapset.id = uid;
+ request.data.dual_idmapset.type = _ID_TYPE_UID;
+
+ wbc_status = wbcSidToString(sid, &sid_string);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ strncpy(request.data.dual_idmapset.sid, sid_string,
+ sizeof(request.data.dual_idmapset.sid)-1);
+ wbcFreeMemory(sid_string);
+
+ wbc_status = wbcRequestResponse(WINBINDD_SET_MAPPING,
+ &request, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+ return wbc_status;
+}
+
+/** @brief Set a group id mapping
+ *
+ * @param gid Gid of the desired mapping.
+ * @param *sid Pointer to the sid of the diresired mapping.
+ *
+ * @return #wbcErr
+ **/
+wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *sid_string = NULL;
+
+ if (!sid) {
+ return WBC_ERR_INVALID_PARAM;
+ }
+
+ /* Initialise request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Make request */
+
+ request.data.dual_idmapset.id = gid;
+ request.data.dual_idmapset.type = _ID_TYPE_GID;
+
+ wbc_status = wbcSidToString(sid, &sid_string);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ strncpy(request.data.dual_idmapset.sid, sid_string,
+ sizeof(request.data.dual_idmapset.sid)-1);
+ wbcFreeMemory(sid_string);
+
+ wbc_status = wbcRequestResponse(WINBINDD_SET_MAPPING,
+ &request, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+ return wbc_status;
+}
+
+/** @brief Set the highwater mark for allocated uids.
+ *
+ * @param uid_hwm The new uid highwater mark value
+ *
+ * @return #wbcErr
+ **/
+wbcErr wbcSetUidHwm(uid_t uid_hwm)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+ /* Initialise request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Make request */
+
+ request.data.dual_idmapset.id = uid_hwm;
+ request.data.dual_idmapset.type = _ID_TYPE_UID;
+
+ wbc_status = wbcRequestResponse(WINBINDD_SET_HWM,
+ &request, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+ return wbc_status;
+}
+
+/** @brief Set the highwater mark for allocated gids.
+ *
+ * @param uid_hwm The new gid highwater mark value
+ *
+ * @return #wbcErr
+ **/
+wbcErr wbcSetGidHwm(gid_t gid_hwm)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+ /* Initialise request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Make request */
+
+ request.data.dual_idmapset.id = gid_hwm;
+ request.data.dual_idmapset.type = _ID_TYPE_GID;
+
+ wbc_status = wbcRequestResponse(WINBINDD_SET_HWM,
+ &request, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+ return wbc_status;
+}
diff --git a/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index 16b68c0..4e7e5af 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/nsswitch/libwbclient/wbclient.h
@@ -346,6 +346,14 @@ wbcErr wbcAllocateUid(uid_t *puid);
wbcErr wbcAllocateGid(gid_t *pgid);
+wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
+
+wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
+
+wbcErr wbcSetUidHwm(uid_t uid_hwm);
+
+wbcErr wbcSetGidHwm(gid_t gid_hwm);
+
/*
* NSS Lookup User/Group details
*/
diff --git a/source/nsswitch/wb_client.c b/source/nsswitch/wb_client.c
deleted file mode 100644
index 5e1a5d8..0000000
--- a/source/nsswitch/wb_client.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- winbind client code
-
- Copyright (C) Tim Potter 2000
- Copyright (C) Andrew Tridgell 2000
-
- 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "nsswitch/winbind_nss.h"
-#include "libwbclient/wbclient.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-NSS_STATUS winbindd_request_response(int req_type,
- struct winbindd_request *request,
- struct winbindd_response *response);
-
-bool winbind_set_mapping(const struct id_map *map)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- int result;
-
- /* Initialise request */
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Make request */
-
- request.data.dual_idmapset.id = map->xid.id;
- request.data.dual_idmapset.type = map->xid.type;
- sid_to_fstring(request.data.dual_idmapset.sid, map->sid);
-
- result = winbindd_request_response(WINBINDD_SET_MAPPING, &request, &response);
-
- return (result == NSS_STATUS_SUCCESS);
-}
-
-bool winbind_set_uid_hwm(unsigned long id)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- int result;
-
- /* Initialise request */
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Make request */
-
- request.data.dual_idmapset.id = id;
- request.data.dual_idmapset.type = ID_TYPE_UID;
-
- result = winbindd_request_response(WINBINDD_SET_HWM, &request, &response);
-
- return (result == NSS_STATUS_SUCCESS);
-}
-
-bool winbind_set_gid_hwm(unsigned long id)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- int result;
-
- /* Initialise request */
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Make request */
-
- request.data.dual_idmapset.id = id;
- request.data.dual_idmapset.type = ID_TYPE_GID;
-
- result = winbindd_request_response(WINBINDD_SET_HWM, &request, &response);
-
- return (result == NSS_STATUS_SUCCESS);
-}
diff --git a/source/utils/net_idmap.c b/source/utils/net_idmap.c
index f0c3e56..b002489 100644
--- a/source/utils/net_idmap.c
+++ b/source/utils/net_idmap.c
@@ -101,9 +101,10 @@ static int net_idmap_restore(int argc, const char **argv)
while (!feof(input)) {
char line[128], sid_string[128];
int len;
- DOM_SID sid;
- struct id_map map;
+ struct wbcDomainSid sid;
+ enum id_type type = ID_TYPE_NOT_SPECIFIED;
unsigned long idval;
+ wbcErr wbc_status;
if (fgets(line, 127, input) == NULL)
break;
@@ -114,21 +115,23 @@ static int net_idmap_restore(int argc, const char **argv)
line[len-1] = '\0';
if (sscanf(line, "GID %lu %128s", &idval, sid_string) == 2) {
- map.xid.type = ID_TYPE_GID;
- map.xid.id = idval;
+ type = ID_TYPE_GID;
} else if (sscanf(line, "UID %lu %128s", &idval, sid_string) == 2) {
- map.xid.type = ID_TYPE_UID;
- map.xid.id = idval;
+ type = ID_TYPE_UID;
} else if (sscanf(line, "USER HWM %lu", &idval) == 1) {
/* set uid hwm */
- if (! winbind_set_uid_hwm(idval)) {
- d_fprintf(stderr, "Could not set USER HWM\n");
+ wbc_status = wbcSetUidHwm(idval);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set USER HWM: %s\n",
+ wbcErrorString(wbc_status));
}
continue;
} else if (sscanf(line, "GROUP HWM %lu", &idval) == 1) {
/* set gid hwm */
- if (! winbind_set_gid_hwm(idval)) {
- d_fprintf(stderr, "Could not set GROUP HWM\n");
+ wbc_status = wbcSetGidHwm(idval);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set GROUP HWM: %s\n",
+ wbcErrorString(wbc_status));
}
continue;
} else {
@@ -136,20 +139,25 @@ static int net_idmap_restore(int argc, const char **argv)
continue;
}
- if (!string_to_sid(&sid, sid_string)) {
- d_fprintf(stderr, "ignoring invalid sid [%s]\n", sid_string);
+ wbc_status = wbcStringToSid(sid_string, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "ignoring invalid sid [%s]: %s\n",
+ sid_string, wbcErrorString(wbc_status));
continue;
}
- map.sid = &sid;
- if (!winbind_set_mapping(&map)) {
- d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s\n",
- (map.xid.type == ID_TYPE_GID) ? "GID" : "UID",
- (unsigned long)map.xid.id,
- sid_string_tos(map.sid));
+ if (type == ID_TYPE_UID) {
+ wbc_status = wbcSetUidMapping(idval, &sid);
+ } else {
+ wbc_status = wbcSetGidMapping(idval, &sid);
+ }
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s: %s\n",
+ (type == ID_TYPE_GID) ? "GID" : "UID",
+ idval, sid_string,
+ wbcErrorString(wbc_status));
continue;
}
-
}
if (input != stdin) {
--
Samba Shared Repository
More information about the samba-cvs
mailing list