]> sourceware.org Git - newlib-cygwin.git/commitdiff
* mkgroup.c (print_special_by_sid): Rename from print_special. Change
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 5 Apr 2012 13:37:32 +0000 (13:37 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 5 Apr 2012 13:37:32 +0000 (13:37 +0000)
calls throughout.
(print_special_by_name): New function.
(main): Call print_special_by_name for TrustedInstaller account.
* mkpasswd.c (print_special_by_sid): Rename from print_special.  Change
calls throughout.
(print_special_by_name): New function.
(enum_std_accounts): Call print_special_by_name for TrustedInstaller
account.

winsup/utils/ChangeLog
winsup/utils/mkgroup.c
winsup/utils/mkpasswd.c

index 50a957ae409a8710ed1692b2ed951b2afcdddb01..2011c34c761f94d1c0b210567791ed9d0315e111 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * mkgroup.c (print_special_by_sid): Rename from print_special.  Change
+       calls throughout.
+       (print_special_by_name): New function.
+       (main): Call print_special_by_name for TrustedInstaller account.
+       * mkpasswd.c (print_special_by_sid): Rename from print_special.  Change
+       calls throughout.
+       (print_special_by_name): New function.
+       (enum_std_accounts): Call print_special_by_name for TrustedInstaller
+       account.
+
 2012-02-24  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
 
        * pldd.c: Fix typo in license header.
index 393d8f8f7a79c7aaee773f40a14eeed592bdd710..f712553c4155e5a6984317a0dc214e4f44d894fe 100644 (file)
@@ -1,7 +1,7 @@
 /* mkgroup.c:
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -558,9 +558,9 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
 }
 
 static void
-print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
-              DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
-              DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
+print_special_by_sid (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
+                     DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
+                     DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
 {
   WCHAR grp[GNLEN + 1], dom[MAX_DOMAIN_NAME_LEN + 1];
   DWORD glen, dlen, rid;
@@ -597,6 +597,23 @@ print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
     }
 }
 
+static void
+print_special_by_name (PCWSTR name, gid_t gid)
+{
+  DWORD size = 256, dom_size = 256;
+  PSID sid = (PSID) alloca (size);
+  WCHAR dom[dom_size];
+  SID_NAME_USE use;
+
+  PWCHAR name_only = wcschr (name, L'\\');
+  if (name_only)
+    ++name_only;
+
+  if (LookupAccountNameW (NULL, name, sid, &size, dom, &dom_size, &use))
+    printf ("%ls:%s:%lu:\n",
+           name_only ?: name, put_sid (sid), (unsigned long) gid);
+}
+
 static int
 usage (FILE * stream)
 {
@@ -730,8 +747,8 @@ main (int argc, char **argv)
 
   if (argc == 1)
     {
-      print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
-                    0, 0, 0, 0, 0, 0, 0);
+      print_special_by_sid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
+                           0, 0, 0, 0, 0, 0, 0);
       if (in_domain)
        {
          if (!enum_local_groups (TRUE, NULL, sep_char, id_offset,
@@ -857,8 +874,11 @@ skip:
 
   /* Get 'system' group */
   if (!disp_groupname && print_system && print_builtin && print_domlist)
-    print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
-                  0, 0, 0, 0, 0, 0, 0);
+    {
+      print_special_by_sid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
+                           0, 0, 0, 0, 0, 0, 0);
+      print_special_by_name (L"NT SERVICE\\TrustedInstaller", -2);
+    }
 
   off = id_offset;
   for (i = 0; i < print_domlist; ++i)
index c873664f9c08b29324ad54b743323d8fefb0e785..6ca4e5db3f1af21d318c247af0cce5b9856713c5 100644 (file)
@@ -1,7 +1,7 @@
 /* mkpasswd.c:
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
-   2008, 2009, 2010, 2011 Red Hat, Inc.
+   2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -455,9 +455,9 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
 }
 
 static void
-print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
-              DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
-              DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
+print_special_by_sid (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
+                     DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
+                     DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
 {
   WCHAR user[UNLEN + 1], dom[MAX_DOMAIN_NAME_LEN + 1];
   DWORD len, len2, rid;
@@ -580,6 +580,29 @@ print_version ()
          strrchr (__DATE__, ' ') + 1);
 }
 
+static void
+print_special_by_name (PCWSTR name, uid_t uid, gid_t gid)
+{
+  DWORD size = 256, dom_size = 256;
+  PSID sid = (PSID) alloca (size);
+  WCHAR dom[dom_size];
+  SID_NAME_USE use;
+
+  PWCHAR name_only = wcschr (name, L'\\');
+  if (name_only)
+    ++name_only;
+
+  if (LookupAccountNameW (NULL, name, sid, &size, dom, &dom_size, &use))
+    printf ("%ls:*:%lu:%lu:U-%ls%s%ls,%s::\n",
+           name_only ?: name,
+           (unsigned long) uid,
+           (unsigned long) gid,
+           name_only ? dom : L"",
+           name_only ? "\\" : "",
+           name_only ?: name,
+           put_sid (sid));
+}
+
 static void
 enum_std_accounts ()
 {
@@ -588,8 +611,10 @@ enum_std_accounts ()
   printf ("LocalService:*:19:544:U-NT AUTHORITY\\LocalService,S-1-5-19::\n");
   printf ("NetworkService:*:20:544:U-NT AUTHORITY\\NetworkService,S-1-5-20::\n");
   /* Get 'administrators' group (has localized name). */
-  print_special (&sid_nt_auth, 2, SECURITY_BUILTIN_DOMAIN_RID,
-                DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0);
+  print_special_by_sid (&sid_nt_auth, 2, SECURITY_BUILTIN_DOMAIN_RID,
+                       DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0);
+  /* Fetch "TrustedInstaller" account starting with Vista. */
+  print_special_by_name (L"NT SERVICE\\TrustedInstaller", -2, -2);
 }
 
 static PPOLICY_PRIMARY_DOMAIN_INFO p_dom;
This page took 0.039787 seconds and 5 git commands to generate.