cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/06/01/09:24:17

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <3753DE93.94F7E870@vinschen.de>
Date: Tue, 01 Jun 1999 15:22:27 +0200
From: Corinna Vinschen <corinna AT vinschen DOT de>
X-Mailer: Mozilla 4.51 [en] (WinNT; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: Chris Faylor <cgf AT cygnus DOT com>, cygwin-developers AT sourceware DOT cygnus DOT com
Subject: mkpasswd and mkgroup patch

This is a multi-part message in MIME format.
--------------B5DF0E0DCA75AEA2229B874D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Sorry,

I've forgotten the `system' entry for /etc/passwd and
/etc/group. The attached patch replaces the previous patch 
completely. The ChangeLog, too.

Regards,
Corinna

Thu Jun 1 14:17:00 1999  Corinna Vinschen  <corinna AT vinschen DOT de>

        * utils/mkpasswd.c: Changed to output native names of
        well known groups `Everyone' (SID 0) and `system' (SID 18).
        * utils/mkgroup.c: Ditto plus output of native name of
        well known group `None' (SID 513).

-- 
new mail address:
mailto:corinna AT vinschen DOT de
--------------B5DF0E0DCA75AEA2229B874D
Content-Type: text/plain; charset=us-ascii;
 name="ntsec-util-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ntsec-util-patch"

Index: mkpasswd.c
===================================================================
RCS file: /src/cvsroot/winsup-990526/utils/mkpasswd.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 mkpasswd.c
--- mkpasswd.c	1999/05/28 19:28:24	1.1.1.1
+++ mkpasswd.c	1999/06/01 13:16:23
@@ -22,6 +22,9 @@
 
 #include <stdio.h>
 
+SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
+SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
+
 #ifndef min
 #define min(a,b) (((a)<(b))?(a):(b))
 #endif
@@ -167,9 +170,9 @@ enum_local_groups ()
 	      return 0;
 	    }
 
-	  gid = *GetSidSubAuthority (psid, 1);
+	  gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
 
-	  printf ("%s::%ld:0:::\n", localgroup_name, gid);
+	  printf ("%s:*:%ld:%ld:::\n", localgroup_name, gid, gid);
 	}
 
       NetApiBufferFree (buffer);
@@ -208,6 +211,11 @@ main (int argc, char **argv)
   int domain_name_specified = 0;
   int i;
 
+  char name[256], dom[256];
+  DWORD len, len2;
+  PSID sid;
+  SID_NAME_USE use;
+
   if (argc == 1)
     usage ();
 
@@ -243,6 +251,39 @@ main (int argc, char **argv)
       exit (1);
     }
 
+  /*
+   * Get `Everyone' group
+  */
+  if (AllocateAndInitializeSid (&sid_world_auth, 1, SECURITY_WORLD_RID,
+                                0, 0, 0, 0, 0, 0, 0, &sid))
+    {
+      if (LookupAccountSid (NULL, sid,
+                            name, (len = 256, &len),
+                            dom, (len2 = 256, &len),
+                            &use))
+        printf ("%s:*:%d:%d:::\n", name, SECURITY_WORLD_RID, SECURITY_WORLD_RID);
+      FreeSid (sid);
+    }
+
+  /*
+   * Get `system' group
+  */
+  if (AllocateAndInitializeSid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
+                                0, 0, 0, 0, 0, 0, 0, &sid))
+    {
+      if (LookupAccountSid (NULL, sid,
+                            name, (len = 256, &len),
+                            dom, (len2 = 256, &len),
+                            &use))
+        printf ("%s:*:%d:%d:::\n", name,
+                                   SECURITY_LOCAL_SYSTEM_RID,
+                                   SECURITY_LOCAL_SYSTEM_RID);
+      FreeSid (sid);
+    }
+
+  if (print_local_groups)
+    enum_local_groups ();
+
   if (print_domain)
     {
       if (domain_name_specified)
@@ -262,9 +303,6 @@ main (int argc, char **argv)
 
   if (print_local)
     enum_users (NULL);
-
-  if (print_local_groups)
-    enum_local_groups ();
 
   return 0;
 }
Index: mkgroup.c
===================================================================
RCS file: /src/cvsroot/winsup-990526/utils/mkgroup.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 mkgroup.c
--- mkgroup.c	1999/05/28 19:28:24	1.1.1.1
+++ mkgroup.c	1999/06/01 13:15:16
@@ -16,6 +16,9 @@
 #include <lmaccess.h>
 #include <lmapibuf.h>
 
+SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
+SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
+
 #ifndef min
 #define min(a,b) (((a)<(b))?(a):(b))
 #endif
@@ -53,6 +56,70 @@ uni2ansi (LPWSTR wcs, char *mbs)
     *mbs = '\0';
 }
 
+int 
+enum_local_groups ()
+{
+  LOCALGROUP_INFO_0 *buffer;
+  DWORD entriesread = 0;
+  DWORD totalentries = 0;
+  DWORD resume_handle = 0;
+
+  do
+    {
+      DWORD i;
+      DWORD rc = NetLocalGroupEnum (NULL, 0, (LPBYTE *) & buffer, 1024,
+			       &entriesread, &totalentries, &resume_handle);
+
+      switch (rc)
+	{
+	case ERROR_ACCESS_DENIED:
+	  fprintf (stderr, "Access denied\n");
+	  exit (1);
+
+	case ERROR_MORE_DATA:
+	case ERROR_SUCCESS:
+	  break;
+
+	default:
+	  fprintf (stderr, "NetUserEnum() failed with %ld\n", rc);
+	  exit (1);
+	}
+
+      for (i = 0; i < entriesread; i++)
+	{
+	  char localgroup_name[100];
+	  char domain_name[100];
+	  DWORD domname_len = 100;
+	  char psid_buffer[1024];
+	  PSID psid = (PSID) psid_buffer;
+	  DWORD sid_length = 1024;
+	  DWORD gid;
+	  SID_NAME_USE acc_type;
+	  uni2ansi (buffer[i].lgrpi0_name, localgroup_name);
+
+	  if (!LookupAccountName (NULL, localgroup_name, psid,
+				  &sid_length, domain_name, &domname_len,
+				  &acc_type))
+	    {
+	      int code = GetLastError ();
+	      fprintf (stderr, "LookupAccountName(%s) failed with %d\n",
+		       localgroup_name, code);
+	      return 0;
+	    }
+
+	  gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
+
+	  printf ("%s::%ld:\n", localgroup_name, gid);
+	}
+
+      NetApiBufferFree (buffer);
+
+    }
+  while (entriesread < totalentries);
+
+  return 0;
+}
+
 void 
 enum_groups (LPWSTR servername)
 {
@@ -126,6 +193,11 @@ main (int argc, char **argv)
   int domain_specified = 0;
   int i;
 
+  char name[256], dom[256];
+  DWORD len, len2;
+  PSID sid, csid;
+  SID_NAME_USE use;
+
   if (argc == 1)
     usage ();
 
@@ -150,6 +222,65 @@ main (int argc, char **argv)
 	    }
 	}
     }
+
+  /*
+   * Get `Everyone' group
+  */
+  if (AllocateAndInitializeSid (&sid_world_auth, 1, SECURITY_WORLD_RID,
+                                0, 0, 0, 0, 0, 0, 0, &sid))
+    {
+      if (LookupAccountSid (NULL, sid,
+                            name, (len = 256, &len),
+                            dom, (len2 = 256, &len),
+                            &use))
+        printf ("%s::%d:\n", name, SECURITY_WORLD_RID);
+      FreeSid (sid);
+    }
+
+  /*
+   * Get `system' group
+  */
+  if (AllocateAndInitializeSid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
+                                0, 0, 0, 0, 0, 0, 0, &sid))
+    {
+      if (LookupAccountSid (NULL, sid,
+                            name, (len = 256, &len),
+                            dom, (len2 = 256, &len),
+                            &use))
+        printf ("%s::%d:\n", name, SECURITY_LOCAL_SYSTEM_RID);
+      FreeSid (sid);
+    }
+
+  /*
+   * Get `None' group
+  */
+  GetComputerName (name, (len = 256, &len));
+  csid = (PSID) malloc (1024);
+  LookupAccountName (NULL, name,
+                     csid, (len = 1024, &len),
+                     dom, (len2 = 256, &len),
+                     &use);
+  if (AllocateAndInitializeSid (GetSidIdentifierAuthority (csid),
+                                *GetSidSubAuthorityCount (csid),
+                                *GetSidSubAuthority (csid, 0),
+                                *GetSidSubAuthority (csid, 1),
+                                *GetSidSubAuthority (csid, 2),
+                                *GetSidSubAuthority (csid, 3),
+                                513,
+                                0,
+                                0,
+                                0,
+                                &sid))
+    {
+      if (LookupAccountSid (NULL, sid,
+                            name, (len = 256, &len),
+                            dom, (len2 = 256, &len),
+                            &use))
+        printf ("%s::513:\n", name);
+      FreeSid (sid);
+    }
+  free (csid);
+
   if (print_domain)
     {
       if (domain_specified)
@@ -168,9 +299,7 @@ main (int argc, char **argv)
     }
 
   if (print_local)
-    enum_groups (NULL);
-
-  printf ("Everyone::0:\n");
+    enum_local_groups ();
 
   return 0;
 }

--------------B5DF0E0DCA75AEA2229B874D--


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019