* Makefile.in (ALL_LDFLAGS): Add --enable-auto-import option to quiet ld
warnings. * mkgroup.c: Change all global variables and most functions to static. (enum_local_groups): Add a print_current parameter to control whether entries for everything should be printed or just the current user. (enum_groups): Ditto. (main): Move call fetch_current_pgrp_sid earlier to avoid a NULL deference when no command line arguments are specified. Accommodate argument changes to above functions. Avoid printing SYSTEM account when print_current is specified. Issue error when extra stuff is found on the command line. * mkpasswd.c: Change all global variables and most functions to static. (enum_users): Add a print_current parameter to control whether entries for everything should be printed or just the current user. (main): Move call fetch_current_user_sid earlier to avoid a NULL deference when no command line arguments are specified. Accommodate argument change to above function. Avoid printing standard accounts when print_current is specified. Issue error when extra stuff is found on the command line.
This commit is contained in:
parent
f609b6715a
commit
6510edf4bc
@ -1,3 +1,25 @@
|
|||||||
|
2008-08-17 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* Makefile.in (ALL_LDFLAGS): Add --enable-auto-import option to quiet
|
||||||
|
ld warnings.
|
||||||
|
* mkgroup.c: Change all global variables and most functions to static.
|
||||||
|
(enum_local_groups): Add a print_current parameter to control whether
|
||||||
|
entries for everything should be printed or just the current user.
|
||||||
|
(enum_groups): Ditto.
|
||||||
|
(main): Move call fetch_current_pgrp_sid earlier to avoid a NULL
|
||||||
|
deference when no command line arguments are specified. Accommodate
|
||||||
|
argument changes to above functions. Avoid printing SYSTEM account
|
||||||
|
when print_current is specified. Issue error when extra stuff is found
|
||||||
|
on the command line.
|
||||||
|
* mkpasswd.c: Change all global variables and most functions to static.
|
||||||
|
(enum_users): Add a print_current parameter to control whether entries
|
||||||
|
for everything should be printed or just the current user.
|
||||||
|
(main): Move call fetch_current_user_sid earlier to avoid a NULL
|
||||||
|
deference when no command line arguments are specified. Accommodate
|
||||||
|
argument change to above function. Avoid printing standard accounts
|
||||||
|
when print_current is specified. Issue error when extra stuff is found
|
||||||
|
on the command line.
|
||||||
|
|
||||||
2008-08-15 Corinna Vinschen <corinna@vinschen.de>
|
2008-08-15 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* mkgroup.c (fetch_current_pgrp_sid): New function to fetch primary
|
* mkgroup.c (fetch_current_pgrp_sid): New function to fetch primary
|
||||||
|
@ -41,7 +41,7 @@ include $(srcdir)/../Makefile.common
|
|||||||
.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
|
.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
|
||||||
|
|
||||||
ALL_LDLIBS := -lnetapi32 -ladvapi32
|
ALL_LDLIBS := -lnetapi32 -ladvapi32
|
||||||
ALL_LDFLAGS := -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
|
ALL_LDFLAGS := -Wl,--enable-auto-import -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
|
||||||
ALL_DEP_LDLIBS := $(cygwin_build)/libcygwin.a ${patsubst -l%,\
|
ALL_DEP_LDLIBS := $(cygwin_build)/libcygwin.a ${patsubst -l%,\
|
||||||
$(w32api_lib)/lib%.a,$(ALL_LDLIBS) -lkernel32 -luser32}
|
$(w32api_lib)/lib%.a,$(ALL_LDLIBS) -lkernel32 -luser32}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ typedef struct
|
|||||||
BOOL with_dom;
|
BOOL with_dom;
|
||||||
} domlist_t;
|
} domlist_t;
|
||||||
|
|
||||||
void
|
static void
|
||||||
_print_win_error (DWORD code, int line)
|
_print_win_error (DWORD code, int line)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
@ -69,7 +69,7 @@ _print_win_error (DWORD code, int line)
|
|||||||
fprintf (stderr, "mkgroup (%d): error %lu", line, code);
|
fprintf (stderr, "mkgroup (%d): error %lu", line, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
load_dsgetdcname ()
|
load_dsgetdcname ()
|
||||||
{
|
{
|
||||||
HANDLE h = LoadLibrary ("netapi32.dll");
|
HANDLE h = LoadLibrary ("netapi32.dll");
|
||||||
@ -124,7 +124,7 @@ get_dcname (char *domain)
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
put_sid (PSID psid)
|
put_sid (PSID psid)
|
||||||
{
|
{
|
||||||
static char s[512];
|
static char s[512];
|
||||||
@ -158,10 +158,10 @@ typedef struct {
|
|||||||
int buffer[10];
|
int buffer[10];
|
||||||
} sidbuf;
|
} sidbuf;
|
||||||
|
|
||||||
sidbuf curr_pgrp;
|
static sidbuf curr_pgrp;
|
||||||
BOOL got_curr_pgrp = FALSE;
|
static BOOL got_curr_pgrp = FALSE;
|
||||||
|
|
||||||
void
|
static void
|
||||||
fetch_current_pgrp_sid ()
|
fetch_current_pgrp_sid ()
|
||||||
{
|
{
|
||||||
DWORD len;
|
DWORD len;
|
||||||
@ -177,7 +177,7 @@ fetch_current_pgrp_sid ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
current_group (const char *sep, DWORD id_offset)
|
current_group (const char *sep, DWORD id_offset)
|
||||||
{
|
{
|
||||||
WCHAR grp[GNLEN + 1];
|
WCHAR grp[GNLEN + 1];
|
||||||
@ -204,7 +204,7 @@ current_group (const char *sep, DWORD id_offset)
|
|||||||
id_offset + gid);
|
id_offset + gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
||||||
char *unix_grp_list)
|
char *unix_grp_list)
|
||||||
{
|
{
|
||||||
@ -307,9 +307,10 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
|||||||
FreeSid (psid);
|
FreeSid (psid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||||
DWORD id_offset, char *disp_groupname, int print_builtin)
|
DWORD id_offset, char *disp_groupname, int print_builtin,
|
||||||
|
int print_current)
|
||||||
{
|
{
|
||||||
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
PWCHAR servername = NULL;
|
PWCHAR servername = NULL;
|
||||||
@ -431,8 +432,12 @@ enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
CopySid (sizeof (DBGSID), &builtin_sid_list[builtin_sid_cnt++],
|
CopySid (sizeof (DBGSID), &builtin_sid_list[builtin_sid_cnt++],
|
||||||
psid);
|
psid);
|
||||||
}
|
}
|
||||||
if (EqualSid (curr_pgrp.psid, psid))
|
if (!print_current)
|
||||||
|
/* fall through */;
|
||||||
|
else if (EqualSid (curr_pgrp.psid, psid))
|
||||||
got_curr_pgrp = TRUE;
|
got_curr_pgrp = TRUE;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
|
gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
|
||||||
printf ("%ls%s%ls:%s:%ld:\n",
|
printf ("%ls%s%ls:%s:%ld:\n",
|
||||||
with_dom && !is_builtin ? domain_name : L"",
|
with_dom && !is_builtin ? domain_name : L"",
|
||||||
@ -452,9 +457,9 @@ skip_group:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||||
DWORD id_offset, char *disp_groupname)
|
DWORD id_offset, char *disp_groupname, int print_current)
|
||||||
{
|
{
|
||||||
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
PWCHAR servername = NULL;
|
PWCHAR servername = NULL;
|
||||||
@ -554,8 +559,12 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (EqualSid (curr_pgrp.psid, psid))
|
if (!print_current)
|
||||||
|
/* fall through */;
|
||||||
|
else if (EqualSid (curr_pgrp.psid, psid))
|
||||||
got_curr_pgrp = TRUE;
|
got_curr_pgrp = TRUE;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
printf ("%ls%s%ls:%s:%lu:\n",
|
printf ("%ls%s%ls:%s:%lu:\n",
|
||||||
with_dom ? domain_name : L"",
|
with_dom ? domain_name : L"",
|
||||||
with_dom ? sep : "",
|
with_dom ? sep : "",
|
||||||
@ -570,7 +579,7 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
while (rc == ERROR_MORE_DATA);
|
while (rc == ERROR_MORE_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
||||||
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
||||||
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
||||||
@ -610,7 +619,7 @@ print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
usage (FILE * stream)
|
usage (FILE * stream)
|
||||||
{
|
{
|
||||||
fprintf (stream,
|
fprintf (stream,
|
||||||
@ -672,9 +681,9 @@ struct option longopts[] = {
|
|||||||
{0, no_argument, NULL, 0}
|
{0, no_argument, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char opts[] = "bcCd::D::g:hl::L::o:sS:uU:v";
|
static char opts[] = "bcCd::D::g:hl::L::o:sS:uU:v";
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_version ()
|
print_version ()
|
||||||
{
|
{
|
||||||
const char *v = strchr (version, ':');
|
const char *v = strchr (version, ':');
|
||||||
@ -712,7 +721,7 @@ fetch_primary_domain ()
|
|||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
status = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
status = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
||||||
(PVOID *) &p_dom);
|
(PVOID *) ((void *) &p_dom));
|
||||||
LsaClose (lsa);
|
LsaClose (lsa);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -741,6 +750,8 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
load_dsgetdcname ();
|
load_dsgetdcname ();
|
||||||
in_domain = fetch_primary_domain ();
|
in_domain = fetch_primary_domain ();
|
||||||
|
fetch_current_pgrp_sid ();
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
||||||
@ -748,12 +759,12 @@ main (int argc, char **argv)
|
|||||||
if (in_domain)
|
if (in_domain)
|
||||||
{
|
{
|
||||||
if (!enum_local_groups (TRUE, NULL, sep_char, id_offset,
|
if (!enum_local_groups (TRUE, NULL, sep_char, id_offset,
|
||||||
disp_groupname, print_builtin))
|
disp_groupname, print_builtin, 0))
|
||||||
enum_groups (TRUE, NULL, sep_char, id_offset, disp_groupname);
|
enum_groups (TRUE, NULL, sep_char, id_offset, disp_groupname, 0);
|
||||||
}
|
}
|
||||||
else if (!enum_local_groups (FALSE, NULL, sep_char, 0, disp_groupname,
|
else if (!enum_local_groups (FALSE, NULL, sep_char, 0, disp_groupname,
|
||||||
print_builtin))
|
print_builtin, 0))
|
||||||
enum_groups (FALSE, NULL, sep_char, 0, disp_groupname);
|
enum_groups (FALSE, NULL, sep_char, 0, disp_groupname, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,13 +864,19 @@ skip:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv[optind])
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"mkgroup: non-option command line argument `%s' is not allowed.\n"
|
||||||
|
"Try `mkgroup --help' for more information.\n", argv[optind]);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get 'system' group */
|
/* Get 'system' group */
|
||||||
if (!disp_groupname && print_system && print_builtin)
|
if (!disp_groupname && print_system && print_builtin && !print_current)
|
||||||
print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
print_special (&sid_nt_auth, 1, SECURITY_LOCAL_SYSTEM_RID,
|
||||||
0, 0, 0, 0, 0, 0, 0);
|
0, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
fetch_current_pgrp_sid ();
|
|
||||||
|
|
||||||
off = id_offset;
|
off = id_offset;
|
||||||
for (i = 0; i < print_domlist; ++i)
|
for (i = 0; i < print_domlist; ++i)
|
||||||
{
|
{
|
||||||
@ -867,12 +884,12 @@ skip:
|
|||||||
? domlist[i].id_offset != ULONG_MAX
|
? domlist[i].id_offset != ULONG_MAX
|
||||||
? domlist[i].id_offset : off : 0;
|
? domlist[i].id_offset : off : 0;
|
||||||
if (!enum_local_groups (domlist[i].domain, domlist + i, sep_char,
|
if (!enum_local_groups (domlist[i].domain, domlist + i, sep_char,
|
||||||
my_off, disp_groupname, print_builtin))
|
my_off, disp_groupname, print_builtin, print_current))
|
||||||
{
|
{
|
||||||
if (!domlist[i].domain && domlist[i].str && print_unix)
|
if (!domlist[i].domain && domlist[i].str && print_unix)
|
||||||
enum_unix_groups (domlist + i, sep_char, my_off, print_unix);
|
enum_unix_groups (domlist + i, sep_char, my_off, print_unix);
|
||||||
enum_groups (domlist[i].domain, domlist + i, sep_char, my_off,
|
enum_groups (domlist[i].domain, domlist + i, sep_char, my_off,
|
||||||
disp_groupname);
|
disp_groupname, print_current);
|
||||||
if (my_off)
|
if (my_off)
|
||||||
off += id_offset;
|
off += id_offset;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ typedef struct
|
|||||||
BOOL with_dom;
|
BOOL with_dom;
|
||||||
} domlist_t;
|
} domlist_t;
|
||||||
|
|
||||||
void
|
static void
|
||||||
_print_win_error(DWORD code, int line)
|
_print_win_error(DWORD code, int line)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
@ -69,7 +69,7 @@ _print_win_error(DWORD code, int line)
|
|||||||
fprintf (stderr, "mkpasswd (%d): error %lu", line, code);
|
fprintf (stderr, "mkpasswd (%d): error %lu", line, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
load_dsgetdcname ()
|
load_dsgetdcname ()
|
||||||
{
|
{
|
||||||
HANDLE h = LoadLibrary ("netapi32.dll");
|
HANDLE h = LoadLibrary ("netapi32.dll");
|
||||||
@ -125,7 +125,7 @@ get_dcname (char *domain)
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
put_sid (PSID sid)
|
put_sid (PSID sid)
|
||||||
{
|
{
|
||||||
static char s[512];
|
static char s[512];
|
||||||
@ -143,7 +143,7 @@ put_sid (PSID sid)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
psx_dir (char *in, char *out)
|
psx_dir (char *in, char *out)
|
||||||
{
|
{
|
||||||
if (isalpha (in[0]) && in[1] == ':')
|
if (isalpha (in[0]) && in[1] == ':')
|
||||||
@ -166,7 +166,7 @@ psx_dir (char *in, char *out)
|
|||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
uni2ansi (LPWSTR wcs, char *mbs, int size)
|
uni2ansi (LPWSTR wcs, char *mbs, int size)
|
||||||
{
|
{
|
||||||
if (wcs)
|
if (wcs)
|
||||||
@ -180,11 +180,11 @@ typedef struct {
|
|||||||
int buffer[10];
|
int buffer[10];
|
||||||
} sidbuf;
|
} sidbuf;
|
||||||
|
|
||||||
sidbuf curr_user;
|
static sidbuf curr_user;
|
||||||
sidbuf curr_pgrp;
|
static sidbuf curr_pgrp;
|
||||||
BOOL got_curr_user = FALSE;
|
static BOOL got_curr_user = FALSE;
|
||||||
|
|
||||||
void
|
static void
|
||||||
fetch_current_user_sid ()
|
fetch_current_user_sid ()
|
||||||
{
|
{
|
||||||
DWORD len;
|
DWORD len;
|
||||||
@ -202,7 +202,7 @@ fetch_current_user_sid ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
current_user (int print_cygpath, const char *sep, const char *passed_home_path,
|
current_user (int print_cygpath, const char *sep, const char *passed_home_path,
|
||||||
DWORD id_offset, const char *disp_username)
|
DWORD id_offset, const char *disp_username)
|
||||||
{
|
{
|
||||||
@ -279,7 +279,7 @@ current_user (int print_cygpath, const char *sep, const char *passed_home_path,
|
|||||||
homedir_psx);
|
homedir_psx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
||||||
char *unix_user_list)
|
char *unix_user_list)
|
||||||
{
|
{
|
||||||
@ -382,10 +382,10 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
|||||||
FreeSid (psid);
|
FreeSid (psid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||||
int print_cygpath, const char *passed_home_path, DWORD id_offset,
|
int print_cygpath, const char *passed_home_path, DWORD id_offset,
|
||||||
char *disp_username)
|
char *disp_username, int print_current)
|
||||||
{
|
{
|
||||||
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
PWCHAR servername = NULL;
|
PWCHAR servername = NULL;
|
||||||
@ -397,7 +397,6 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
DWORD resume_handle = 0;
|
DWORD resume_handle = 0;
|
||||||
DWORD rc;
|
DWORD rc;
|
||||||
WCHAR uni_name[UNLEN + 1];
|
WCHAR uni_name[UNLEN + 1];
|
||||||
|
|
||||||
if (domain)
|
if (domain)
|
||||||
{
|
{
|
||||||
servername = get_dcname (d_or_m);
|
servername = get_dcname (d_or_m);
|
||||||
@ -508,8 +507,13 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (EqualSid (curr_user.psid, psid))
|
if (!print_current)
|
||||||
|
/* fall through */;
|
||||||
|
else if (EqualSid (curr_user.psid, psid))
|
||||||
got_curr_user = TRUE;
|
got_curr_user = TRUE;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
printf ("%ls%s%ls:unused:%lu:%lu:%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n",
|
printf ("%ls%s%ls:unused:%lu:%lu:%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n",
|
||||||
with_dom ? domain_name : L"",
|
with_dom ? domain_name : L"",
|
||||||
with_dom ? sep : "",
|
with_dom ? sep : "",
|
||||||
@ -533,7 +537,7 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
||||||
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
DWORD sub1, DWORD sub2, DWORD sub3, DWORD sub4,
|
||||||
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
DWORD sub5, DWORD sub6, DWORD sub7, DWORD sub8)
|
||||||
@ -575,7 +579,7 @@ print_special (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
usage (FILE * stream)
|
usage (FILE * stream)
|
||||||
{
|
{
|
||||||
fprintf (stream,
|
fprintf (stream,
|
||||||
@ -620,7 +624,7 @@ usage (FILE * stream)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
{"current", no_argument, NULL, 'c'},
|
{"current", no_argument, NULL, 'c'},
|
||||||
{"Current", no_argument, NULL, 'C'},
|
{"Current", no_argument, NULL, 'C'},
|
||||||
{"domain", optional_argument, NULL, 'd'},
|
{"domain", optional_argument, NULL, 'd'},
|
||||||
@ -640,7 +644,7 @@ struct option longopts[] = {
|
|||||||
{0, no_argument, NULL, 0}
|
{0, no_argument, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char opts[] = "cCd::D::ghl::L::mo:sS:p:u:U:v";
|
static char opts[] = "cCd::D::ghl::L::mo:sS:p:u:U:v";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_version ()
|
print_version ()
|
||||||
@ -692,7 +696,7 @@ fetch_primary_domain ()
|
|||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
status = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
status = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
||||||
(PVOID *) &p_dom);
|
(PVOID *) ((void *) &p_dom));
|
||||||
LsaClose (lsa);
|
LsaClose (lsa);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -722,15 +726,17 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
load_dsgetdcname ();
|
load_dsgetdcname ();
|
||||||
in_domain = fetch_primary_domain ();
|
in_domain = fetch_primary_domain ();
|
||||||
|
fetch_current_user_sid ();
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
enum_std_accounts ();
|
enum_std_accounts ();
|
||||||
if (in_domain)
|
if (in_domain)
|
||||||
enum_users (TRUE, NULL, sep_char, print_cygpath, passed_home_path,
|
enum_users (TRUE, NULL, sep_char, print_cygpath, passed_home_path,
|
||||||
10000, disp_username);
|
10000, disp_username, 0);
|
||||||
else
|
else
|
||||||
enum_users (FALSE, NULL, sep_char, print_cygpath, passed_home_path, 0,
|
enum_users (FALSE, NULL, sep_char, print_cygpath, passed_home_path, 0,
|
||||||
disp_username);
|
disp_username, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +852,13 @@ skip:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_current_user_sid ();
|
if (argv[optind])
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"mkpasswd: non-option command line argument `%s' is not allowed.\n"
|
||||||
|
"Try `mkpasswd --help' for more information.\n", argv[optind]);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
off = id_offset;
|
off = id_offset;
|
||||||
for (i = 0; i < print_domlist; ++i)
|
for (i = 0; i < print_domlist; ++i)
|
||||||
@ -856,10 +868,10 @@ skip:
|
|||||||
? domlist[i].id_offset : off : 0;
|
? domlist[i].id_offset : off : 0;
|
||||||
if (!domlist[i].domain && domlist[i].str && print_unix)
|
if (!domlist[i].domain && domlist[i].str && print_unix)
|
||||||
enum_unix_users (domlist + i, sep_char, my_off, print_unix);
|
enum_unix_users (domlist + i, sep_char, my_off, print_unix);
|
||||||
if (!my_off)
|
if (!my_off && !print_current)
|
||||||
enum_std_accounts ();
|
enum_std_accounts ();
|
||||||
enum_users (domlist[i].domain, domlist + i, sep_char, print_cygpath,
|
enum_users (domlist[i].domain, domlist + i, sep_char, print_cygpath,
|
||||||
passed_home_path, my_off, disp_username);
|
passed_home_path, my_off, disp_username, print_current);
|
||||||
if (my_off)
|
if (my_off)
|
||||||
off += id_offset;
|
off += id_offset;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user