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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.