Print this page
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-2667 Wrong error when join domain with wrong password
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
NEX-2225 Unable to join NexentaStor to 2008 AD
NEX-1638 Updated DC Locator
 Includes work by: matt.barden@nexenta.com, kevin.crowe@nexenta.com
re #12435 rb3958 r10 is added 2 times to panic info
re #12393 rb3935 Kerberos and smbd disagree about who is our AD server

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c
          +++ new/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       24 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  #include <syslog.h>
  28   28  #include <synch.h>
  29   29  #include <pthread.h>
  30   30  #include <unistd.h>
  31   31  #include <string.h>
  32   32  #include <strings.h>
  33   33  #include <sys/errno.h>
  34   34  #include <sys/types.h>
↓ open down ↓ 48 lines elided ↑ open up ↑
  83   83  /*
  84   84   * Initialization of the DC locator thread.
  85   85   * Returns 0 on success, an error number if thread creation fails.
  86   86   */
  87   87  int
  88   88  smb_dclocator_init(void)
  89   89  {
  90   90          pthread_attr_t tattr;
  91   91          int rc;
  92   92  
       93 +        /*
       94 +         * We need the smb_ddiscover_service to run on startup,
       95 +         * so it will enter smb_ddiscover_main() and put the
       96 +         * SMB "domain cache" into "updating" state so clients
       97 +         * trying to logon will wait while we're finding a DC.
       98 +         */
       99 +        smb_dclocator.sdl_locate = B_TRUE;
      100 +
  93  101          (void) pthread_attr_init(&tattr);
  94  102          (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
  95  103          rc = pthread_create(&smb_dclocator_thr, &tattr,
  96  104              smb_ddiscover_service, &smb_dclocator);
  97  105          (void) pthread_attr_destroy(&tattr);
  98  106          return (rc);
  99  107  }
 100  108  
 101  109  /*
 102  110   * This is the entry point for discovering a domain controller for the
↓ open down ↓ 131 lines elided ↑ open up ↑
 234  242                  syslog(LOG_DEBUG, "smb_ddiscover_bad_dc repeat");
 235  243                  goto out;
 236  244          }
 237  245  
 238  246          /*
 239  247           * Mark the current DC as "bad" and let the DC Locator
 240  248           * run again if it's not already.
 241  249           */
 242  250          syslog(LOG_INFO, "smb_ddiscover, bad DC: %s", bad_dc);
 243  251          smb_dclocator.sdl_bad_dc = B_TRUE;
      252 +        smb_domain_bad_dc();
 244  253  
 245  254          /* In-line smb_ddiscover_kick */
 246  255          if (!smb_dclocator.sdl_locate) {
 247  256                  smb_dclocator.sdl_locate = B_TRUE;
 248  257                  (void) cond_broadcast(&smb_dclocator.sdl_cv);
 249  258          }
 250  259  
 251  260  out:
 252  261          (void) mutex_unlock(&smb_dclocator.sdl_mtx);
 253  262  }
 254  263  
 255      -/*
 256      - * If domain discovery is running, wait for it to finish.
 257      - */
 258      -int
 259      -smb_ddiscover_wait(void)
 260      -{
 261      -        timestruc_t to;
 262      -        int rc = 0;
 263  264  
 264      -        (void) mutex_lock(&smb_dclocator.sdl_mtx);
 265      -
 266      -        if (smb_dclocator.sdl_locate) {
 267      -                to.tv_sec = SMB_DCLOCATOR_TIMEOUT;
 268      -                to.tv_nsec = 0;
 269      -                rc = cond_reltimedwait(&smb_dclocator.sdl_cv,
 270      -                    &smb_dclocator.sdl_mtx, &to);
 271      -        }
 272      -
 273      -        (void) mutex_unlock(&smb_dclocator.sdl_mtx);
 274      -
 275      -        return (rc);
 276      -}
 277      -
 278      -
 279  265  /*
 280  266   * ==========================================================
 281  267   * DC discovery functions
 282  268   * ==========================================================
 283  269   */
 284  270  
 285  271  /*
 286  272   * This is the domain and DC discovery service: it gets woken up whenever
 287  273   * there is need to locate a domain controller.
 288  274   *
↓ open down ↓ 58 lines elided ↑ open up ↑
 347  333                   */
 348  334                  smb_ads_refresh(bad_dc);
 349  335  
 350  336                  /*
 351  337                   * Search for the DC, save the result.
 352  338                   */
 353  339                  bzero(&dxi, sizeof (dxi));
 354  340                  status = smb_ddiscover_main(sdl->sdl_domain, &dxi);
 355  341                  if (status == 0)
 356  342                          smb_domain_save();
      343 +
 357  344                  (void) mutex_lock(&sdl->sdl_mtx);
      345 +
 358  346                  sdl->sdl_status = status;
 359      -                if (status == 0)
      347 +                if (status == 0) {
 360  348                          sdl->sdl_dci = dxi.d_dci;
      349 +                } else {
      350 +                        syslog(LOG_DEBUG, "smb_ddiscover_service "
      351 +                            "retry after STATUS_%s",
      352 +                            xlate_nt_status(status));
      353 +                        (void) sleep(5);
      354 +                        goto find_again;
      355 +                }
 361  356  
 362  357                  /*
 363  358                   * Run again if either of cfg_chg or bad_dc
 364  359                   * was turned on during smb_ddiscover_main().
 365  360                   * Note: mutex held here.
 366  361                   */
 367  362                  if (sdl->sdl_bad_dc) {
 368  363                          syslog(LOG_DEBUG, "smb_ddiscover_service "
 369  364                              "restart because bad_dc was set");
 370  365                          goto find_again;
↓ open down ↓ 27 lines elided ↑ open up ↑
 398  393  uint32_t
 399  394  smb_ddiscover_main(char *domain, smb_domainex_t *dxi)
 400  395  {
 401  396          uint32_t status;
 402  397  
 403  398          if (domain[0] == '\0') {
 404  399                  syslog(LOG_DEBUG, "smb_ddiscover_main NULL domain");
 405  400                  return (NT_STATUS_INTERNAL_ERROR);
 406  401          }
 407  402  
 408      -        if (smb_domain_start_update() != SMB_DOMAIN_SUCCESS) {
 409      -                syslog(LOG_DEBUG, "smb_ddiscover_main can't get lock");
 410      -                return (NT_STATUS_INTERNAL_ERROR);
 411      -        }
 412      -
 413  403          status = smb_ads_lookup_msdcs(domain, &dxi->d_dci);
 414  404          if (status != 0) {
 415  405                  syslog(LOG_DEBUG, "smb_ddiscover_main can't find DC (%s)",
 416  406                      xlate_nt_status(status));
 417  407                  goto out;
 418  408          }
 419  409  
 420  410          status = smb_ddiscover_qinfo(domain, dxi->d_dci.dc_name, dxi);
 421  411          if (status != 0) {
 422  412                  syslog(LOG_DEBUG,
 423  413                      "smb_ddiscover_main can't get domain info (%s)",
 424  414                      xlate_nt_status(status));
 425  415                  goto out;
 426  416          }
 427  417  
 428      -        smb_domain_update(dxi);
      418 +        if (smb_domain_start_update() != SMB_DOMAIN_SUCCESS) {
      419 +                syslog(LOG_DEBUG, "smb_ddiscover_main can't get lock");
      420 +                status = NT_STATUS_INTERNAL_ERROR;
      421 +        } else {
      422 +                smb_domain_update(dxi);
      423 +                smb_domain_end_update();
      424 +        }
 429  425  
 430  426  out:
 431      -        smb_domain_end_update();
 432      -
 433  427          /* Don't need the trusted domain list anymore. */
 434  428          smb_domainex_free(dxi);
 435  429  
 436  430          return (status);
 437  431  }
 438  432  
 439  433  /*
 440  434   * Obtain primary and trusted domain information using LSA queries.
 441  435   *
 442  436   * domain - either NetBIOS or fully-qualified domain name
↓ open down ↓ 98 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX