From 0ac91154fc664eaed66a8a286069b916adf34e25 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 15 Apr 2000 22:30:49 +0000 Subject: [PATCH] * mkpasswd.c (main): Use GetDCName instead of GetAnyDCName. Don't create extra passwd entry for administrators group if local_groups is set. (usage): Change usage text slightly. (enum_users): Loop while ERROR_MORE_DATA is returned. (enum_local_groups): Ditto. * mkgroup.c (enum_local_groups): Ditto. (enum_groups) Ditto. (usage): Change usage text slightly. --- winsup/utils/ChangeLog | 12 ++++++++++++ winsup/utils/mkgroup.c | 16 +++++++++------- winsup/utils/mkpasswd.c | 30 +++++++++++++++++------------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index e389c97aa..840b8bb3a 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,15 @@ +Sat Apr 15 23:34:00 2000 Corinna Vinschen + + * mkpasswd.c (main): Use GetDCName instead of GetAnyDCName. + Don't create extra passwd entry for administrators group + if local_groups is set. + (usage): Change usage text slightly. + (enum_users): Loop while ERROR_MORE_DATA is returned. + (enum_local_groups): Ditto. + * mkgroup.c (enum_local_groups): Ditto. + (enum_groups) Ditto. + (usage): Change usage text slightly. + Thu Apr 13 01:22:35 2000 Christopher Faylor * cygpath.cc (main): Add -a -o and -c options. diff --git a/winsup/utils/mkgroup.c b/winsup/utils/mkgroup.c index 0c322bbc6..ecf080166 100644 --- a/winsup/utils/mkgroup.c +++ b/winsup/utils/mkgroup.c @@ -82,13 +82,14 @@ enum_local_groups (int print_sids) DWORD entriesread = 0; DWORD totalentries = 0; DWORD resume_handle = 0; + DWORD rc; do { DWORD i; - DWORD rc = NetLocalGroupEnum (NULL, 0, (LPBYTE *) & buffer, 1024, - &entriesread, &totalentries, &resume_handle); + rc = NetLocalGroupEnum (NULL, 0, (LPBYTE *) & buffer, 1024, + &entriesread, &totalentries, &resume_handle); switch (rc) { case ERROR_ACCESS_DENIED: @@ -155,7 +156,7 @@ enum_local_groups (int print_sids) NetApiBufferFree (buffer); } - while (entriesread < totalentries); + while (rc == ERROR_MORE_DATA); return 0; } @@ -167,6 +168,7 @@ enum_groups (LPWSTR servername, int print_sids) DWORD entriesread = 0; DWORD totalentries = 0; DWORD resume_handle = 0; + DWORD rc; char ansi_srvname[256]; if (servername) @@ -175,9 +177,9 @@ enum_groups (LPWSTR servername, int print_sids) do { DWORD i; - DWORD rc = NetGroupEnum (servername, 2, (LPBYTE *) & buffer, 1024, - &entriesread, &totalentries, &resume_handle); + rc = NetGroupEnum (servername, 2, (LPBYTE *) & buffer, 1024, + &entriesread, &totalentries, &resume_handle); switch (rc) { case ERROR_ACCESS_DENIED: @@ -252,7 +254,7 @@ enum_groups (LPWSTR servername, int print_sids) NetApiBufferFree (buffer); } - while (entriesread < totalentries); + while (rc == ERROR_MORE_DATA); if (servername) NetApiBufferFree (servername); @@ -271,7 +273,7 @@ usage () fprintf (stderr, " specified (or from the current domain if there is\n"); fprintf (stderr, " no domain specified)\n"); fprintf (stderr, " -s,--no-sids don't print SIDs in pwd field\n"); - fprintf (stderr, " (this affects NT security)\n"); + fprintf (stderr, " (this affects ntsec)\n"); fprintf (stderr, " -?,--help print this message\n\n"); exit (1); } diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c index 649320c50..5b964585e 100644 --- a/winsup/utils/mkpasswd.c +++ b/winsup/utils/mkpasswd.c @@ -82,6 +82,7 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath) DWORD entriesread = 0; DWORD totalentries = 0; DWORD resume_handle = 0; + DWORD rc; char ansi_srvname[256]; if (servername) @@ -90,10 +91,10 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath) do { DWORD i; - DWORD rc = NetUserEnum (servername, 3, FILTER_NORMAL_ACCOUNT, - (LPBYTE *) & buffer, 1024, - &entriesread, &totalentries, &resume_handle); + rc = NetUserEnum (servername, 3, FILTER_NORMAL_ACCOUNT, + (LPBYTE *) & buffer, 1024, + &entriesread, &totalentries, &resume_handle); switch (rc) { case ERROR_ACCESS_DENIED: @@ -182,7 +183,7 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath) NetApiBufferFree (buffer); } - while (entriesread < totalentries); + while (rc == ERROR_MORE_DATA); if (servername) NetApiBufferFree (servername); @@ -197,13 +198,14 @@ enum_local_groups (int print_sids) DWORD entriesread = 0; DWORD totalentries = 0; DWORD resume_handle = 0; + DWORD rc ; do { DWORD i; - DWORD rc = NetLocalGroupEnum (NULL, 0, (LPBYTE *) & buffer, 1024, - &entriesread, &totalentries, &resume_handle); + rc = NetLocalGroupEnum (NULL, 0, (LPBYTE *) & buffer, 1024, + &entriesread, &totalentries, &resume_handle); switch (rc) { case ERROR_ACCESS_DENIED: @@ -270,7 +272,7 @@ enum_local_groups (int print_sids) NetApiBufferFree (buffer); } - while (entriesread < totalentries); + while (rc == ERROR_MORE_DATA); return 0; } @@ -288,7 +290,7 @@ usage () fprintf (stderr, " -g,--local-groups print local group information too\n"); fprintf (stderr, " -m,--no-mount don't use mount points for home dir\n"); fprintf (stderr, " -s,--no-sids don't print SIDs in GCOS field\n"); - fprintf (stderr, " (this affects NT security)\n"); + fprintf (stderr, " (this affects ntsec)\n"); fprintf (stderr, " -?,--help displays this message\n\n"); fprintf (stderr, "This program does only work on Windows NT\n\n"); exit (1); @@ -392,9 +394,11 @@ main (int argc, char **argv) /* * Get `administrators' group */ - if (AllocateAndInitializeSid (&sid_nt_auth, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &sid)) + if (!print_local + && 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), @@ -414,10 +418,10 @@ main (int argc, char **argv) if (print_domain) { if (domain_name_specified) - rc = NetGetAnyDCName (NULL, domain_name, (LPBYTE *) & servername); + rc = NetGetDCName (NULL, domain_name, (LPBYTE *) & servername); else - rc = NetGetAnyDCName (NULL, NULL, (LPBYTE *) & servername); + rc = NetGetDCName (NULL, NULL, (LPBYTE *) & servername); if (rc != ERROR_SUCCESS) { -- 2.43.5