Print this page
NEX-1767 ls is unable to display SIDs
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
SUP-795 IDMAP: idmap_getwinnamebyuid() and idmap_getwinnamebygid() fails for empty domains
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libsec/common/acltext.c
          +++ new/usr/src/lib/libsec/common/acltext.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   * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  /*LINTLIBRARY*/
  27   27  
  28   28  #include <grp.h>
  29   29  #include <pwd.h>
  30   30  #include <string.h>
  31   31  #include <limits.h>
  32   32  #include <stdlib.h>
  33   33  #include <errno.h>
↓ open down ↓ 131 lines elided ↑ open up ↑
 165  165                  }
 166  166                  if (get_hdl)
 167  167                          idmap_get_destroy(get_hdl);
 168  168          }
 169  169  
 170  170          free(domain);
 171  171  
 172  172          return (*sidp ? 0 : 1);
 173  173  }
 174  174  
      175 +/*
      176 + * sid_string_by_id() is an exposed interface via -lsec
      177 + */
      178 +int
      179 +sid_string_by_id(uid_t who, boolean_t user, char **sidp, boolean_t noresolve)
      180 +{
      181 +        return (getsidname(who, user, sidp, noresolve));
      182 +}
      183 +
 175  184  static void
 176  185  aclent_printacl(acl_t *aclp)
 177  186  {
 178  187          aclent_t *tp;
 179  188          int aclcnt;
 180  189          int mask;
 181  190          int slot = 0;
 182  191          char perm[4];
 183  192          char uidp[ID_STR_MAX];
 184  193          char gidp[ID_STR_MAX];
↓ open down ↓ 224 lines elided ↑ open up ↑
 409  418                  }
 410  419                  if (error == 0)
 411  420                          error = str_append(dynstr, ":");
 412  421                  break;
 413  422  
 414  423          case ACE_EVERYONE:
 415  424                  error = str_append(dynstr, EVERYONEAT_TXT);
 416  425                  break;
 417  426  
 418  427          case 0:
 419      -                if ((flags & ACL_SID_FMT) && acep->a_who > MAXUID) {
      428 +                if ((flags & ACL_SID_FMT) && acep->a_who > MAXUID &&
      429 +                    (flags & ACL_EPHEMERAL) == 0) {
 420  430                          if (error = str_append(dynstr, USERSID_TXT))
 421  431                                  break;
 422  432                          if (error = getsidname(acep->a_who, B_TRUE,
 423  433                              &sidp, flags & ACL_NORESOLVE))
 424  434                                  break;
 425  435                          error = str_append(dynstr, sidp);
 426  436                  } else {
      437 +                        flags &= ~ACL_NORESOLVE;
 427  438                          if (error = str_append(dynstr, USER_TXT))
 428  439                                  break;
 429  440                          error = str_append(dynstr, pruname(acep->a_who, idp,
 430  441                              sizeof (idp), flags & ACL_NORESOLVE));
 431  442                  }
 432  443                  if (error == 0)
 433  444                          error = str_append(dynstr, ":");
 434  445                  break;
 435  446          default:
 436  447                  error = 0;
↓ open down ↓ 584 lines elided ↑ open up ↑
1021 1032  {
1022 1033          int error;
1023 1034  
1024 1035          yyinteractive = 1;
1025 1036          error = acl_fromtext(acltextp, aclp);
1026 1037          yyinteractive = 0;
1027 1038          return (error);
1028 1039  }
1029 1040  
1030 1041  static void
1031      -ace_compact_printacl(acl_t *aclp)
     1042 +ace_compact_printacl(acl_t *aclp, int flgs)
1032 1043  {
1033 1044          int cnt;
1034 1045          ace_t *acep;
1035 1046          dynaclstr_t *dstr;
1036 1047          int len;
1037 1048  
1038 1049          if ((dstr = malloc(sizeof (dynaclstr_t))) == NULL)
1039 1050                  return;
1040 1051          dstr->d_bufsize = ACE_ENTRY_SIZE;
1041 1052          if ((dstr->d_aclexport = malloc(dstr->d_bufsize)) == NULL) {
↓ open down ↓ 1 lines elided ↑ open up ↑
1043 1054                  return;
1044 1055          }
1045 1056          *dstr->d_aclexport = '\0';
1046 1057  
1047 1058          dstr->d_pos = 0;
1048 1059          for (cnt = 0, acep = aclp->acl_aclp;
1049 1060              cnt != aclp->acl_cnt; cnt++, acep++) {
1050 1061                  dstr->d_aclexport[0] = '\0';
1051 1062                  dstr->d_pos = 0;
1052 1063  
1053      -                if (ace_type_txt(dstr, acep, 0))
     1064 +                if (ace_type_txt(dstr, acep, flgs))
1054 1065                          break;
1055 1066                  len = strlen(&dstr->d_aclexport[0]);
1056 1067                  if (ace_perm_txt(dstr, acep->a_access_mask, acep->a_flags,
1057 1068                      aclp->acl_flags & ACL_IS_DIR, ACL_COMPACT_FMT))
1058 1069                          break;
1059 1070                  if (ace_inherit_txt(dstr, acep->a_flags, ACL_COMPACT_FMT))
1060 1071                          break;
1061 1072                  if (ace_access_txt(dstr, acep->a_type) == -1)
1062 1073                          break;
1063 1074                  (void) printf("    %20.*s%s\n", len, dstr->d_aclexport,
1064 1075                      &dstr->d_aclexport[len]);
1065 1076          }
1066 1077  
1067 1078          if (dstr->d_aclexport)
1068 1079                  free(dstr->d_aclexport);
1069 1080          free(dstr);
1070 1081  }
1071 1082  
1072 1083  static void
1073      -ace_printacl(acl_t *aclp, int cols, int compact)
     1084 +ace_printacl(acl_t *aclp, int cols, int flgs)
1074 1085  {
1075 1086          int  slot = 0;
1076 1087          char *token;
1077 1088          char *acltext;
1078 1089  
1079      -        if (compact) {
1080      -                ace_compact_printacl(aclp);
     1090 +        if (flgs & ACL_COMPACT_FMT) {
     1091 +                ace_compact_printacl(aclp, flgs);
1081 1092                  return;
1082 1093          }
1083 1094  
1084      -        acltext = acl_totext(aclp, 0);
     1095 +        acltext = acl_totext(aclp, flgs);
1085 1096  
1086 1097          if (acltext == NULL)
1087 1098                  return;
1088 1099  
1089 1100          token = strtok(acltext, ",");
1090 1101          if (token == NULL) {
1091 1102                  free(acltext);
1092 1103                  return;
1093 1104          }
1094 1105  
↓ open down ↓ 9 lines elided ↑ open up ↑
1104 1115   * For aclent_t ACL's the format is
1105 1116   * similar to the old format used by getfacl,
1106 1117   * with the addition of adding a "slot" number
1107 1118   * before each entry.
1108 1119   *
1109 1120   * for ace_t ACL's the cols variable will break up
1110 1121   * the long lines into multiple lines and will also
1111 1122   * print a "slot" number.
1112 1123   */
1113 1124  void
1114      -acl_printacl(acl_t *aclp, int cols, int compact)
     1125 +acl_printacl(acl_t *aclp, int cols, int flgs)
1115 1126  {
1116 1127  
1117 1128          switch (aclp->acl_type) {
1118 1129          case ACLENT_T:
1119 1130                  aclent_printacl(aclp);
1120 1131                  break;
1121 1132          case ACE_T:
1122      -                ace_printacl(aclp, cols, compact);
     1133 +                ace_printacl(aclp, cols, flgs);
1123 1134                  break;
1124 1135          }
1125 1136  }
1126 1137  
1127 1138  typedef struct value_table {
1128 1139          char            p_letter; /* perm letter such as 'r' */
1129 1140          uint32_t        p_value; /* value for perm when pletter found */
1130 1141  } value_table_t;
1131 1142  
1132 1143  /*
↓ open down ↓ 216 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX