Print this page
SUP-549 Can't remove the Domain Admin from the local administrators group. (fix copyrights)
SUP-549 Can't remove the Domain Admin from the local administrators group.
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c
          +++ new/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   23   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  25   24   * Copyright (c) 2013 RackTop Systems.
       25 + * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  26   26   */
  27   27  
  28   28  #include <stdlib.h>
  29   29  #include <strings.h>
  30   30  #include <unistd.h>
  31   31  #include <syslog.h>
  32   32  #include <thread.h>
  33   33  #include <synch.h>
  34   34  #include <grp.h>
  35   35  #include <assert.h>
↓ open down ↓ 99 lines elided ↑ open up ↑
 135  135  
 136  136  #define NULL_MSGCHK(msg)        ((msg) ? (msg) : "NULL")
 137  137  
 138  138  /* Member ID */
 139  139  typedef struct smb_lgmid {
 140  140          uint32_t m_idx;
 141  141          uint32_t m_rid;
 142  142          uint16_t m_type;
 143  143  } smb_lgmid_t;
 144  144  
      145 +/* Buffer size to hold hex form of the above (>24). */
 145  146  #define SMB_LGRP_MID_HEXSZ      32
 146  147  
      148 +/* Size of idx,rid parts of above, in hex form. */
      149 +#define SMB_LGRP_IDXRID_LEN     16
      150 +
 147  151  /* Member list */
 148  152  typedef struct smb_lgmlist {
 149  153          uint32_t        m_cnt;
 150  154          char            *m_ids;
 151  155  } smb_lgmlist_t;
 152  156  
 153  157  /* Privilege ID */
 154  158  typedef uint8_t smb_lgpid_t;
 155  159  
 156  160  /* Privilege list */
↓ open down ↓ 1875 lines elided ↑ open up ↑
2032 2036  
2033 2037  /*
2034 2038   * smb_lgrp_mlist_del
2035 2039   *
2036 2040   * Removes the given member (msid) from the input member list
2037 2041   * (in_members) if it's already there. The result list will b
2038 2042   * returned in out_members. The caller must free the allocated
2039 2043   * memory for out_members by calling free().
2040 2044   *
2041 2045   * in_members and out_members are hex strings.
     2046 + *
     2047 + * Note that we ignore the SID "type" when matching because
     2048 + * we always want to delete when the SID part matches.
     2049 + * The "type" part can be fiction.
2042 2050   */
2043 2051  static int
2044 2052  smb_lgrp_mlist_del(smb_lgmlist_t *in_members, smb_lgmid_t *mid,
2045 2053      smb_lgmlist_t *out_members)
2046 2054  {
2047 2055          char mid_hex[SMB_LGRP_MID_HEXSZ];
2048 2056          char *in_list;
2049 2057          char *out_list;
2050 2058          int in_size;
2051 2059          int out_size;
↓ open down ↓ 14 lines elided ↑ open up ↑
2066 2074                  return (SMB_LGRP_NO_MEMORY);
2067 2075  
2068 2076          *out_list = '\0';
2069 2077  
2070 2078          bzero(mid_hex, sizeof (mid_hex));
2071 2079          mid_hexsz = bintohex((const char *)mid, sizeof (smb_lgmid_t),
2072 2080              mid_hex, sizeof (mid_hex));
2073 2081  
2074 2082          in_list = in_members->m_ids;
2075 2083          for (i = 0, out_cnt = 0; i < in_members->m_cnt; i++) {
2076      -                if (strncmp(in_list, mid_hex, mid_hexsz)) {
     2084 +                /* Keep only those NOT matching in IDX,RID */
     2085 +                if (strncmp(in_list, mid_hex, SMB_LGRP_IDXRID_LEN)) {
2077 2086                          (void) strncat(out_list, in_list, mid_hexsz);
2078 2087                          out_cnt++;
2079 2088                  }
2080 2089                  in_list += mid_hexsz;
2081 2090          }
2082 2091  
2083 2092          if (out_cnt == in_members->m_cnt) {
2084 2093                  free(out_list);
2085 2094                  return (SMB_LGRP_MEMBER_NOT_IN_GROUP);
2086 2095          }
↓ open down ↓ 543 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX