mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* mkgroup.c: Avoid compiler warnings.
(print_special): New function. (main): Print special accounts by calling print_special(). * mkpasswd.c: Avoid compiler warnings. (enum_users): Print additional U-domain\username info in gecos field when SIDs are printed. (print_special): New function. (main): Print special accounts by calling print_special().
This commit is contained in:
parent
b07891c58b
commit
011ec894d2
@ -1,3 +1,14 @@
|
|||||||
|
2001-10-20 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* mkgroup.c: Avoid compiler warnings.
|
||||||
|
(print_special): New function.
|
||||||
|
(main): Print special accounts by calling print_special().
|
||||||
|
* mkpasswd.c: Avoid compiler warnings.
|
||||||
|
(enum_users): Print additional U-domain\username info in gecos
|
||||||
|
field when SIDs are printed.
|
||||||
|
(print_special): New function.
|
||||||
|
(main): Print special accounts by calling print_special().
|
||||||
|
|
||||||
2001-10-15 Christopher Faylor <cgf@redhat.com>
|
2001-10-15 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* mkpasswd.cc (enum_users): Shorten "unused" passwd field.
|
* mkpasswd.cc (enum_users): Shorten "unused" passwd field.
|
||||||
|
@ -40,17 +40,17 @@ load_netapi ()
|
|||||||
if (!h)
|
if (!h)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!(netapibufferfree = GetProcAddress (h, "NetApiBufferFree")))
|
if (!(netapibufferfree = (void *) GetProcAddress (h, "NetApiBufferFree")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netgroupenum = GetProcAddress (h, "NetGroupEnum")))
|
if (!(netgroupenum = (void *) GetProcAddress (h, "NetGroupEnum")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netgroupgetusers = GetProcAddress (h, "NetGroupGetUsers")))
|
if (!(netgroupgetusers = (void *) GetProcAddress (h, "NetGroupGetUsers")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netlocalgroupenum = GetProcAddress (h, "NetLocalGroupEnum")))
|
if (!(netlocalgroupenum = (void *) GetProcAddress (h, "NetLocalGroupEnum")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netlocalgroupgetmembers = GetProcAddress (h, "NetLocalGroupGetMembers")))
|
if (!(netlocalgroupgetmembers = (void *) GetProcAddress (h, "NetLocalGroupGetMembers")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netgetdcname = GetProcAddress (h, "NetGetDCName")))
|
if (!(netgetdcname = (void *) GetProcAddress (h, "NetGetDCName")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -356,6 +356,49 @@ enum_groups (LPWSTR servername, int print_sids, int print_users, int id_offset)
|
|||||||
netapibufferfree (servername);
|
netapibufferfree (servername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_special (int print_sids,
|
||||||
|
PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
||||||
|
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
||||||
|
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
||||||
|
{
|
||||||
|
char name[256], dom[256];
|
||||||
|
DWORD len, len2, rid;
|
||||||
|
PSID sid;
|
||||||
|
SID_NAME_USE use;
|
||||||
|
|
||||||
|
if (AllocateAndInitializeSid (auth, cnt, sub1, sub2, sub3, sub4,
|
||||||
|
sub5, sub6, sub7, sub8, &sid))
|
||||||
|
{
|
||||||
|
if (LookupAccountSid (NULL, sid,
|
||||||
|
name, (len = 256, &len),
|
||||||
|
dom, (len2 = 256, &len),
|
||||||
|
&use))
|
||||||
|
{
|
||||||
|
if (sub8)
|
||||||
|
rid = sub8;
|
||||||
|
else if (sub7)
|
||||||
|
rid = sub7;
|
||||||
|
else if (sub6)
|
||||||
|
rid = sub6;
|
||||||
|
else if (sub5)
|
||||||
|
rid = sub5;
|
||||||
|
else if (sub4)
|
||||||
|
rid = sub4;
|
||||||
|
else if (sub3)
|
||||||
|
rid = sub3;
|
||||||
|
else if (sub2)
|
||||||
|
rid = sub2;
|
||||||
|
else
|
||||||
|
rid = sub1;
|
||||||
|
printf ("%s:%s:%lu:\n", name,
|
||||||
|
print_sids ? put_sid (sid) : "",
|
||||||
|
rid);
|
||||||
|
}
|
||||||
|
FreeSid (sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
@ -404,10 +447,11 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
char name[256], dom[256];
|
char name[256], dom[256];
|
||||||
DWORD len, len2;
|
DWORD len, len2;
|
||||||
PSID sid, csid;
|
PSID csid;
|
||||||
SID_NAME_USE use;
|
SID_NAME_USE use;
|
||||||
|
|
||||||
if (GetVersion () < 0x80000000)
|
if (GetVersion () < 0x80000000)
|
||||||
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return usage ();
|
return usage ();
|
||||||
else
|
else
|
||||||
@ -453,6 +497,7 @@ main (int argc, char **argv)
|
|||||||
domain_specified = 1;
|
domain_specified = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This takes Windows 9x/ME into account. */
|
/* This takes Windows 9x/ME into account. */
|
||||||
if (GetVersion () >= 0x80000000)
|
if (GetVersion () >= 0x80000000)
|
||||||
@ -471,35 +516,13 @@ main (int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Get `Everyone' group
|
* Get `Everyone' group
|
||||||
*/
|
*/
|
||||||
if (AllocateAndInitializeSid (&sid_world_auth, 1, SECURITY_WORLD_RID,
|
print_special (print_sids, &sid_world_auth, 1, SECURITY_WORLD_RID,
|
||||||
0, 0, 0, 0, 0, 0, 0, &sid))
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
{
|
|
||||||
if (LookupAccountSid (NULL, sid,
|
|
||||||
name, (len = 256, &len),
|
|
||||||
dom, (len2 = 256, &len),
|
|
||||||
&use))
|
|
||||||
printf ("%s:%s:%d:\n", name,
|
|
||||||
print_sids ? put_sid (sid) : "",
|
|
||||||
SECURITY_WORLD_RID);
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get `system' group
|
* Get `system' group
|
||||||
*/
|
*/
|
||||||
if (AllocateAndInitializeSid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
print_special (print_sids, &sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
||||||
0, 0, 0, 0, 0, 0, 0, &sid))
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
{
|
|
||||||
if (LookupAccountSid (NULL, sid,
|
|
||||||
name, (len = 256, &len),
|
|
||||||
dom, (len2 = 256, &len),
|
|
||||||
&use))
|
|
||||||
printf ("%s:%s:%d:\n", name,
|
|
||||||
print_sids ? put_sid (sid) : "",
|
|
||||||
SECURITY_LOCAL_SYSTEM_RID);
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (print_local)
|
if (print_local)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -511,8 +534,7 @@ main (int argc, char **argv)
|
|||||||
csid, (len = 1024, &len),
|
csid, (len = 1024, &len),
|
||||||
dom, (len2 = 256, &len),
|
dom, (len2 = 256, &len),
|
||||||
&use);
|
&use);
|
||||||
if (AllocateAndInitializeSid (GetSidIdentifierAuthority (csid),
|
print_special (print_sids, GetSidIdentifierAuthority (csid), 5,
|
||||||
5,
|
|
||||||
*GetSidSubAuthority (csid, 0),
|
*GetSidSubAuthority (csid, 0),
|
||||||
*GetSidSubAuthority (csid, 1),
|
*GetSidSubAuthority (csid, 1),
|
||||||
*GetSidSubAuthority (csid, 2),
|
*GetSidSubAuthority (csid, 2),
|
||||||
@ -520,17 +542,7 @@ main (int argc, char **argv)
|
|||||||
513,
|
513,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0);
|
||||||
&sid))
|
|
||||||
{
|
|
||||||
if (LookupAccountSid (NULL, sid,
|
|
||||||
name, (len = 256, &len),
|
|
||||||
dom, (len2 = 256, &len),
|
|
||||||
&use))
|
|
||||||
printf ("%s:%s:513:\n", name,
|
|
||||||
print_sids ? put_sid (sid) : "");
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
free (csid);
|
free (csid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <io.h>
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <lmaccess.h>
|
#include <lmaccess.h>
|
||||||
@ -39,13 +40,13 @@ load_netapi ()
|
|||||||
if (!h)
|
if (!h)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!(netapibufferfree = GetProcAddress (h, "NetApiBufferFree")))
|
if (!(netapibufferfree = (void *) GetProcAddress (h, "NetApiBufferFree")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netuserenum = GetProcAddress (h, "NetUserEnum")))
|
if (!(netuserenum = (void *) GetProcAddress (h, "NetUserEnum")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netlocalgroupenum = GetProcAddress (h, "NetLocalGroupEnum")))
|
if (!(netlocalgroupenum = (void *) GetProcAddress (h, "NetLocalGroupEnum")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(netgetdcname = GetProcAddress (h, "NetGetDCName")))
|
if (!(netgetdcname = (void *) GetProcAddress (h, "NetGetDCName")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -206,10 +207,16 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf ("%s:unused_by_nt/2000/xp:%d:%d:%s%s%s:%s:/bin/bash\n", username,
|
printf ("%s:unused_by_nt/2000/xp:%d:%d:%s%s%s%s%s%s%s%s:%s:/bin/bash\n",
|
||||||
|
username,
|
||||||
uid + id_offset,
|
uid + id_offset,
|
||||||
gid + id_offset,
|
gid + id_offset,
|
||||||
fullname,
|
fullname,
|
||||||
|
print_sids && fullname[0] ? "," : "",
|
||||||
|
print_sids ? "U-" : "",
|
||||||
|
print_sids ? domain_name : "",
|
||||||
|
print_sids && domain_name[0] ? "\\" : "",
|
||||||
|
print_sids ? username : "",
|
||||||
print_sids ? "," : "",
|
print_sids ? "," : "",
|
||||||
print_sids ? put_sid (psid) : "",
|
print_sids ? put_sid (psid) : "",
|
||||||
homedir_psx);
|
homedir_psx);
|
||||||
@ -312,6 +319,50 @@ enum_local_groups (int print_sids)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_special (int print_sids,
|
||||||
|
PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
||||||
|
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
||||||
|
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
||||||
|
{
|
||||||
|
char name[256], dom[256];
|
||||||
|
DWORD len, len2, rid;
|
||||||
|
PSID sid;
|
||||||
|
SID_NAME_USE use;
|
||||||
|
|
||||||
|
if (AllocateAndInitializeSid (auth, cnt, sub1, sub2, sub3, sub4,
|
||||||
|
sub5, sub6, sub7, sub8, &sid))
|
||||||
|
{
|
||||||
|
if (LookupAccountSid (NULL, sid,
|
||||||
|
name, (len = 256, &len),
|
||||||
|
dom, (len2 = 256, &len),
|
||||||
|
&use))
|
||||||
|
{
|
||||||
|
if (sub8)
|
||||||
|
rid = sub8;
|
||||||
|
else if (sub7)
|
||||||
|
rid = sub7;
|
||||||
|
else if (sub6)
|
||||||
|
rid = sub6;
|
||||||
|
else if (sub5)
|
||||||
|
rid = sub5;
|
||||||
|
else if (sub4)
|
||||||
|
rid = sub4;
|
||||||
|
else if (sub3)
|
||||||
|
rid = sub3;
|
||||||
|
else if (sub2)
|
||||||
|
rid = sub2;
|
||||||
|
else
|
||||||
|
rid = sub1;
|
||||||
|
printf ("%s:*:%lu:%lu:%s%s::\n",
|
||||||
|
name, rid, rid,
|
||||||
|
print_sids ? "," : "",
|
||||||
|
print_sids ? put_sid (sid) : "");
|
||||||
|
}
|
||||||
|
FreeSid (sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
@ -364,15 +415,14 @@ main (int argc, char **argv)
|
|||||||
int id_offset = 10000;
|
int id_offset = 10000;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
char name[256], dom[256], passed_home_path[MAX_PATH];
|
char name[256], passed_home_path[MAX_PATH];
|
||||||
DWORD len, len2;
|
DWORD len;
|
||||||
PSID sid;
|
|
||||||
SID_NAME_USE use;
|
|
||||||
|
|
||||||
passed_home_path[0] = '\0';
|
passed_home_path[0] = '\0';
|
||||||
setmode (1, O_BINARY);
|
setmode (1, O_BINARY);
|
||||||
|
|
||||||
if (GetVersion () < 0x80000000)
|
if (GetVersion () < 0x80000000)
|
||||||
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return usage ();
|
return usage ();
|
||||||
else
|
else
|
||||||
@ -432,6 +482,7 @@ main (int argc, char **argv)
|
|||||||
domain_name_specified = 1;
|
domain_name_specified = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (passed_home_path[0] == '\0')
|
if (passed_home_path[0] == '\0')
|
||||||
strcpy (passed_home_path, "/home/");
|
strcpy (passed_home_path, "/home/");
|
||||||
@ -462,59 +513,16 @@ main (int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Get `Everyone' group
|
* Get `Everyone' group
|
||||||
*/
|
*/
|
||||||
if (AllocateAndInitializeSid (&sid_world_auth, 1, SECURITY_WORLD_RID,
|
print_special (print_sids, &sid_world_auth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0);
|
||||||
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:%s%s::\n", name,
|
|
||||||
SECURITY_WORLD_RID,
|
|
||||||
SECURITY_WORLD_RID,
|
|
||||||
print_sids ? "," : "",
|
|
||||||
print_sids ? put_sid (sid) : "");
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get `system' group
|
* Get `system' group
|
||||||
*/
|
*/
|
||||||
if (AllocateAndInitializeSid (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
print_special (print_sids, &sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0);
|
||||||
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:%s%s::\n", name,
|
|
||||||
SECURITY_LOCAL_SYSTEM_RID,
|
|
||||||
SECURITY_LOCAL_SYSTEM_RID,
|
|
||||||
print_sids ? "," : "",
|
|
||||||
print_sids ? put_sid (sid) : "");
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get `administrators' group
|
* Get `administrators' group
|
||||||
*/
|
*/
|
||||||
if (!print_local_groups
|
if (!print_local_groups)
|
||||||
&& AllocateAndInitializeSid (&sid_nt_auth, 2,
|
print_special (print_sids, &sid_nt_auth, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0);
|
||||||
SECURITY_BUILTIN_DOMAIN_RID,
|
|
||||||
DOMAIN_ALIAS_RID_ADMINS,
|
|
||||||
0, 0, 0, 0, 0, 0, &sid))
|
|
||||||
{
|
|
||||||
if (LookupAccountSid (NULL, sid,
|
|
||||||
name, (len = 256, &len),
|
|
||||||
dom, (len2 = 256, &len),
|
|
||||||
&use))
|
|
||||||
printf ("%s:*:%ld:%ld:%s%s::\n", name,
|
|
||||||
DOMAIN_ALIAS_RID_ADMINS,
|
|
||||||
DOMAIN_ALIAS_RID_ADMINS,
|
|
||||||
print_sids ? "," : "",
|
|
||||||
print_sids ? put_sid (sid) : "");
|
|
||||||
FreeSid (sid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (print_local_groups)
|
if (print_local_groups)
|
||||||
enum_local_groups (print_sids);
|
enum_local_groups (print_sids);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user