]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: Move init_lsa_ref_domain_list to lib
authorChristof Schmitt <cs@samba.org>
Thu, 11 Sep 2014 23:11:06 +0000 (16:11 -0700)
committerKarolin Seeger <kseeger@samba.org>
Thu, 9 Oct 2014 19:10:04 +0000 (21:10 +0200)
This will be used in the next patch in winbind.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 16594e7fc0a46249a48d0d0635de0c1050ecd340)

source3/Makefile.in
source3/include/lsa.h [new file with mode: 0644]
source3/lib/lsa.c [new file with mode: 0644]
source3/rpc_server/lsa/srv_lsa_nt.c
source3/rpc_server/wscript_build
source3/wscript_build

index 8d2a2cdb9f515e3f268705164d5bea7b101ef2a4..9c1f0b9ee6502b93b7acbaa610eebcf7b4618540 100644 (file)
@@ -723,6 +723,8 @@ REG_FULL_OBJ = $(REG_SMBCONF_OBJ) \
 
 LIB_EVENTLOG_OBJ = lib/eventlog/eventlog.o
 
+LIB_LSA = lib/lsa.o
+
 DCE_RPC_EP_OBJ = librpc/rpc/dcerpc_ep.o
 
 RPC_LSARPC_OBJ = rpc_server/lsa/srv_lsa_nt.o \
@@ -806,6 +808,7 @@ RPC_SERVER_OBJ = $(RPC_LSARPC_OBJ) $(RPC_WINREG_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
                 $(LIBCLI_SRVSVC_OBJ) \
                 $(LIBCLI_LSA_OBJ) \
                 $(LIBCLI_SAMR_OBJ) \
+                $(LIB_LSA) \
                 $(RPC_SERVER_REGISTER_OBJ) \
                 $(RPC_CLIENT_SCHANNEL_OBJ) \
                 rpc_server/rpc_sock_helper.o \
@@ -1480,6 +1483,7 @@ WINBINDD_OBJ = \
                $(LIBCLI_DSSETUP_OBJ) \
                $(LIBCLI_LSA_OBJ) \
                $(LIBCLI_SAMR_OBJ) \
+               $(LIB_LSA) \
                rpc_client/init_samr.o \
                $(PAM_ERRORS_OBJ)
 
diff --git a/source3/include/lsa.h b/source3/include/lsa.h
new file mode 100644 (file)
index 0000000..7681aed
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Helper functions related to the LSA server
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef LSA_H
+#define LSA_H
+
+int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
+                            struct lsa_RefDomainList *ref,
+                            const char *dom_name,
+                            struct dom_sid *dom_sid);
+
+#endif
diff --git a/source3/lib/lsa.c b/source3/lib/lsa.c
new file mode 100644 (file)
index 0000000..0046fda
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Helper functions related to the LSA server
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/***************************************************************************
+ init_lsa_ref_domain_list - adds a domain if it's not already in, returns index.
+***************************************************************************/
+
+#include "includes.h"
+#include "libcli/security/dom_sid.h"
+#include "librpc/gen_ndr/lsa.h"
+#include "lsa.h"
+
+int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
+                            struct lsa_RefDomainList *ref,
+                            const char *dom_name,
+                            struct dom_sid *dom_sid)
+{
+       int num = 0;
+
+       if (dom_name != NULL) {
+               for (num = 0; num < ref->count; num++) {
+                       if (dom_sid_equal(dom_sid, ref->domains[num].sid)) {
+                               return num;
+                       }
+               }
+       } else {
+               num = ref->count;
+       }
+
+       if (num >= LSA_REF_DOMAIN_LIST_MULTIPLIER) {
+               /* index not found, already at maximum domain limit */
+               return -1;
+       }
+
+       ref->count = num + 1;
+       ref->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER;
+
+       ref->domains = talloc_realloc(mem_ctx, ref->domains,
+                                           struct lsa_DomainInfo, ref->count);
+       if (!ref->domains) {
+               return -1;
+       }
+
+       ZERO_STRUCT(ref->domains[num]);
+
+       ref->domains[num].name.string = dom_name;
+       ref->domains[num].sid = dom_sid_dup(mem_ctx, dom_sid);
+       if (!ref->domains[num].sid) {
+               return -1;
+       }
+
+       return num;
+}
index f4dc4afd57fa19997b3c65b34cd82e02a8a196af..46f42d532083d40448d0ec7cb5595385b78b777c 100644 (file)
@@ -49,6 +49,7 @@
 #include "../librpc/gen_ndr/ndr_wkssvc.h"
 #include "../libcli/auth/libcli_auth.h"
 #include "../libcli/lsarpc/util_lsarpc.h"
+#include "lsa.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
@@ -97,53 +98,6 @@ const struct generic_mapping lsa_trusted_domain_mapping = {
        LSA_TRUSTED_DOMAIN_ALL_ACCESS
 };
 
-/***************************************************************************
- init_lsa_ref_domain_list - adds a domain if it's not already in, returns the index.
-***************************************************************************/
-
-static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
-                                   struct lsa_RefDomainList *ref,
-                                   const char *dom_name,
-                                   struct dom_sid *dom_sid)
-{
-       int num = 0;
-
-       if (dom_name != NULL) {
-               for (num = 0; num < ref->count; num++) {
-                       if (dom_sid_equal(dom_sid, ref->domains[num].sid)) {
-                               return num;
-                       }
-               }
-       } else {
-               num = ref->count;
-       }
-
-       if (num >= LSA_REF_DOMAIN_LIST_MULTIPLIER) {
-               /* index not found, already at maximum domain limit */
-               return -1;
-       }
-
-       ref->count = num + 1;
-       ref->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER;
-
-       ref->domains = talloc_realloc(mem_ctx, ref->domains,
-                                           struct lsa_DomainInfo, ref->count);
-       if (!ref->domains) {
-               return -1;
-       }
-
-       ZERO_STRUCT(ref->domains[num]);
-
-       init_lsa_StringLarge(&ref->domains[num].name, dom_name);
-       ref->domains[num].sid = dom_sid_dup(mem_ctx, dom_sid);
-       if (!ref->domains[num].sid) {
-               return -1;
-       }
-
-       return num;
-}
-
-
 /***************************************************************************
  initialize a lsa_DomainInfo structure.
  ***************************************************************************/
index bd96b92b25d9245d6a5de2941b450a6655a59477..65daec4adb453b5484b602604ba8d1240ef85c97 100755 (executable)
@@ -68,7 +68,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_SAMR',
 
 bld.SAMBA3_SUBSYSTEM('RPC_LSARPC',
                     source=RPC_LSARPC_SRC,
-                    deps='SRV_ACCESS_CHECK',
+                    deps='SRV_ACCESS_CHECK LIBLSA',
                     vars=locals())
 
 bld.SAMBA3_SUBSYSTEM('RPC_WINREG',
index 3e05fd6f0995ebc2b39c5f7f863d9f3e4f5f66f3..c4281edac46a585ea28c5bcf43afb19111e8779d 100755 (executable)
@@ -1168,6 +1168,9 @@ bld.SAMBA3_SUBSYSTEM('INIT_SAMR',
                     source='rpc_client/init_samr.c',
                     deps='samba-util')
 
+bld.SAMBA3_SUBSYSTEM('LIBLSA',
+                     source='lib/lsa.c')
+
 ########################## BINARIES #################################
 
 bld.SAMBA3_BINARY('smbd/smbd',
@@ -1211,6 +1214,7 @@ bld.SAMBA3_BINARY('winbindd/winbindd',
                  RPC_NCACN_NP
                  RPC_PIPE_REGISTER
                  WB_REQTRANS
+                 LIBLSA
                  ''',
                  enabled=bld.env.build_winbind,
                  install_path='${SBINDIR}',