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>

@@ -18,11 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*LINTLIBRARY*/
 
 #include <grp.h>

@@ -170,10 +170,19 @@
         free(domain);
 
         return (*sidp ? 0 : 1);
 }
 
+/*
+ * sid_string_by_id() is an exposed interface via -lsec
+ */
+int
+sid_string_by_id(uid_t who, boolean_t user, char **sidp, boolean_t noresolve)
+{
+        return (getsidname(who, user, sidp, noresolve));
+}
+
 static void
 aclent_printacl(acl_t *aclp)
 {
         aclent_t *tp;
         int aclcnt;

@@ -414,18 +423,20 @@
         case ACE_EVERYONE:
                 error = str_append(dynstr, EVERYONEAT_TXT);
                 break;
 
         case 0:
-                if ((flags & ACL_SID_FMT) && acep->a_who > MAXUID) {
+                if ((flags & ACL_SID_FMT) && acep->a_who > MAXUID &&
+                    (flags & ACL_EPHEMERAL) == 0) {
                         if (error = str_append(dynstr, USERSID_TXT))
                                 break;
                         if (error = getsidname(acep->a_who, B_TRUE,
                             &sidp, flags & ACL_NORESOLVE))
                                 break;
                         error = str_append(dynstr, sidp);
                 } else {
+                        flags &= ~ACL_NORESOLVE;
                         if (error = str_append(dynstr, USER_TXT))
                                 break;
                         error = str_append(dynstr, pruname(acep->a_who, idp,
                             sizeof (idp), flags & ACL_NORESOLVE));
                 }

@@ -1026,11 +1037,11 @@
         yyinteractive = 0;
         return (error);
 }
 
 static void
-ace_compact_printacl(acl_t *aclp)
+ace_compact_printacl(acl_t *aclp, int flgs)
 {
         int cnt;
         ace_t *acep;
         dynaclstr_t *dstr;
         int len;

@@ -1048,11 +1059,11 @@
         for (cnt = 0, acep = aclp->acl_aclp;
             cnt != aclp->acl_cnt; cnt++, acep++) {
                 dstr->d_aclexport[0] = '\0';
                 dstr->d_pos = 0;
 
-                if (ace_type_txt(dstr, acep, 0))
+                if (ace_type_txt(dstr, acep, flgs))
                         break;
                 len = strlen(&dstr->d_aclexport[0]);
                 if (ace_perm_txt(dstr, acep->a_access_mask, acep->a_flags,
                     aclp->acl_flags & ACL_IS_DIR, ACL_COMPACT_FMT))
                         break;

@@ -1068,22 +1079,22 @@
                 free(dstr->d_aclexport);
         free(dstr);
 }
 
 static void
-ace_printacl(acl_t *aclp, int cols, int compact)
+ace_printacl(acl_t *aclp, int cols, int flgs)
 {
         int  slot = 0;
         char *token;
         char *acltext;
 
-        if (compact) {
-                ace_compact_printacl(aclp);
+        if (flgs & ACL_COMPACT_FMT) {
+                ace_compact_printacl(aclp, flgs);
                 return;
         }
 
-        acltext = acl_totext(aclp, 0);
+        acltext = acl_totext(aclp, flgs);
 
         if (acltext == NULL)
                 return;
 
         token = strtok(acltext, ",");

@@ -1109,19 +1120,19 @@
  * for ace_t ACL's the cols variable will break up
  * the long lines into multiple lines and will also
  * print a "slot" number.
  */
 void
-acl_printacl(acl_t *aclp, int cols, int compact)
+acl_printacl(acl_t *aclp, int cols, int flgs)
 {
 
         switch (aclp->acl_type) {
         case ACLENT_T:
                 aclent_printacl(aclp);
                 break;
         case ACE_T:
-                ace_printacl(aclp, cols, compact);
+                ace_printacl(aclp, cols, flgs);
                 break;
         }
 }
 
 typedef struct value_table {