* 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:
Corinna Vinschen 2001-10-20 13:56:09 +00:00
parent b07891c58b
commit 011ec894d2
3 changed files with 238 additions and 207 deletions

View File

@ -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>
* mkpasswd.cc (enum_users): Shorten "unused" passwd field.

View File

@ -40,17 +40,17 @@ load_netapi ()
if (!h)
return FALSE;
if (!(netapibufferfree = GetProcAddress (h, "NetApiBufferFree")))
if (!(netapibufferfree = (void *) GetProcAddress (h, "NetApiBufferFree")))
return FALSE;
if (!(netgroupenum = GetProcAddress (h, "NetGroupEnum")))
if (!(netgroupenum = (void *) GetProcAddress (h, "NetGroupEnum")))
return FALSE;
if (!(netgroupgetusers = GetProcAddress (h, "NetGroupGetUsers")))
if (!(netgroupgetusers = (void *) GetProcAddress (h, "NetGroupGetUsers")))
return FALSE;
if (!(netlocalgroupenum = GetProcAddress (h, "NetLocalGroupEnum")))
if (!(netlocalgroupenum = (void *) GetProcAddress (h, "NetLocalGroupEnum")))
return FALSE;
if (!(netlocalgroupgetmembers = GetProcAddress (h, "NetLocalGroupGetMembers")))
if (!(netlocalgroupgetmembers = (void *) GetProcAddress (h, "NetLocalGroupGetMembers")))
return FALSE;
if (!(netgetdcname = GetProcAddress (h, "NetGetDCName")))
if (!(netgetdcname = (void *) GetProcAddress (h, "NetGetDCName")))
return FALSE;
return TRUE;
@ -356,6 +356,49 @@ enum_groups (LPWSTR servername, int print_sids, int print_users, int id_offset)
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
usage ()
{
@ -404,10 +447,11 @@ main (int argc, char **argv)
char name[256], dom[256];
DWORD len, len2;
PSID sid, csid;
PSID csid;
SID_NAME_USE use;
if (GetVersion () < 0x80000000)
{
if (argc == 1)
return usage ();
else
@ -453,6 +497,7 @@ main (int argc, char **argv)
domain_specified = 1;
}
}
}
/* This takes Windows 9x/ME into account. */
if (GetVersion () >= 0x80000000)
@ -471,35 +516,13 @@ 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:%s:%d:\n", name,
print_sids ? put_sid (sid) : "",
SECURITY_WORLD_RID);
FreeSid (sid);
}
print_special (print_sids, &sid_world_auth, 1, SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0);
/*
* 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:%s:%d:\n", name,
print_sids ? put_sid (sid) : "",
SECURITY_LOCAL_SYSTEM_RID);
FreeSid (sid);
}
print_special (print_sids, &sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0);
if (print_local)
{
/*
@ -511,8 +534,7 @@ main (int argc, char **argv)
csid, (len = 1024, &len),
dom, (len2 = 256, &len),
&use);
if (AllocateAndInitializeSid (GetSidIdentifierAuthority (csid),
5,
print_special (print_sids, GetSidIdentifierAuthority (csid), 5,
*GetSidSubAuthority (csid, 0),
*GetSidSubAuthority (csid, 1),
*GetSidSubAuthority (csid, 2),
@ -520,17 +542,7 @@ main (int argc, char **argv)
513,
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);
}
0);
free (csid);
}

View File

@ -13,6 +13,7 @@
#include <wchar.h>
#include <stdio.h>
#include <windows.h>
#include <io.h>
#include <sys/cygwin.h>
#include <getopt.h>
#include <lmaccess.h>
@ -39,13 +40,13 @@ load_netapi ()
if (!h)
return FALSE;
if (!(netapibufferfree = GetProcAddress (h, "NetApiBufferFree")))
if (!(netapibufferfree = (void *) GetProcAddress (h, "NetApiBufferFree")))
return FALSE;
if (!(netuserenum = GetProcAddress (h, "NetUserEnum")))
if (!(netuserenum = (void *) GetProcAddress (h, "NetUserEnum")))
return FALSE;
if (!(netlocalgroupenum = GetProcAddress (h, "NetLocalGroupEnum")))
if (!(netlocalgroupenum = (void *) GetProcAddress (h, "NetLocalGroupEnum")))
return FALSE;
if (!(netgetdcname = GetProcAddress (h, "NetGetDCName")))
if (!(netgetdcname = (void *) GetProcAddress (h, "NetGetDCName")))
return FALSE;
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,
gid + id_offset,
fullname,
print_sids && fullname[0] ? "," : "",
print_sids ? "U-" : "",
print_sids ? domain_name : "",
print_sids && domain_name[0] ? "\\" : "",
print_sids ? username : "",
print_sids ? "," : "",
print_sids ? put_sid (psid) : "",
homedir_psx);
@ -312,6 +319,50 @@ enum_local_groups (int print_sids)
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
usage ()
{
@ -364,15 +415,14 @@ main (int argc, char **argv)
int id_offset = 10000;
int i;
char name[256], dom[256], passed_home_path[MAX_PATH];
DWORD len, len2;
PSID sid;
SID_NAME_USE use;
char name[256], passed_home_path[MAX_PATH];
DWORD len;
passed_home_path[0] = '\0';
setmode (1, O_BINARY);
if (GetVersion () < 0x80000000)
{
if (argc == 1)
return usage ();
else
@ -432,6 +482,7 @@ main (int argc, char **argv)
domain_name_specified = 1;
}
}
}
if (passed_home_path[0] == '\0')
strcpy (passed_home_path, "/home/");
@ -462,59 +513,16 @@ 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:%d:%s%s::\n", name,
SECURITY_WORLD_RID,
SECURITY_WORLD_RID,
print_sids ? "," : "",
print_sids ? put_sid (sid) : "");
FreeSid (sid);
}
print_special (print_sids, &sid_world_auth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0);
/*
* 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:%s%s::\n", name,
SECURITY_LOCAL_SYSTEM_RID,
SECURITY_LOCAL_SYSTEM_RID,
print_sids ? "," : "",
print_sids ? put_sid (sid) : "");
FreeSid (sid);
}
print_special (print_sids, &sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0);
/*
* Get `administrators' group
*/
if (!print_local_groups
&& AllocateAndInitializeSid (&sid_nt_auth, 2,
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)
print_special (print_sids, &sid_nt_auth, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0);
if (print_local_groups)
enum_local_groups (print_sids);