Print this page
MFV: illumos-gate@62f63298eba531d48f87aa8c2089298cb7821962
9881 smbd terminated by SIGABRT after smb_account_free()
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Vitaliy Gusev <gusev.vitaliy@gmail.com>
Conflicts:
        usr/src/lib/smbsrv/libsmb/common/smb_sam.c
NEX-15052 Need a way to add appliance local user/group ACE from Windows
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15052 Need a way to add appliance local user/group ACE from Windows
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libsmb/common/smb_sam.c
          +++ new/usr/src/lib/smbsrv/libsmb/common/smb_sam.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   *
  25      - * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
       26 + * Copyright 2018 RackTop Systems.
  26   27   */
  27   28  
  28   29  #include <strings.h>
  29   30  #include <smbsrv/libsmb.h>
  30   31  
  31   32  extern int smb_pwd_num(void);
  32   33  extern int smb_lgrp_numbydomain(smb_domain_type_t, int *);
  33   34  
  34   35  static uint32_t smb_sam_lookup_user(char *, smb_sid_t **);
  35   36  static uint32_t smb_sam_lookup_group(char *, smb_sid_t **);
↓ open down ↓ 48 lines elided ↑ open up ↑
  84   85   * Windows systems.
  85   86   *
  86   87   * If a SMB local user/group is found but it turns out that
  87   88   * it'll be mapped to a domain user/group the lookup is considered
  88   89   * failed and NT_STATUS_NONE_MAPPED is returned.
  89   90   *
  90   91   * Return status:
  91   92   *
  92   93   *   NT_STATUS_NOT_FOUND        This is not a local account
  93   94   *   NT_STATUS_NONE_MAPPED      It's a local account but cannot be
  94      - *                              translated.
       95 + *                              translated.
  95   96   *   other error status codes.
  96   97   */
  97   98  uint32_t
  98   99  smb_sam_lookup_name(char *domain, char *name, uint16_t type,
  99  100      smb_account_t *account)
 100  101  {
 101  102          smb_domain_t di;
 102  103          smb_sid_t *sid;
 103  104          uint32_t status;
 104  105          smb_lwka_t *lwka;
↓ open down ↓ 89 lines elided ↑ open up ↑
 194  195   *
 195  196   * If the account is found, its information is populated
 196  197   * in the passed smb_account_t structure. Caller must free
 197  198   * allocated memories by calling smb_account_free() upon
 198  199   * successful return.
 199  200   *
 200  201   * Return status:
 201  202   *
 202  203   *   NT_STATUS_NOT_FOUND        This is not a local account
 203  204   *   NT_STATUS_NONE_MAPPED      It's a local account but cannot be
 204      - *                              translated.
      205 + *                              translated.
 205  206   *   other error status codes.
 206  207   */
 207  208  uint32_t
 208  209  smb_sam_lookup_sid(smb_sid_t *sid, smb_account_t *account)
 209  210  {
 210  211          char hostname[MAXHOSTNAMELEN];
 211  212          smb_passwd_t smbpw;
 212  213          smb_group_t grp;
 213  214          smb_lwka_t *lwka;
 214  215          smb_domain_t di;
↓ open down ↓ 37 lines elided ↑ open up ↑
 252  253                  if (smb_idmap_getid(sid, &id, &id_type) != IDMAP_SUCCESS)
 253  254                          return (NT_STATUS_NONE_MAPPED);
 254  255  
 255  256                  switch (id_type) {
 256  257                  case SMB_IDMAP_USER:
 257  258                          account->a_type = SidTypeUser;
 258  259                          if (smb_pwd_getpwuid(id, &smbpw) == NULL)
 259  260                                  return (NT_STATUS_NO_SUCH_USER);
 260  261  
 261  262                          account->a_name = strdup(smbpw.pw_name);
      263 +                        account->a_flags = smbpw.pw_flags;
 262  264                          break;
 263  265  
 264  266                  case SMB_IDMAP_GROUP:
 265  267                          account->a_type = SidTypeAlias;
 266  268                          (void) smb_sid_getrid(sid, &rid);
 267  269                          rc = smb_lgrp_getbyrid(rid, SMB_DOMAIN_LOCAL, &grp);
 268  270                          if (rc != SMB_LGRP_SUCCESS)
 269  271                                  return (NT_STATUS_NO_SUCH_ALIAS);
 270  272  
 271  273                          account->a_name = strdup(grp.sg_name);
↓ open down ↓ 198 lines elided ↑ open up ↑
 470  472          if (smb_lgrp_getbyname((char *)gname, &grp) == SMB_LGRP_SUCCESS) {
 471  473                  ismember = smb_lgrp_is_member(&grp, sid);
 472  474                  smb_lgrp_free(&grp);
 473  475          }
 474  476  
 475  477          return (ismember);
 476  478  }
 477  479  
 478  480  /*
 479  481   * Frees memories allocated for the passed account fields.
      482 + * Initializes @account after all.
 480  483   */
 481  484  void
 482  485  smb_account_free(smb_account_t *account)
 483  486  {
 484  487          free(account->a_name);
 485  488          free(account->a_domain);
 486  489          smb_sid_free(account->a_sid);
 487  490          smb_sid_free(account->a_domsid);
      491 +
      492 +        bzero(account, sizeof (smb_account_t));
 488  493  }
 489  494  
 490  495  /*
 491  496   * Validates the given account.
 492  497   */
 493  498  boolean_t
 494  499  smb_account_validate(smb_account_t *account)
 495  500  {
 496  501          return ((account->a_name != NULL) && (account->a_sid != NULL) &&
 497  502              (account->a_domain != NULL) && (account->a_domsid != NULL));
↓ open down ↓ 109 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX