Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/smbd
Files:
5 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/smbd/process_model.c

    r740 r988  
    2222#include "smbd/process_model.h"
    2323#include "param/param.h"
     24#include "lib/util/samba_modules.h"
    2425
    2526/* the list of currently registered process models */
     
    112113        initialised = true;
    113114
    114         shared_init = load_samba_modules(NULL, lp_ctx, "process_model");
     115        shared_init = load_samba_modules(NULL, "process_model");
    115116       
    116117        run_init_functions(static_init);
  • vendor/current/source4/smbd/process_single.c

    r740 r988  
    2727#include "cluster/cluster.h"
    2828
     29NTSTATUS process_model_single_init(void);
     30
    2931/*
    3032  called when the process model is selected
     
    4850        NTSTATUS status;
    4951        struct socket_context *connected_socket;
     52        pid_t pid = getpid();
    5053
    5154        /* accept an incoming connection. */
     
    7073        talloc_steal(private_data, connected_socket);
    7174
    72         /* The cluster_id(0, fd) cannot collide with the incrementing
    73          * task below, as the first component is 0, not 1 */
     75        /*
     76         * We use the PID so we cannot collide in with cluster ids
     77         * generated in other single mode tasks, and, and won't
     78         * collide with PIDs from process model standard because a the
     79         * combination of pid/fd should be unique system-wide
     80         */
    7481        new_conn(ev, lp_ctx, connected_socket,
    75                  cluster_id(0, socket_get_fd(connected_socket)), private_data);
     82                 cluster_id(pid, socket_get_fd(connected_socket)), private_data);
    7683}
    7784
     
    8592                            void *private_data)
    8693{
    87         /* start our taskids at 1, zero is reserved for the top
    88            level samba task */
    89         static uint32_t taskid = 1;
     94        pid_t pid = getpid();
     95        /* start our taskids at MAX_INT32, the first 2^31 tasks are is reserved for fd numbers */
     96        static uint32_t taskid = INT32_MAX;
    9097       
    91         /* We use 1 so we cannot collide in with cluster ids generated
    92          * in the accept connection above, and unlikly to collide with
    93          * PIDs from process modal standard (don't run samba as
    94          * init) */
    95         new_task(ev, lp_ctx, cluster_id(1, taskid++), private_data);
     98        /*
     99         * We use the PID so we cannot collide in with cluster ids
     100         * generated in other single mode tasks, and, and won't
     101         * collide with PIDs from process model starndard because a the
     102         * combination of pid/task_id should be unique system-wide
     103         *
     104         * Using the pid unaltered makes debugging of which process
     105         * owns the messaging socket easier.
     106         */
     107        new_task(ev, lp_ctx, cluster_id(pid, taskid++), private_data);
    96108}
    97109
  • vendor/current/source4/smbd/process_standard.c

    r740 r988  
    3030#include "ldb_wrap.h"
    3131
    32 #ifdef HAVE_SETPROCTITLE
    33 #ifdef HAVE_SETPROCTITLE_H
    34 #include <setproctitle.h>
    35 #endif
    36 #else
    37 #define setproctitle none_setproctitle
    38 static int none_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
    39 static int none_setproctitle(const char *fmt, ...)
    40 {
    41         return 0;
    42 }
    43 #endif
     32struct standard_child_state {
     33        const char *name;
     34        pid_t pid;
     35        int to_parent_fd;
     36        int from_child_fd;
     37        struct tevent_fd *from_child_fde;
     38};
     39
     40NTSTATUS process_model_standard_init(void);
    4441
    4542/* we hold a pipe open in the parent, and the any child
    4643   processes wait for EOF on that pipe. This ensures that
    4744   children die when the parent dies */
    48 static int child_pipe[2];
     45static int child_pipe[2] = { -1, -1 };
    4946
    5047/*
     
    5350static void standard_model_init(void)
    5451{
    55         pipe(child_pipe);
    56         signal(SIGCHLD, SIG_IGN);
    57 }
    58 
    59 /*
    60   handle EOF on the child pipe
     52        int rc;
     53
     54        rc = pipe(child_pipe);
     55        if (rc < 0) {
     56                smb_panic("Failed to initialze pipe!");
     57        }
     58}
     59
     60/*
     61  handle EOF on the parent-to-all-children pipe in the child
    6162*/
    6263static void standard_pipe_handler(struct tevent_context *event_ctx, struct tevent_fd *fde,
     
    6566        DEBUG(10,("Child %d exiting\n", (int)getpid()));
    6667        exit(0);
     68}
     69
     70/*
     71  handle EOF on the child pipe in the parent, so we know when a
     72  process terminates without using SIGCHLD or waiting on all possible pids.
     73
     74  We need to ensure we do not ignore SIGCHLD because we need it to
     75  work to get a valid error code from samba_runcmd_*().
     76 */
     77static void standard_child_pipe_handler(struct tevent_context *ev,
     78                                        struct tevent_fd *fde,
     79                                        uint16_t flags,
     80                                        void *private_data)
     81{
     82        struct standard_child_state *state
     83                = talloc_get_type_abort(private_data, struct standard_child_state);
     84        int status = 0;
     85        pid_t pid;
     86
     87        /* the child has closed the pipe, assume its dead */
     88        errno = 0;
     89        pid = waitpid(state->pid, &status, 0);
     90
     91        if (pid != state->pid) {
     92                if (errno == ECHILD) {
     93                        /*
     94                         * this happens when the
     95                         * parent has set SIGCHLD to
     96                         * SIG_IGN. In that case we
     97                         * can only get error
     98                         * information for the child
     99                         * via its logging. We should
     100                         * stop using SIG_IGN on
     101                         * SIGCHLD in the standard
     102                         * process model.
     103                         */
     104                        DEBUG(0, ("Error in waitpid() unexpectedly got ECHILD "
     105                                  "for child %d (%s) - %s, someone has set SIGCHLD "
     106                                  "to SIG_IGN!\n",
     107                                  (int)state->pid, state->name,
     108                                  strerror(errno)));
     109                        TALLOC_FREE(state);
     110                        return;
     111                }
     112                DEBUG(0, ("Error in waitpid() for child %d (%s) - %s \n",
     113                          (int)state->pid, state->name, strerror(errno)));
     114                if (errno == 0) {
     115                        errno = ECHILD;
     116                }
     117                TALLOC_FREE(state);
     118                return;
     119        }
     120        if (WIFEXITED(status)) {
     121                status = WEXITSTATUS(status);
     122                DEBUG(2, ("Child %d (%s) exited with status %d\n",
     123                          (int)state->pid, state->name, status));
     124        } else if (WIFSIGNALED(status)) {
     125                status = WTERMSIG(status);
     126                DEBUG(0, ("Child %d (%s) terminated with signal %d\n",
     127                          (int)state->pid, state->name, status));
     128        }
     129        TALLOC_FREE(state);
     130        return;
     131}
     132
     133static struct standard_child_state *setup_standard_child_pipe(struct tevent_context *ev,
     134                                                              const char *name)
     135{
     136        struct standard_child_state *state;
     137        int parent_child_pipe[2];
     138        int ret;
     139
     140        /*
     141         * Prepare a pipe to allow us to know when the child exits,
     142         * because it will trigger a read event on this private
     143         * pipe.
     144         *
     145         * We do all this before the accept and fork(), so we can
     146         * clean up if it fails.
     147         */
     148        state = talloc_zero(ev, struct standard_child_state);
     149        if (state == NULL) {
     150                return NULL;
     151        }
     152
     153        if (name == NULL) {
     154                name = "";
     155        }
     156
     157        state->name = talloc_strdup(state, name);
     158        if (state->name == NULL) {
     159                TALLOC_FREE(state);
     160                return NULL;
     161        }
     162
     163        ret = pipe(parent_child_pipe);
     164        if (ret == -1) {
     165                DEBUG(0, ("Failed to create parent-child pipe to handle "
     166                          "SIGCHLD to track new process for socket\n"));
     167                TALLOC_FREE(state);
     168                return NULL;
     169        }
     170
     171        smb_set_close_on_exec(parent_child_pipe[0]);
     172        smb_set_close_on_exec(parent_child_pipe[1]);
     173
     174        state->from_child_fd = parent_child_pipe[0];
     175        state->to_parent_fd = parent_child_pipe[1];
     176
     177        /*
     178         * The basic purpose of calling this handler is to ensure we
     179         * call waitpid() and so avoid zombies (now that we no longer
     180         * user SIGIGN on for SIGCHLD), but it also allows us to clean
     181         * up other resources in the future.
     182         */
     183        state->from_child_fde = tevent_add_fd(ev, state,
     184                                              state->from_child_fd,
     185                                              TEVENT_FD_READ,
     186                                              standard_child_pipe_handler,
     187                                              state);
     188        if (state->from_child_fde == NULL) {
     189                TALLOC_FREE(state);
     190                return NULL;
     191        }
     192        tevent_fd_set_auto_close(state->from_child_fde);
     193
     194        return state;
    67195}
    68196
     
    82210        pid_t pid;
    83211        struct socket_address *c, *s;
     212        struct standard_child_state *state;
     213
     214        state = setup_standard_child_pipe(ev, NULL);
     215        if (state == NULL) {
     216                return;
     217        }
    84218
    85219        /* accept an incoming connection. */
     
    91225                   the system clears enough resources to handle this new socket */
    92226                sleep(1);
     227                close(state->to_parent_fd);
     228                state->to_parent_fd = -1;
     229                TALLOC_FREE(state);
    93230                return;
    94231        }
     
    97234
    98235        if (pid != 0) {
     236                close(state->to_parent_fd);
     237                state->to_parent_fd = -1;
     238
     239                if (pid > 0) {
     240                        state->pid = pid;
     241                } else {
     242                        TALLOC_FREE(state);
     243                }
     244
    99245                /* parent or error code ... */
    100246                talloc_free(sock2);
     
    102248                return;
    103249        }
     250
     251        /* this leaves state->to_parent_fd open */
     252        TALLOC_FREE(state);
    104253
    105254        pid = getpid();
     
    124273        tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
    125274                      standard_pipe_handler, NULL);
    126         close(child_pipe[1]);
    127 
    128         /* Ensure that the forked children do not expose identical random streams */
    129         set_need_random_reseed();
     275        if (child_pipe[1] != -1) {
     276                close(child_pipe[1]);
     277                child_pipe[1] = -1;
     278        }
    130279
    131280        /* setup the process title */
     
    139288        talloc_free(s);
    140289
    141         /* setup this new connection.  Cluster ID is PID based for this process modal */
     290        /* setup this new connection.  Cluster ID is PID based for this process model */
    142291        new_conn(ev, lp_ctx, sock2, cluster_id(pid, 0), private_data);
    143292
     
    145294           so we now process events in the new event context until there are no
    146295           more to process */     
    147         event_loop_wait(ev);
     296        tevent_loop_wait(ev);
    148297
    149298        talloc_free(ev);
     
    161310{
    162311        pid_t pid;
     312        struct standard_child_state *state;
     313
     314        state = setup_standard_child_pipe(ev, service_name);
     315        if (state == NULL) {
     316                return;
     317        }
    163318
    164319        pid = fork();
    165320
    166321        if (pid != 0) {
     322                close(state->to_parent_fd);
     323                state->to_parent_fd = -1;
     324
     325                if (pid > 0) {
     326                        state->pid = pid;
     327                } else {
     328                        TALLOC_FREE(state);
     329                }
     330
    167331                /* parent or error code ... go back to the event loop */
    168332                return;
    169333        }
     334
     335        /* this leaves state->to_parent_fd open */
     336        TALLOC_FREE(state);
    170337
    171338        pid = getpid();
     
    182349        tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
    183350                      standard_pipe_handler, NULL);
    184         close(child_pipe[1]);
    185 
    186         /* Ensure that the forked children do not expose identical random streams */
    187         set_need_random_reseed();
     351        if (child_pipe[1] != -1) {
     352                close(child_pipe[1]);
     353                child_pipe[1] = -1;
     354        }
    188355
    189356        setproctitle("task %s server_id[%d]", service_name, (int)pid);
    190357
    191         /* setup this new task.  Cluster ID is PID based for this process modal */
     358        /* setup this new task.  Cluster ID is PID based for this process model */
    192359        new_task(ev, lp_ctx, cluster_id(pid, 0), private_data);
    193360
     
    195362           so we now process events in the new event context until there are no
    196363           more to process */     
    197         event_loop_wait(ev);
     364        tevent_loop_wait(ev);
    198365
    199366        talloc_free(ev);
  • vendor/current/source4/smbd/server.c

    r740 r988  
    3535#include "smbd/process_model.h"
    3636#include "param/secrets.h"
    37 #include "smbd/pidfile.h"
     37#include "lib/util/pidfile.h"
    3838#include "param/param.h"
    3939#include "dsdb/samdb/samdb.h"
     
    4343#include "cluster/cluster.h"
    4444#include "dynconfig/dynconfig.h"
     45#include "lib/util/samba_modules.h"
     46#include "nsswitch/winbind_client.h"
     47#include "libds/common/roles.h"
    4548
    4649/*
     
    179182{
    180183        const char *binary_name = (const char *)private_data;
    181         struct timeval tv;
    182         struct timezone tz;
    183         if (gettimeofday(&tv, &tz) == 0) {
    184                 DEBUG(0,("%s: maximum runtime exceeded - terminating, current ts: %d\n", binary_name, (int)tv.tv_sec));
    185         } else {
    186                 DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name));
    187         }
     184        DEBUG(0,("%s: maximum runtime exceeded - terminating at %llu, current ts: %llu\n",
     185                 binary_name, (unsigned long long)t.tv_sec, (unsigned long long) time(NULL)));
    188186        exit(0);
    189187}
     
    222220                                       struct loadparm_context *lp_ctx)
    223221{
    224         struct messaging_context *msg;
     222        struct imessaging_context *msg;
    225223        NTSTATUS status;
    226224
    227         msg = messaging_init(talloc_autofree_context(),
    228                              lpcfg_messaging_path(event_ctx, lp_ctx),
    229                              cluster_id(0, SAMBA_PARENT_TASKID), event_ctx);
     225        msg = imessaging_init(talloc_autofree_context(),
     226                              lp_ctx,
     227                              cluster_id(0, SAMBA_PARENT_TASKID), event_ctx, false);
    230228        NT_STATUS_HAVE_NO_MEMORY(msg);
    231229
    232         irpc_add_name(msg, "samba");
     230        status = irpc_add_name(msg, "samba");
     231        if (!NT_STATUS_IS_OK(status)) {
     232                return status;
     233        }
    233234
    234235        status = IRPC_REGISTER(msg, irpc, SAMBA_TERMINATE,
     
    258259                CONFIG_OPTION(MODULESDIR),
    259260                CONFIG_OPTION(LOCKDIR),
     261                CONFIG_OPTION(STATEDIR),
     262                CONFIG_OPTION(CACHEDIR),
    260263                CONFIG_OPTION(PIDDIR),
    261264                CONFIG_OPTION(PRIVATE_DIR),
    262                 CONFIG_OPTION(SWATDIR),
    263265                CONFIG_OPTION(CODEPAGEDIR),
    264266                CONFIG_OPTION(SETUPDIR),
     
    302304        const char *model = "standard";
    303305        int max_runtime = 0;
     306        struct stat st;
    304307        enum {
    305308                OPT_DAEMON = 1000,
     
    359362        poptFreeContext(pc);
    360363
     364        talloc_enable_null_tracking();
     365
    361366        setup_logging(binary_name, opt_interactive?DEBUG_STDOUT:DEBUG_FILE);
    362367        setup_signals();
     
    367372
    368373        DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING));
    369         DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2011\n"));
     374        DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2016\n"));
    370375
    371376        if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) {
     
    383388        cleanup_tmp_files(cmdline_lp_ctx);
    384389
    385         if (!directory_exist(lpcfg_lockdir(cmdline_lp_ctx))) {
    386                 mkdir(lpcfg_lockdir(cmdline_lp_ctx), 0755);
    387         }
    388 
    389         pidfile_create(lpcfg_piddir(cmdline_lp_ctx), binary_name);
    390 
    391         /* Do *not* remove this, until you have removed
    392          * passdb/secrets.c, and proved that Samba still builds... */
    393         /* Setup the SECRETS subsystem */
    394         if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) {
    395                 return 1;
    396         }
    397 
    398         if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_DOMAIN_CONTROLLER) {
    399                 if (!open_schannel_session_store(talloc_autofree_context(), lpcfg_private_dir(cmdline_lp_ctx))) {
    400                         DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n"));
    401                         exit(1);
    402                 }
    403         }
    404 
    405         gensec_init(cmdline_lp_ctx); /* FIXME: */
    406 
    407         ntptr_init(cmdline_lp_ctx);     /* FIXME: maybe run this in the initialization function
     390        if (!directory_exist(lpcfg_lock_directory(cmdline_lp_ctx))) {
     391                mkdir(lpcfg_lock_directory(cmdline_lp_ctx), 0755);
     392        }
     393
     394        pidfile_create(lpcfg_pid_directory(cmdline_lp_ctx), binary_name);
     395
     396        if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_ACTIVE_DIRECTORY_DC) {
     397                if (!open_schannel_session_store(talloc_autofree_context(), cmdline_lp_ctx)) {
     398                        exit_daemon("Samba cannot open schannel store for secured NETLOGON operations.", EACCES);
     399                }
     400        }
     401
     402        /* make sure we won't go through nss_winbind */
     403        if (!winbind_off()) {
     404                exit_daemon("Samba failed to disable recusive winbindd calls.", EACCES);
     405        }
     406
     407        gensec_init(); /* FIXME: */
     408
     409        ntptr_init();   /* FIXME: maybe run this in the initialization function
    408410                                                of the spoolss RPC server instead? */
    409411
     
    413415        process_model_init(cmdline_lp_ctx);
    414416
    415         shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "service");
     417        shared_init = load_samba_modules(NULL, "service");
    416418
    417419        run_init_functions(static_init);
     
    425427
    426428        if (event_ctx == NULL) {
    427                 DEBUG(0,("Initializing event context failed\n"));
    428                 return 1;
     429                exit_daemon("Initializing event context failed", EACCES);
    429430        }
    430431
     
    441442        signal(SIGTTIN, SIG_IGN);
    442443#endif
    443         tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
    444                       server_stdin_handler,
    445                       discard_const(binary_name));
     444
     445        if (fstat(0, &st) != 0) {
     446                exit_daemon("Samba failed to set standard input handler", ENOTTY);
     447        }
     448
     449        if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
     450                tevent_add_fd(event_ctx,
     451                                event_ctx,
     452                                0,
     453                                stdin_event_flags,
     454                                server_stdin_handler,
     455                                discard_const(binary_name));
     456        }
    446457
    447458        if (max_runtime) {
    448                 struct timeval tv;
    449                 struct timezone tz;
    450 
    451                 if (gettimeofday(&tv, &tz) == 0) {
    452                         DEBUG(0,("Called with maxruntime %d - current ts %d\n", max_runtime, (int)tv.tv_sec));
    453                 } else {
    454                         DEBUG(0,("Called with maxruntime %d\n", max_runtime));
    455                 }
     459                DEBUG(0,("Called with maxruntime %d - current ts %llu\n",
     460                      max_runtime, (unsigned long long) time(NULL)));
    456461                tevent_add_timer(event_ctx, event_ctx,
    457462                                 timeval_current_ofs(max_runtime, 0),
     
    460465        }
    461466
     467        if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC
     468            && !lpcfg_parm_bool(cmdline_lp_ctx, NULL, "server role check", "inhibit", false)
     469            && !str_list_check_ci(lpcfg_server_services(cmdline_lp_ctx), "smb")
     470            && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "remote")
     471            && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "mapiproxy")) {
     472                DEBUG(0, ("At this time the 'samba' binary should only be used for either:\n"));
     473                DEBUGADD(0, ("'server role = active directory domain controller' or to access the ntvfs file server with 'server services = +smb' or the rpc proxy with 'dcerpc endpoint servers = remote'\n"));
     474                DEBUGADD(0, ("You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks\n"));
     475                exit_daemon("Samba detected misconfigured 'server role' and exited. Check logs for details", EINVAL);
     476        };
     477
    462478        prime_ldb_databases(event_ctx);
    463479
    464480        status = setup_parent_messaging(event_ctx, cmdline_lp_ctx);
    465481        if (!NT_STATUS_IS_OK(status)) {
    466                 DEBUG(0,("Failed to setup parent messaging - %s\n", nt_errstr(status)));
    467                 return 1;
     482                exit_daemon("Samba failed to setup parent messaging", NT_STATUS_V(status));
    468483        }
    469484
     
    473488                                        lpcfg_server_services(cmdline_lp_ctx));
    474489        if (!NT_STATUS_IS_OK(status)) {
    475                 DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status)));
    476                 return 1;
     490                exit_daemon("Samba failed to start services", NT_STATUS_V(status));
     491        }
     492
     493        if (opt_daemon) {
     494                daemon_ready("samba");
    477495        }
    478496
  • vendor/current/source4/smbd/service.c

    r740 r988  
    4545        srv->service_name = name;
    4646        srv->task_init = task_init;
    47         DLIST_ADD_END(registered_servers, srv, struct registered_server *);
     47        DLIST_ADD_END(registered_servers, srv);
    4848        return NT_STATUS_OK;
    4949}
  • vendor/current/source4/smbd/service_named_pipe.c

    r740 r988  
    201201        }
    202202
    203         if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), geteuid(), 0755)) {
    204                 status = map_nt_error_from_unix(errno);
     203        if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), 0755)) {
     204                status = map_nt_error_from_unix_common(errno);
    205205                DEBUG(0,(__location__ ": Failed to create ncalrpc pipe directory '%s' - %s\n",
    206206                         lpcfg_ncalrpc_dir(lp_ctx), nt_errstr(status)));
     
    213213        }
    214214
    215         if (!directory_create_or_exist(dirname, geteuid(), 0700)) {
    216                 status = map_nt_error_from_unix(errno);
    217                 DEBUG(0,(__location__ ": Failed to create stream pipe directory %s - %s\n",
     215        if (!directory_create_or_exist_strict(dirname, geteuid(), 0700)) {
     216                status = map_nt_error_from_unix_common(errno);
     217                DEBUG(0,(__location__ ": Failed to create stream pipe directory '%s' - %s\n",
    218218                         dirname, nt_errstr(status)));
    219219                goto fail;
  • vendor/current/source4/smbd/service_stream.c

    r740 r988  
    2828#include "param/param.h"
    2929#include "../lib/tsocket/tsocket.h"
     30#include "lib/util/util_net.h"
    3031
    3132/* the range of ports to try for dcerpc over tcp endpoints */
     
    6061        if (!reason) reason = "unknown reason";
    6162
    62         DEBUG(3,("Terminating connection - '%s'\n", reason));
     63        if (srv_conn->processing) {
     64                DEBUG(3,("Terminating connection deferred - '%s'\n", reason));
     65        } else {
     66                DEBUG(3,("Terminating connection - '%s'\n", reason));
     67        }
    6368
    6469        srv_conn->terminate = reason;
     
    7782        talloc_free(srv_conn->event.fde);
    7883        srv_conn->event.fde = NULL;
     84        imessaging_cleanup(srv_conn->msg_ctx);
    7985        model_ops->terminate(event_ctx, srv_conn->lp_ctx, reason);
    8086        talloc_free(srv_conn);
     
    123129                                     const struct model_ops *model_ops,
    124130                                     const struct stream_server_ops *stream_ops,
    125                                      struct messaging_context *msg_ctx,
     131                                     struct imessaging_context *msg_ctx,
    126132                                     void *private_data,
    127133                                     struct stream_connection **_srv_conn)
     
    174180        srv_conn->lp_ctx        = lp_ctx;
    175181
    176         if (!socket_check_access(sock, "smbd", lpcfg_hostsallow(NULL, lpcfg_default_service(lp_ctx)), lpcfg_hostsdeny(NULL, lpcfg_default_service(lp_ctx)))) {
     182        if (!socket_check_access(sock, "smbd", lpcfg_hosts_allow(NULL, lpcfg_default_service(lp_ctx)), lpcfg_hosts_deny(NULL, lpcfg_default_service(lp_ctx)))) {
    177183                stream_terminate_connection(srv_conn, "denied by access rules");
    178184                return;
     
    187193
    188194        /* setup to receive internal messages on this connection */
    189         srv_conn->msg_ctx = messaging_init(srv_conn,
    190                                            lpcfg_messaging_path(srv_conn, lp_ctx),
    191                                            srv_conn->server_id, ev);
     195        srv_conn->msg_ctx = imessaging_init(srv_conn,
     196                                            lp_ctx,
     197                                            srv_conn->server_id, ev, false);
    192198        if (!srv_conn->msg_ctx) {
    193                 stream_terminate_connection(srv_conn, "messaging_init() failed");
     199                stream_terminate_connection(srv_conn, "imessaging_init() failed");
    194200                return;
    195201        }
     
    210216                TALLOC_CTX *tmp_ctx;
    211217                const char *title;
     218                struct server_id_buf idbuf;
    212219
    213220                tmp_ctx = talloc_new(srv_conn);
     
    217224                                        tsocket_address_string(srv_conn->remote_address, tmp_ctx),
    218225                                        tsocket_address_string(srv_conn->local_address, tmp_ctx),
    219                                         cluster_id_string(tmp_ctx, server_id));
     226                                        server_id_str_buf(server_id, &idbuf));
    220227                if (title) {
    221228                        stream_connection_set_title(srv_conn, title);
     
    272279        struct tevent_fd *fde;
    273280        int i;
     281        struct sockaddr_storage ss;
    274282
    275283        stream_socket = talloc_zero(mem_ctx, struct stream_socket);
    276284        NT_STATUS_HAVE_NO_MEMORY(stream_socket);
    277285
    278         status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
    279         NT_STATUS_NOT_OK_RETURN(status);
     286        if (strcmp(family, "ip") == 0) {
     287                /* we will get the real family from the address itself */
     288                if (!interpret_string_addr(&ss, sock_addr, 0)) {
     289                        talloc_free(stream_socket);
     290                        return NT_STATUS_INVALID_ADDRESS;
     291                }
     292
     293                socket_address = socket_address_from_sockaddr_storage(stream_socket, &ss, port?*port:0);
     294                if (socket_address == NULL) {
     295                        TALLOC_FREE(stream_socket);
     296                        return NT_STATUS_NO_MEMORY;
     297                }
     298
     299                status = socket_create(socket_address->family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
     300                NT_STATUS_NOT_OK_RETURN(status);
     301        } else {
     302                status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
     303                NT_STATUS_NOT_OK_RETURN(status);
     304
     305                /* this is for non-IP sockets, eg. unix domain sockets */
     306                socket_address = socket_address_from_strings(stream_socket,
     307                                                             stream_socket->sock->backend_name,
     308                                                             sock_addr, port?*port:0);
     309                NT_STATUS_HAVE_NO_MEMORY(socket_address);
     310        }
     311
    280312
    281313        talloc_steal(stream_socket, stream_socket->sock);
     
    298330         * the string.  We are indicating this by having port == NULL */
    299331        if (!port) {
    300                 socket_address = socket_address_from_strings(stream_socket,
    301                                                              stream_socket->sock->backend_name,
    302                                                              sock_addr, 0);
    303                 NT_STATUS_HAVE_NO_MEMORY(socket_address);
    304332                status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0);
    305                 talloc_free(socket_address);
    306 
    307333        } else if (*port == 0) {
    308334                for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) {
    309                         socket_address = socket_address_from_strings(stream_socket,
    310                                                                      stream_socket->sock->backend_name,
    311                                                                      sock_addr, i);
    312                         NT_STATUS_HAVE_NO_MEMORY(socket_address);
     335                        socket_address->port = i;
    313336                        status = socket_listen(stream_socket->sock, socket_address,
    314337                                               SERVER_LISTEN_BACKLOG, 0);
    315                         talloc_free(socket_address);
    316338                        if (NT_STATUS_IS_OK(status)) {
    317339                                *port = i;
     
    320342                }
    321343        } else {
    322                 socket_address = socket_address_from_strings(stream_socket,
    323                                                              stream_socket->sock->backend_name,
    324                                                              sock_addr, *port);
    325                 NT_STATUS_HAVE_NO_MEMORY(socket_address);
    326344                status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0);
    327                 talloc_free(socket_address);
    328345        }
    329346
     
    363380}
    364381
     382
    365383/*
    366384  setup a connection title
  • vendor/current/source4/smbd/service_stream.h

    r740 r988  
    2424#define __SERVICE_STREAM_H__
    2525
    26 #include "librpc/gen_ndr/server_id4.h"
     26#include "librpc/gen_ndr/server_id.h"
    2727
    2828/* modules can use the following to determine if the interface has changed
     
    4848
    4949        struct socket_context *socket;
    50         struct messaging_context *msg_ctx;
     50        struct imessaging_context *msg_ctx;
    5151        struct loadparm_context *lp_ctx;
    5252
  • vendor/current/source4/smbd/service_task.c

    r740 r988  
    3535        DEBUG(0,("task_server_terminate: [%s]\n", reason));
    3636
    37         if (fatal) {
     37        if (fatal && task->msg_ctx != NULL) {
    3838                struct dcerpc_binding_handle *irpc_handle;
    3939                struct samba_terminate r;
     
    4242                                                          "samba", &ndr_table_irpc);
    4343                if (irpc_handle != NULL) {
     44                        /* Note: this makes use of nested event loops... */
     45                        dcerpc_binding_handle_set_sync_ev(irpc_handle, event_ctx);
    4446                        r.in.reason = reason;
    4547                        dcerpc_samba_terminate_r(irpc_handle, task, &r);
    4648                }
    4749        }
     50
     51        imessaging_cleanup(task->msg_ctx);
    4852
    4953        model_ops->terminate(event_ctx, task->lp_ctx, reason);
     
    7983        task->lp_ctx = lp_ctx;
    8084
    81         task->msg_ctx = messaging_init(task,
    82                                        lpcfg_messaging_path(task, task->lp_ctx),
    83                                        task->server_id,
    84                                        task->event_ctx);
     85        task->msg_ctx = imessaging_init(task,
     86                                        task->lp_ctx,
     87                                        task->server_id,
     88                                        task->event_ctx, false);
    8589        if (!task->msg_ctx) {
    86                 task_server_terminate(task, "messaging_init() failed", true);
     90                task_server_terminate(task, "imessaging_init() failed", true);
    8791                return;
    8892        }
  • vendor/current/source4/smbd/service_task.h

    r740 r988  
    2323#define __SERVICE_TASK_H__
    2424
    25 #include "librpc/gen_ndr/server_id4.h"
     25#include "librpc/gen_ndr/server_id.h"
    2626
    2727struct task_server {
    2828        struct tevent_context *event_ctx;
    2929        const struct model_ops *model_ops;
    30         struct messaging_context *msg_ctx;
     30        struct imessaging_context *msg_ctx;
    3131        struct loadparm_context *lp_ctx;
    3232        struct server_id server_id;
  • vendor/current/source4/smbd/wscript_build

    r740 r988  
    44        source='service.c service_stream.c service_named_pipe.c service_task.c',
    55        autoproto='service_proto.h',
    6         deps='tevent MESSAGING samba_socket RPC_NDR_IRPC NDR_NAMED_PIPE_AUTH NAMED_PIPE_AUTH_TSTREAM gssapi credentials LIBTSOCKET LIBSAMBA_TSOCKET process_model',
    7         private_library=True
     6        deps='tevent MESSAGING samba_socket RPC_NDR_IRPC NDR_NAMED_PIPE_AUTH npa_tstream gssapi samba-credentials LIBTSOCKET LIBSAMBA_TSOCKET process_model',
     7        private_library=True,
     8        enabled=bld.AD_DC_BUILD_IS_ENABLED()
    89        )
    910
    1011
    11 bld.SAMBA_SUBSYSTEM('PIDFILE',
    12         source='pidfile.c',
    13         deps='talloc',
    14         autoproto='pidfile.h'
    15         )
    16 
     12bld.SAMBA_LIBRARY('process_model',
     13                  source='process_model.c',
     14                  autoproto='process_model_proto.h',
     15                  deps='samba-util samba-hostconfig samba-modules',
     16                  private_library=True,
     17                  enabled=bld.AD_DC_BUILD_IS_ENABLED()
     18                  )
    1719
    1820bld.SAMBA_BINARY('samba',
    1921        source='server.c',
    20         manpages='samba.8',
    2122        subsystem_name='service',
    22         deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA PIDFILE
     23        deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA
    2324                popt gensec registry ntptr ntvfs share cluster COMMON_SCHANNEL SECRETS''',
    2425        pyembed=True,
    25         install_path='${SBINDIR}'
     26        install_path='${SBINDIR}',
     27        enabled=bld.AD_DC_BUILD_IS_ENABLED()
    2628        )
    27 
    28 
    29 
    3029
    3130bld.SAMBA_MODULE('process_model_single',
     
    4645                 )
    4746
    48 
    49 bld.SAMBA_MODULE('process_model_thread',
    50                  source='process_thread.c',
    51                  subsystem='process_model',
    52                  init_function='process_model_thread_init',
    53                  enabled=False,
    54                  deps='pthread samba-sockets cluster process_model',
    55                  internal_module=False
    56                  )
    57 
    58 
    59 bld.SAMBA_MODULE('process_model_prefork',
    60                  source='process_prefork.c',
    61                  subsystem='process_model',
    62                  init_function='process_model_prefork_init',
    63                  deps='events ldbsamba cluster samba-sockets process_model',
    64                  internal_module=False
    65                  )
    66 
    67 bld.SAMBA_MODULE('process_model_onefork',
    68                  source='process_onefork.c',
    69                  subsystem='process_model',
    70                  init_function='process_model_onefork_init',
    71                  deps='events ldbsamba process_model cluster samba-sockets',
    72                  internal_module=False
    73                  )
    74 
    75 
    76 bld.SAMBA_LIBRARY('process_model',
    77                   source='process_model.c',
    78                   autoproto='process_model_proto.h',
    79                   deps='samba-util samba-hostconfig',
    80                   private_library=True
    81                   )
    82 
Note: See TracChangeset for help on using the changeset viewer.