summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-01-14 01:32:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:49 -0500
commit9327ec51d11855ec0ceac3ce1f4e0a75c8b57081 (patch)
tree7f4427b4246b91b050c16e8dc5d1f0433eb7cc2d /source4/smb_server
parentcfc10f2a83b7c6190742498f1027256215cd0b31 (diff)
downloadsamba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.tar.gz
samba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.tar.bz2
samba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.zip
r4728: split up server_services into:
- stream_socket services the smb, ldap and rpc service which sets up a srtam socket end then waits for connections and - task services which this you can create a seperate task that do something (this is also going through the process_model subsystem so with -M standard a new process for this created with -M thread a new thread ... I'll add datagram services later when we whave support for datagram sockets in lib/socket/ see the next commit as an example for service_task's metze (This used to be commit d5fa02746c6569b09b6e05785642da2fad3ba3e0)
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/negprot.c6
-rw-r--r--source4/smb_server/request.c2
-rw-r--r--source4/smb_server/service.c48
-rw-r--r--source4/smb_server/smb_server.c66
-rw-r--r--source4/smb_server/smb_server.h19
5 files changed, 35 insertions, 106 deletions
diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c
index 77df978a05..4af8fed53b 100644
--- a/source4/smb_server/negprot.c
+++ b/source4/smb_server/negprot.c
@@ -144,7 +144,7 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_conn->pid);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->connection.id);
srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
SIVAL(req->out.vwv, VWV(11), 0); /* reserved */
@@ -198,7 +198,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_conn->pid);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->connection.id);
srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
SIVAL(req->out.vwv, VWV(11), 0);
@@ -310,7 +310,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
- SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->pid); /* session key */
+ SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->connection.id); /* session key */
SIVAL(req->out.vwv+1, VWV(9), capabilities);
push_nttime(req->out.vwv+1, VWV(11), nttime);
SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60);
diff --git a/source4/smb_server/request.c b/source4/smb_server/request.c
index 2ac832b439..f7f39f39d5 100644
--- a/source4/smb_server/request.c
+++ b/source4/smb_server/request.c
@@ -47,8 +47,6 @@ struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn)
{
struct smbsrv_request *req;
- smb_conn->pkt_count++;
-
req = talloc_p(smb_conn, struct smbsrv_request);
if (!req) {
return NULL;
diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c
index 1aa41d17a8..d4386ca77b 100644
--- a/source4/smb_server/service.c
+++ b/source4/smb_server/service.c
@@ -72,54 +72,6 @@ static int find_service(const char *service)
iService = lp_servicenumber(service);
- /* If we still don't have a service, attempt to add it as a printer. */
- if (iService == -1) {
- int iPrinterService;
-
- if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0) {
- const char *pszTemp;
-
- DEBUG(3,("checking whether %s is a valid printer name...\n", service));
- pszTemp = lp_printcapname();
- if ((pszTemp != NULL) && pcap_printername_ok(service, pszTemp)) {
- DEBUG(3,("%s is a valid printer name\n", service));
- DEBUG(3,("adding %s as a printer service\n", service));
- lp_add_printer(service, iPrinterService);
- iService = lp_servicenumber(service);
- if (iService < 0)
- DEBUG(0,("failed to add %s as a printer service!\n", service));
- } else {
- DEBUG(3,("%s is not a valid printer name\n", service));
- }
- }
- }
-
- /* Check for default vfs service? Unsure whether to implement this */
- if (iService == -1) {
- }
-
- /* just possibly it's a default service? */
- if (iService == -1) {
- const char *pdefservice = lp_defaultservice();
- if (pdefservice && *pdefservice &&
- !strequal(pdefservice,service) &&
- !strstr(service,"..")) {
- /*
- * We need to do a local copy here as lp_defaultservice()
- * returns one of the rotating lp_string buffers that
- * could get overwritten by the recursive find_service() call
- * below. Fix from Josef Hinteregger <joehtg@joehtg.co.at>.
- */
- pstring defservice;
- pstrcpy(defservice, pdefservice);
- iService = find_service(defservice);
- if (iService >= 0) {
- /* REWRITE: all_string_sub(service, "_","/",0); */
- iService = lp_add_service(service, iService);
- }
- }
- }
-
if (iService >= 0 && !VALID_SNUM(iService)) {
DEBUG(0,("Invalid snum %d for %s\n",iService, service));
iService = -1;
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index ddbaf43cc9..1cbc831a17 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -506,7 +506,7 @@ static void switch_message(int type, struct smbsrv_request *req)
session_tag = req->session->vuid;
}
- DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), smb_conn->connection->service->model_ops->get_id(req)));
+ DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), req->smb_conn->connection->connection.id));
/* does this protocol need a valid tree connection? */
if ((flags & AS_USER) && !req->tcon) {
@@ -649,21 +649,12 @@ void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char
server_terminate_connection(smb_conn->connection, reason);
}
-/*
- called on a fatal error that should cause this server to terminate
-*/
-static void smbsrv_exit(struct server_service *service, const char *reason)
-{
- DEBUG(1,("smbsrv_exit\n"));
- return;
-}
+static const struct server_stream_ops *smbsrv_stream_ops(void);
/*
add a socket address to the list of events, one event per port
*/
-static void smb_add_socket(struct server_service *service,
- const struct model_ops *model_ops,
- struct socket_context *socket_ctx,
+static void smb_add_socket(struct server_service *service,
struct ipv4_addr *ifip)
{
const char **ports = lp_smb_ports();
@@ -673,7 +664,7 @@ static void smb_add_socket(struct server_service *service,
for (i=0;ports[i];i++) {
uint16_t port = atoi(ports[i]);
if (port == 0) continue;
- service_setup_socket(service, model_ops, "ipv4", ip_str, &port);
+ service_setup_stream_socket(service, smbsrv_stream_ops(), "ipv4", ip_str, &port);
}
talloc_free(ip_str);
@@ -682,7 +673,7 @@ static void smb_add_socket(struct server_service *service,
/****************************************************************************
Open the socket communication.
****************************************************************************/
-static void smbsrv_init(struct server_service *service, const struct model_ops *model_ops)
+static void smbsrv_init(struct server_service *service)
{
DEBUG(1,("smbsrv_init\n"));
@@ -702,13 +693,13 @@ static void smbsrv_init(struct server_service *service, const struct model_ops *
continue;
}
- smb_add_socket(service, model_ops, NULL, ifip);
+ smb_add_socket(service, ifip);
}
} else {
struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address());
- smb_add_socket(service, model_ops, NULL, &ifip);
+ smb_add_socket(service, &ifip);
}
}
@@ -717,7 +708,7 @@ static void smbsrv_init(struct server_service *service, const struct model_ops *
*/
static void smbsrv_recv(struct server_connection *conn, struct timeval t, uint16_t flags)
{
- struct smbsrv_connection *smb_conn = conn->private_data;
+ struct smbsrv_connection *smb_conn = conn->connection.private_data;
NTSTATUS status;
DEBUG(10,("smbsrv_recv\n"));
@@ -738,7 +729,7 @@ static void smbsrv_recv(struct server_connection *conn, struct timeval t, uint16
*/
static void smbsrv_send(struct server_connection *conn, struct timeval t, uint16_t flags)
{
- struct smbsrv_connection *smb_conn = conn->private_data;
+ struct smbsrv_connection *smb_conn = conn->connection.private_data;
while (smb_conn->pending_send) {
struct smbsrv_request *req = smb_conn->pending_send;
@@ -776,19 +767,9 @@ static void smbsrv_send(struct server_connection *conn, struct timeval t, uint16
}
}
-/*
- called when connection is idle
-*/
-static void smbsrv_idle(struct server_connection *conn, struct timeval t)
-{
- DEBUG(10,("smbsrv_idle: not implemented!\n"));
- conn->event.idle->next_event = timeval_add(&t, 5, 0);
- return;
-}
-
static void smbsrv_close(struct server_connection *conn, const char *reason)
{
- struct smbsrv_connection *smb_conn = conn->private_data;
+ struct smbsrv_connection *smb_conn = conn->connection.private_data;
DEBUG(5,("smbsrv_close: %s\n",reason));
@@ -818,7 +799,7 @@ void smbd_process_async(struct smbsrv_connection *smb_conn)
initialise a server_context from a open socket and register a event handler
for reading from that socket
*/
-void smbsrv_accept(struct server_connection *conn)
+static void smbsrv_accept(struct server_connection *conn)
{
struct smbsrv_connection *smb_conn;
@@ -827,10 +808,6 @@ void smbsrv_accept(struct server_connection *conn)
smb_conn = talloc_zero_p(conn, struct smbsrv_connection);
if (!smb_conn) return;
- smb_conn->pid = getpid();
-
- sub_set_context(&smb_conn->substitute);
-
/* now initialise a few default values associated with this smb socket */
smb_conn->negotiate.max_send = 0xFFFF;
@@ -848,20 +825,29 @@ void smbsrv_accept(struct server_connection *conn)
smb_conn->connection = conn;
- conn->private_data = smb_conn;
+ conn->connection.private_data = smb_conn;
return;
}
-static const struct server_service_ops smb_server_ops = {
+static const struct server_stream_ops smb_stream_ops = {
.name = "smb",
- .service_init = smbsrv_init,
+ .socket_init = NULL,
.accept_connection = smbsrv_accept,
.recv_handler = smbsrv_recv,
.send_handler = smbsrv_send,
- .idle_handler = smbsrv_idle,
- .close_connection = smbsrv_close,
- .service_exit = smbsrv_exit,
+ .idle_handler = NULL,
+ .close_connection = smbsrv_close
+};
+
+static const struct server_stream_ops *smbsrv_stream_ops(void)
+{
+ return &smb_stream_ops;
+}
+
+static const struct server_service_ops smb_server_ops = {
+ .name = "smb",
+ .service_init = smbsrv_init,
};
const struct server_service_ops *smbsrv_get_ops(void)
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 8a21051b65..01eb63d01c 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -150,7 +150,7 @@ struct substitute_context {
struct smbsrv_connection {
/* a count of the number of packets we have received. We
* actually only care about zero/non-zero at this stage */
- unsigned pkt_count;
+ //unsigned pkt_count;
/* context that has been negotiated between the client and server */
struct {
@@ -213,6 +213,7 @@ struct smbsrv_connection {
} tree;
/* the context associated with open files on an smb socket */
+#if 0
struct {
struct files_struct *files; /* open files */
@@ -228,7 +229,7 @@ struct smbsrv_connection {
/* limit for maximum open files */
int real_max_open_files;
} file;
-
+#endif
/* context associated with currently valid session setups */
struct {
/* this holds info on session vuids that are already validated for this VC */
@@ -237,11 +238,6 @@ struct smbsrv_connection {
int num_validated_vuids;
} sessions;
- /* this holds long term state specific to the printing subsystem */
- struct {
- struct notify_queue *notify_queue_head;
- } print;
-
/* the server_context holds a linked list of pending requests,
* this is used for blocking locks and requests blocked due to oplock
* break requests */
@@ -251,7 +247,7 @@ struct smbsrv_connection {
/* the request itself - needs to be freed */
struct smbsrv_request *request;
} *requests;
-
+#if 0
/* the timers context contains info on when we last did various
* functions */
struct {
@@ -264,13 +260,10 @@ struct smbsrv_connection {
/* when we last checked the smb.conf for auto-reload */
time_t last_smb_conf_reload;
} timers;
-
+#endif
struct smb_signing_context signing;
- struct substitute_context substitute;
-
- /* the pid of the process handling this session */
- pid_t pid;
+// struct substitute_context substitute;
struct server_connection *connection;