[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-3342-g03f7af2
Volker Lendecke
vlendec at samba.org
Sat Jul 19 19:08:04 GMT 2008
The branch, v3-3-test has been updated
via 03f7af26f255476d84a375a95fbccfce24db9de8 (commit)
via ab7ab350591bf16717744a0c252d3a9d185bcb77 (commit)
via 283e6039989adea1c8921b3600b410cb67b6492a (commit)
from 3ab3f2610500107c9cff677746365bba143ca9de (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit 03f7af26f255476d84a375a95fbccfce24db9de8
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jul 19 21:07:14 2008 +0200
The PIPE_ pipename macros are only used in cli_pipe.c
commit ab7ab350591bf16717744a0c252d3a9d185bcb77
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jul 19 20:40:27 2008 +0200
Make the pipe_names[] array static to cli_pipe.c
commit 283e6039989adea1c8921b3600b410cb67b6492a
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jul 19 20:27:56 2008 +0200
Introduce is_known_pipename
This scans the list of pipes registered via rpc_pipe_register_commands instead
of using static tables.
-----------------------------------------------------------------------
Summary of changes:
source/include/proto.h | 1 +
source/include/smb.h | 20 ---------
source/rpc_client/cli_pipe.c | 98 +++++++++++++++++++++++++++++++++++++++++-
source/rpc_parse/parse_rpc.c | 63 ---------------------------
source/rpc_server/srv_pipe.c | 33 ++++++++++++++
source/smbd/nttrans.c | 36 +---------------
source/smbd/pipes.c | 12 +-----
7 files changed, 133 insertions(+), 130 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/include/proto.h b/source/include/proto.h
index 136abca..ab92383 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -8815,6 +8815,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
const char *srv,
const struct ndr_syntax_id *interface,
const struct api_struct *cmds, int size);
+bool is_known_pipename(const char *cli_filename);
bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p);
bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p);
bool api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in,
diff --git a/source/include/smb.h b/source/include/smb.h
index 7fcae51..eadbd71 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -173,26 +173,6 @@ typedef uint32 codepoint_t;
/* pipe string names */
#define PIPE_LANMAN "\\PIPE\\LANMAN"
-#define PIPE_SRVSVC "\\PIPE\\srvsvc"
-#define PIPE_SAMR "\\PIPE\\samr"
-#define PIPE_WINREG "\\PIPE\\winreg"
-#define PIPE_WKSSVC "\\PIPE\\wkssvc"
-#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
-#define PIPE_NTLSA "\\PIPE\\ntlsa"
-#define PIPE_NTSVCS "\\PIPE\\ntsvcs"
-#define PIPE_LSASS "\\PIPE\\lsass"
-#define PIPE_LSARPC "\\PIPE\\lsarpc"
-#define PIPE_SPOOLSS "\\PIPE\\spoolss"
-#define PIPE_NETDFS "\\PIPE\\netdfs"
-#define PIPE_ECHO "\\PIPE\\rpcecho"
-#define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
-#define PIPE_EPM "\\PIPE\\epmapper"
-#define PIPE_SVCCTL "\\PIPE\\svcctl"
-#define PIPE_EVENTLOG "\\PIPE\\eventlog"
-#define PIPE_EPMAPPER "\\PIPE\\epmapper"
-#define PIPE_DRSUAPI "\\PIPE\\drsuapi"
-
-#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
#define PI_LSARPC 0
#define PI_DSSETUP 1
diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c
index 5e8bff3..dc130a1 100644
--- a/source/rpc_client/cli_pipe.c
+++ b/source/rpc_client/cli_pipe.c
@@ -23,7 +23,103 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
-extern struct pipe_id_info pipe_names[];
+/*******************************************************************
+interface/version dce/rpc pipe identification
+********************************************************************/
+
+static const struct ndr_syntax_id syntax_spoolss = {
+ {
+ 0x12345678, 0x1234, 0xabcd,
+ { 0xef, 0x00 },
+ { 0x01, 0x23,
+ 0x45, 0x67, 0x89, 0xab }
+ }, 0x01
+};
+
+#define PIPE_SRVSVC "\\PIPE\\srvsvc"
+#define PIPE_SAMR "\\PIPE\\samr"
+#define PIPE_WINREG "\\PIPE\\winreg"
+#define PIPE_WKSSVC "\\PIPE\\wkssvc"
+#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
+#define PIPE_NTLSA "\\PIPE\\ntlsa"
+#define PIPE_NTSVCS "\\PIPE\\ntsvcs"
+#define PIPE_LSASS "\\PIPE\\lsass"
+#define PIPE_LSARPC "\\PIPE\\lsarpc"
+#define PIPE_SPOOLSS "\\PIPE\\spoolss"
+#define PIPE_NETDFS "\\PIPE\\netdfs"
+#define PIPE_ECHO "\\PIPE\\rpcecho"
+#define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
+#define PIPE_EPM "\\PIPE\\epmapper"
+#define PIPE_SVCCTL "\\PIPE\\svcctl"
+#define PIPE_EVENTLOG "\\PIPE\\eventlog"
+#define PIPE_EPMAPPER "\\PIPE\\epmapper"
+#define PIPE_DRSUAPI "\\PIPE\\drsuapi"
+
+/*
+ * IMPORTANT!! If you update this structure, make sure to
+ * update the index #defines in smb.h.
+ */
+
+static const struct pipe_id_info pipe_names [] =
+{
+ { PIPE_LSARPC, &ndr_table_lsarpc.syntax_id,
+ PIPE_LSASS, &ndr_transfer_syntax },
+ { PIPE_LSARPC, &ndr_table_dssetup.syntax_id,
+ PIPE_LSASS, &ndr_transfer_syntax },
+ { PIPE_SAMR, &ndr_table_samr.syntax_id,
+ PIPE_LSASS, &ndr_transfer_syntax },
+ { PIPE_NETLOGON, &ndr_table_netlogon.syntax_id,
+ PIPE_LSASS, &ndr_transfer_syntax },
+ { PIPE_SRVSVC, &ndr_table_srvsvc.syntax_id,
+ PIPE_NTSVCS, &ndr_transfer_syntax },
+ { PIPE_WKSSVC, &ndr_table_wkssvc.syntax_id,
+ PIPE_NTSVCS, &ndr_transfer_syntax },
+ { PIPE_WINREG, &ndr_table_winreg.syntax_id,
+ PIPE_WINREG, &ndr_transfer_syntax },
+ { PIPE_SPOOLSS, &syntax_spoolss,
+ PIPE_SPOOLSS, &ndr_transfer_syntax },
+ { PIPE_NETDFS, &ndr_table_netdfs.syntax_id,
+ PIPE_NETDFS, &ndr_transfer_syntax },
+ { PIPE_ECHO, &ndr_table_rpcecho.syntax_id,
+ PIPE_ECHO, &ndr_transfer_syntax },
+ { PIPE_SHUTDOWN, &ndr_table_initshutdown.syntax_id,
+ PIPE_SHUTDOWN, &ndr_transfer_syntax },
+ { PIPE_SVCCTL, &ndr_table_svcctl.syntax_id,
+ PIPE_NTSVCS, &ndr_transfer_syntax },
+ { PIPE_EVENTLOG, &ndr_table_eventlog.syntax_id,
+ PIPE_EVENTLOG, &ndr_transfer_syntax },
+ { PIPE_NTSVCS, &ndr_table_ntsvcs.syntax_id,
+ PIPE_NTSVCS, &ndr_transfer_syntax },
+ { PIPE_EPMAPPER, &ndr_table_epmapper.syntax_id,
+ PIPE_EPMAPPER, &ndr_transfer_syntax },
+ { PIPE_DRSUAPI, &ndr_table_drsuapi.syntax_id,
+ PIPE_DRSUAPI, &ndr_transfer_syntax },
+ { NULL, NULL, NULL, NULL }
+};
+
+/****************************************************************************
+ Return the pipe name from the index.
+ ****************************************************************************/
+
+const char *cli_get_pipe_name(int pipe_idx)
+{
+ return &pipe_names[pipe_idx].client_pipe[5];
+}
+
+/****************************************************************************
+ Return the pipe idx from the syntax.
+ ****************************************************************************/
+int cli_get_pipe_idx(const RPC_IFACE *syntax)
+{
+ int i;
+ for (i = 0; pipe_names[i].client_pipe; i++) {
+ if (ndr_syntax_id_equal(pipe_names[i].abstr_syntax, syntax)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
/********************************************************************
Map internal value to wire value.
diff --git a/source/rpc_parse/parse_rpc.c b/source/rpc_parse/parse_rpc.c
index ac5483d..14a4eff 100644
--- a/source/rpc_parse/parse_rpc.c
+++ b/source/rpc_parse/parse_rpc.c
@@ -26,69 +26,6 @@
#define DBGC_CLASS DBGC_RPC_PARSE
/*******************************************************************
-interface/version dce/rpc pipe identification
-********************************************************************/
-
-const struct ndr_syntax_id syntax_spoolss = {
- {
- 0x12345678, 0x1234, 0xabcd,
- { 0xef, 0x00 },
- { 0x01, 0x23,
- 0x45, 0x67, 0x89, 0xab }
- }, 0x01
-};
-
-/*
- * IMPORTANT!! If you update this structure, make sure to
- * update the index #defines in smb.h.
- */
-
-const struct pipe_id_info pipe_names [] =
-{
- { PIPE_LSARPC , &ndr_table_lsarpc.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
- { PIPE_LSARPC , &ndr_table_dssetup.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
- { PIPE_SAMR , &ndr_table_samr.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
- { PIPE_NETLOGON, &ndr_table_netlogon.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
- { PIPE_SRVSVC , &ndr_table_srvsvc.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
- { PIPE_WKSSVC , &ndr_table_wkssvc.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
- { PIPE_WINREG , &ndr_table_winreg.syntax_id, PIPE_WINREG , &ndr_transfer_syntax },
- { PIPE_SPOOLSS , &syntax_spoolss , PIPE_SPOOLSS , &ndr_transfer_syntax },
- { PIPE_NETDFS , &ndr_table_netdfs.syntax_id, PIPE_NETDFS , &ndr_transfer_syntax },
- { PIPE_ECHO , &ndr_table_rpcecho.syntax_id, PIPE_ECHO , &ndr_transfer_syntax },
- { PIPE_SHUTDOWN, &ndr_table_initshutdown.syntax_id, PIPE_SHUTDOWN , &ndr_transfer_syntax },
- { PIPE_SVCCTL , &ndr_table_svcctl.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
- { PIPE_EVENTLOG, &ndr_table_eventlog.syntax_id, PIPE_EVENTLOG , &ndr_transfer_syntax },
- { PIPE_NTSVCS , &ndr_table_ntsvcs.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
- { PIPE_EPMAPPER , &ndr_table_epmapper.syntax_id, PIPE_EPMAPPER , &ndr_transfer_syntax },
- { PIPE_DRSUAPI , &ndr_table_drsuapi.syntax_id, PIPE_DRSUAPI , &ndr_transfer_syntax },
- { NULL , NULL , NULL , NULL }
-};
-
-/****************************************************************************
- Return the pipe name from the index.
- ****************************************************************************/
-
-const char *cli_get_pipe_name(int pipe_idx)
-{
- return &pipe_names[pipe_idx].client_pipe[5];
-}
-
-/****************************************************************************
- Return the pipe idx from the syntax.
- ****************************************************************************/
-int cli_get_pipe_idx(const RPC_IFACE *syntax)
-{
- int i;
- for (i = 0; pipe_names[i].client_pipe; i++) {
- if (ndr_syntax_id_equal(pipe_names[i].abstr_syntax, syntax)) {
- return i;
- }
- }
-
- return -1;
-}
-
-/*******************************************************************
Inits an RPC_HDR structure.
********************************************************************/
diff --git a/source/rpc_server/srv_pipe.c b/source/rpc_server/srv_pipe.c
index fa8fffa..7b066d3 100644
--- a/source/rpc_server/srv_pipe.c
+++ b/source/rpc_server/srv_pipe.c
@@ -1078,6 +1078,39 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
return NT_STATUS_OK;
}
+/**
+ * Is a named pipe known?
+ * @param[in] cli_filename The pipe name requested by the client
+ * @result Do we want to serve this?
+ */
+bool is_known_pipename(const char *cli_filename)
+{
+ const char *pipename = cli_filename;
+ int i;
+
+ if (strnequal(pipename, "\\PIPE\\", 6)) {
+ pipename += 5;
+ }
+
+ if (*pipename == '\\') {
+ pipename += 1;
+ }
+
+ if (lp_disable_spoolss() && strequal(pipename, "spoolss")) {
+ DEBUG(10, ("refusing spoolss access\n"));
+ return false;
+ }
+
+ for (i=0; i<rpc_lookup_size; i++) {
+ if (strequal(pipename, rpc_lookup[i].pipe.clnt)) {
+ return true;
+ }
+ }
+
+ DEBUG(10, ("is_known_pipename: %s unknown\n", cli_filename));
+ return false;
+}
+
/*******************************************************************
Handle a SPNEGO krb5 bind auth.
*******************************************************************/
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 12f4da6..149e6ec 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -23,27 +23,6 @@
extern int max_send;
extern enum protocol_types Protocol;
-static const char *known_nt_pipes[] = {
- "\\LANMAN",
- "\\srvsvc",
- "\\samr",
- "\\wkssvc",
- "\\NETLOGON",
- "\\ntlsa",
- "\\ntsvcs",
- "\\lsass",
- "\\lsarpc",
- "\\winreg",
- "\\initshutdown",
- "\\spoolss",
- "\\netdfs",
- "\\rpcecho",
- "\\svcctl",
- "\\eventlog",
- "\\unixinfo",
- NULL
-};
-
static char *nttrans_realloc(char **ptr, size_t size)
{
if (ptr==NULL) {
@@ -291,25 +270,12 @@ static void nt_open_pipe(char *fname, connection_struct *conn,
struct smb_request *req, int *ppnum)
{
smb_np_struct *p = NULL;
- int i;
DEBUG(4,("nt_open_pipe: Opening pipe %s.\n", fname));
/* See if it is one we want to handle. */
- if (lp_disable_spoolss() && strequal(fname, "\\spoolss")) {
- reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
- ERRDOS, ERRbadpipe);
- return;
- }
-
- for( i = 0; known_nt_pipes[i]; i++ ) {
- if( strequal(fname,known_nt_pipes[i])) {
- break;
- }
- }
-
- if ( known_nt_pipes[i] == NULL ) {
+ if (!is_known_pipename(fname)) {
reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
ERRDOS, ERRbadpipe);
return;
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 6b4b83d..4fdcdcc 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -44,9 +44,6 @@ struct pipe_dbrec {
fstring user;
};
-
-extern struct pipe_id_info pipe_names[];
-
/****************************************************************************
Reply to an open and X on a named pipe.
This code is basically stolen from reply_open_and_X with some
@@ -59,7 +56,6 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
char *pipe_name = NULL;
smb_np_struct *p;
int size=0,fmode=0,mtime=0,rmode=0;
- int i;
TALLOC_CTX *ctx = talloc_tos();
/* XXXX we need to handle passed times, sattr and flags */
@@ -82,13 +78,7 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
DEBUG(4,("Opening pipe %s.\n", pipe_name));
/* See if it is one we want to handle. */
- for( i = 0; pipe_names[i].client_pipe ; i++ ) {
- if( strequal(pipe_name,pipe_names[i].client_pipe)) {
- break;
- }
- }
-
- if (pipe_names[i].client_pipe == NULL) {
+ if (!is_known_pipename(pipe_name)) {
reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
ERRDOS, ERRbadpipe);
return;
--
Samba Shared Repository
More information about the samba-cvs
mailing list