Commit Graph

69 Commits

Author SHA1 Message Date
Corinna Vinschen 773f4fa586 * mkgroup.c (MAX_SID_LEN): Remove. Instead, use SECURITY_MAX_SID_SIZE
throughout.
	(enum_unix_groups): Introduce numeric_psid and rearrange code to avoid
	potential heap corruption.
	* mkpasswd.c: Ditto.
2015-02-25 20:18:29 +00:00
Corinna Vinschen f3939c059c * mkgroup.c (main): Call enum_groups with offset 0x30000 for local
machine, same as from DB.
	* mkpasswd.c (enum_unix_users): Set pw_passwd field to '*'.
	(enum_users): Ditto.
	(main): Call enum_users with offset of 0x30000 for local machine,
	same as from DB.
2014-11-27 19:55:37 +00:00
Corinna Vinschen 35983199f3 * mkgroup.c (usage): Fix language.
* mkpasswd.c (usage): Ditto.
2014-11-12 14:22:05 +00:00
Corinna Vinschen 4acb3408e9 * mkgroup.c (enum_unix_groups): Always print groupname with machine
prefix.
	(usage): Extend help output for -l option.
	(main): Drop superfluous goto and label.  Make machine prefixing for
	local machine when using -l option dependend on options in
	/etc/nsswitch.conf.
	* mkpasswd.c: Ditto.
2014-11-12 14:13:56 +00:00
Corinna Vinschen df59ab7e7a * cygcheck.cc (dump_sysinfo): Handle Windows 10/Server 2014(?). 2014-11-10 16:21:52 +00:00
Corinna Vinschen c72a0d361d * mkgroup.c (usage): Move info message that this /etc/group isn't really
required anymore more to the top of the usage output.
	* mkpasswd.c (usage): Ditto for /etc/passwd.  Drop old text from output.
2014-07-29 13:29:54 +00:00
Corinna Vinschen 16a976cff4 * mkgroup.c (domlist_t): Drop id_offset.
(get_dcname): Remove.
	(current_group): Remove.
	(enum_unix_groups): Simplify.  Change space to underscore in domain
	name.
	(enum_local_groups): Simplify to accommodate the fact that it's only
	called for foreign machines.
	(enum_groups): Ditto.
	(print_special_by_sid): Remove.
	(print_special_by_name): Remove.
	(usage): Align to new code.
	(fetch_primary_domain): Remove.
	(main): Use cygwin_internal CW_SETENT, CW_GETENT and CW_ENDENT method.
	Call enum_local_groups, enum_groups, and enum_unix_groups only for
	foreign machines.
	* mkpasswd.c (get_dcname): Remove.
	(current_user): Remove.
	(enum_unix_users): Simplify.  Change space to underscore in domain name.
	(enum_users): Simplify to accommodate the fact that it's only
	called for foreign machines.
	(print_special_by_sid): Remove.
	(usage): Align to new code.
	(longopts): Add -b/--no-builtin option.
	(opts): Add -b option.
	(print_special_by_name): Remove.
	(enum_std_accounts): Remove.
	(fetch_primary_domain): Remove.
	(main): Use cygwin_internal CW_SETENT, CW_GETENT and CW_ENDENT method.
	Call enum_users and enum_unix_users only for foreign machines.
	* utils.xml (mkgroup): Align documentation to new usage.
	(mkpasswd): Ditto.
2014-02-24 10:51:42 +00:00
Corinna Vinschen 61522196c7 * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
Christopher Faylor df0f949cfd Update copyrights 2013-01-21 16:28:27 +00:00
Corinna Vinschen 6428476bdd * mkpasswd.c (current_user): Actually *use* $HOME if it's available.
Add comment to explain what we're doing here.
2012-05-05 08:55:17 +00:00
Corinna Vinschen 036fb4772c * mkgroup.c (print_special_by_sid): Rename from print_special. Change
calls throughout.
	(print_special_by_name): New function.
	(main): Call print_special_by_name for TrustedInstaller account.
	* mkpasswd.c (print_special_by_sid): Rename from print_special.  Change
	calls throughout.
	(print_special_by_name): New function.
	(enum_std_accounts): Call print_special_by_name for TrustedInstaller
	account.
2012-04-05 13:37:32 +00:00
Christopher Faylor 1b23b30b29 Clean up whitespace. 2011-12-17 23:39:47 +00:00
Corinna Vinschen 13a20f9565 * mkgroup.c: Drop support for NT4 domains.
* mkpasswd.c: Ditto.
	(psx_dir): Remove.
	(current_user): Drop support for -m option.  Use $HOME as is since it's
	a POSIX path anyway.
	(enum_users): Drop support for -m option.
	(usage): Mention -m option as ignored.
	(main): Drop support for -m option.  Mark ignored options as deprecated.
	* utils.sgml (mkpasswd): Remove description of -m option.
2011-12-01 13:06:13 +00:00
Corinna Vinschen 92b499acff * Align usage output, version output, as well as usage and version
option handling to use the same style throughout all Cygwin utils.
	Throughout use program_invocation_short_name to refer to current
	process name in Cygwin executables.
	* utils.sgml: Align documentation to above change.  Add missing
	sections for getconf, ldd, and setmetamode.
	* strace.cc (proc_child): Avoid compiler warning.
2011-10-10 14:57:48 +00:00
Corinna Vinschen 71d8f118da * loadlib.h: New header implementing safe LoadLibrary calls.
Include throughout files using LoadLibrary function.
	* cygcheck.cc (dump_sysinfo): Retrieve kernel32.dll handle via
	GetModuleHandle, rather than using LoadLibrary.
	* cygpath.cc (get_long_name): Ditto.
	(do_sysfolders): Append .dll suffix in LoadLibrary call.
	* ldh.cc (WinMain): Use LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES
	to avoid loading malicious library code.
	* locale.cc (print_locale_with_codeset): Change way to retrieve
	kernel32.dll path.
2010-08-28 11:22:37 +00:00
Christopher Faylor a37e07482c * mkpasswd.c: Properly define __progname as __declspec(dllimport).
* mkgroup.c: Ditto.
2009-10-02 13:49:39 +00:00
Corinna Vinschen 91dd009e81 * mkgroup.c (enum_local_groups): Avoid error message if given group
name isn't found and return 0 to allow searching to proceed.  Always
	return 0 or 1, not -1.
	(enum_groups): Avoid error message if given group name isn't found.
	* mkpasswd.c (enum_users): Ditto.
2009-08-11 08:59:50 +00:00
Corinna Vinschen 73535010d7 * cygpath.cc (main): Only setlocale for LC_CTYPE category. Fallback
to UTF-8 if locale is "C".
	* ldd.cc (main): Ditto.
	* mkgroup.c (main): Ditto.
	* mkpasswd.c (main): Ditto.
	* passwd.c (main): Ditto.
2009-05-15 11:30:18 +00:00
Corinna Vinschen 05e6f7b2b9 * mkpasswd.c (current_user): Don't use HOMEDRIVE/HOMEPATH to generate
user's homedir.

	* mkgroup.c: Accommodate ctype changes.
	* mkpasswd.c: Ditto.
	* setfacl.c: Ditto.
	* ssp.c: Ditto.
2009-05-06 11:54:24 +00:00
Corinna Vinschen 328b090f29 * mkgroup.c (enum_local_groups): Don't skip printing groups when
print_current is set and group SID is not curr_pgrp.
	(enum_groups): Ditto.
	(main): Fix condition when SYSTEM group gets printed.
	* mkpasswd.c (enum_users): Don't skip printing users when print_current
	is set and user SID is not curr_user.
	(main): Allow printing standard accounts even when print_current is set.
2008-08-25 09:38:14 +00:00
Corinna Vinschen 096df1774b * mkgroup.c (main): Keep correctly track of optional arguments.
* mkpasswd.c (main): Ditto.
2008-08-18 08:52:49 +00:00
Corinna Vinschen 01dd3162ff * mkgroup.c (main): Always unset environment variable POSIXLY_CORRECT.
Keep track of optional argumnts and fix up optind afterwards.
	* mkpasswd.c (main): Ditto.
2008-08-18 08:33:48 +00:00
Christopher Faylor 95141e7835 * mkpasswd.c (main): Avoid printing system accounts when a single user name has
been requested.
2008-08-17 17:00:50 +00:00
Christopher Faylor 6510edf4bc * 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-17 16:45:44 +00:00
Corinna Vinschen 9258eca9d4 * mkgroup.c (fetch_current_pgrp_sid): New function to fetch primary
group SID from user token.
	(current_group): Move up in file.  Move fetching primary group SID to
	fetch_current_pgrp_sid.
	(enum_local_groups): Check if current SID is the same as current user's
	primary group SID.
	(enum_groups): Ditto.
	(main): Call fetch_current_pgrp_sid before enumerating groups.  Call
	current_group only if current group hasn't been enumerated already.
	* mkpasswd.c (fetch_current_user_sid): New function to fetch current
	user SID from user token.
	(current_user): Move fetching current user SID to
	fetch_current_user_sid.
	(enum_users): Check if current SID is the same as current user's SID.
	(main): Call fetch_current_user_sid before enumerating users.  Call
	current_user only if current user hasn't been enumerated already.
2008-08-15 13:08:47 +00:00
Corinna Vinschen f36c78a487 * mkgroup.c (main): Fix test for duplicate domain/machine request.
* mkpasswd.c (main): Ditto.
2008-07-23 20:12:12 +00:00
Corinna Vinschen f9519bcd1a * mkgroup.c: Rework to allow per-domain/per-machine id_offset.
Add -b option to skip builtin groups.
	(main): Simplify code.
	* mkpasswd.c: Rework to allow per-domain/per-machine id_offset.
	(main): Simplify code.
	* utils.sgml: Explain changed mkgroup/mkpasswd -d/-D/-l/-L options.
	Add mkgroup -b option.
2008-07-23 18:09:50 +00:00
Corinna Vinschen 0bdab5c8a9 * mkgroup.c: Consolidate variable names.
(enum_unix_groups): New function.
	(print_special): Use LookupAccountSidW instead of LookupAccountSidA.
	(current_group): Ditto.
	(usage): Add -U option.
	(longopts): Add --unix option.
	(opts): Add -U option.
	(main): Handle -U option.  Call enum_unix_groups if set.
	* mkpasswd.c: Consolidate variable names.
	(current_user): Use LookupAccountSidW instead of LookupAccountSidA.
	(enum_unix_users): New function.
	(usage): Add -U option.
	(longopts): Add --unix option.
	(opts): Add -U option.
	(main): Handle -U option.  Call enum_unix_groups if set.
	* utils.sgml: Add -U option text to mkgroup and mkpasswd description.
2008-07-23 11:41:10 +00:00
Corinna Vinschen 7e1fdc9e2c * mkgroup.c (enum_groups): Create full qualified groupname using
domain or servername, depending on printing domain or machine accounts.
	* mkpasswd.c (enum_users): Ditto for users.
2008-07-22 20:47:14 +00:00
Corinna Vinschen a1e1990348 * Makefile.in (cygcheck.exe): Link against ntdll.
* bloda.cc: Use statically linked functions throughout.
	* cygpath.cc: Drop 9x considerations.
	* mkgroup.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique groupnames in
	domain\group syntax.  Add -S option to define domain\group separator
	char.  Ignore -u and -s options.
	* mkpasswd.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique usernames in
	domain\user syntax.  Add -S option to define domain\user separator
	char.  Ignore -g and -s options.  Prefer to take homedir from $HOME
	over $HOMEDRIVE/$HOMEPATH.
	* path.cc (oopts): Add "acl", "noacl", "posix=0" and "posix=1" options.
	(getmntent): Accomodate throughout.
	* ps.cc: Fix copyright dates.
	* utils.sgml: Fix text for mkgroup and mkpasswd.
2008-07-22 14:40:05 +00:00
Corinna Vinschen 375a780e06 * mkgroup.c: Use statically linked functions throughout, except for
DsGetDcNameW.  Reformat.  Convert to use WCHAR for names throughout.
	Use defines instead of constants throughout.
	(MAX_SID_LEN): Define.
	(load_netapi): Just load DsGetDcNameW pointer.
	(psx_dir): Remove.
	(uni2ansi): Remove.
	(enum_local_users): Take server name and use in Net... call.
	(DBGSID): Define datastructure.
	(MAX_BUILTIN_SIDS): Define.
	(builtin_sid_list): Define global sid list.
	(builtin_sid_cnt): Define counter for global sid list.
	(enum_local_groups): Take server name and use in Net... and Lookup...
	calls.  Take offset argument.  Use MAX_PREFERRED_LENGTH in call to
	NetLocalGroupEnum.  Check for duplicate builtin groups.
	(enum_users): Take server name and use in Net... call.
	(usage): Change text slightly.
	(print_version): Fix copyright.
	(main): Call enum_local_groups for domains as well.
	* mkpasswd.c: Use statically linked functions throughout, except for
	DsGetDcNameW.  Reformat.  Convert to use WCHAR for names throughout.
	Use defines instead of constants throughout.
	(MAX_SID_LEN): Define.
	(load_netapi): Just load DsGetDcNameW pointer.
	(uni2ansi): Use wcstombs.
	(current_user): Replace "unused_by_nt/2000/xp" by
	just "unused".
	(enum_users): Ditto.
	(print_version): Fix copyright.
2008-07-09 14:32:29 +00:00
Corinna Vinschen 2b2b42cf59 * cygpath.cc (do_sysfolders): Use cygwin_conv_path.
(do_pathconv): Use cygwin_conv_path and cygwin_conv_path_list.
	* dumper.cc (main): Use cygwin_conv_path.  Allocate target path
	dynamically.
	* mkpasswd.c (current_user): Use cygwin_conv_path.
	(enum_users): Ditto.
	* ps.cc (NT_MAX_PATH): Define.
	(main): Use cygwin_conv_path.
	* regtool.cc (find_key): Ditto. Allocate target path dynamically.
	(cmd_save): Ditto.
2008-03-12 12:47:09 +00:00
Corinna Vinschen 11cd2378b0 * mkpasswd.c (main): Simplify generating SYSTEM entry. Add entries
for LocalService and NetworkService accounts.  Change comments.
2008-02-28 11:11:12 +00:00
Christopher Faylor 14a4d5989a bad_keywords 2006-01-18 15:57:56 +00:00
Corinna Vinschen d829da1423 Align error message handling to mkpasswd's error messages throughout.
* mkgroup.c (print_win_error): Create macro calling ...
	(_print_win_error): ... this function created from former
	print_win_error.  Move up in source.
	(PDOMAIN_CONTROLLER_INFOW): Define return type of DcGetDcNameW.
	(dsgetdcname): New function pointer for DcGetDcNameW.
	(load_netapi): Get DcGetDcNameW address.
	(main): If DcGetDcNameW is available, use it.
	* mkpasswd.c (PDOMAIN_CONTROLLER_INFOW): Define return type of
	DcGetDcNameW.
	(dsgetdcname): New function pointer for DcGetDcNameW.
	(load_netapi): Get DcGetDcNameW address.
	(main): If DcGetDcNameW is available, use it.  Rename local variable
	domain_name_specified to domain_specified as in mkgroup.c.
2005-09-21 22:26:08 +00:00
Pierre Humblet 114b7248ee 2005-01-11 Pierre Humblet <pierre.humblet@ieee.org>
* mkpasswd.c (print_win_error): Transform into macro.
        (_print_win_error): Upgrade former print_win_error by
        printing the line.
        (current_user): Call _print_win_error.
        (enum_users): Print name in case of lookup failure.
        (enum_local_groups): Ditto.
2005-01-11 23:03:24 +00:00
Corinna Vinschen 508682370b * mkgroup.c: Avoid compiler warnings throughout.
* mkpasswd.c: Ditto.
	* passwd.c: Ditto.
2003-11-14 19:14:43 +00:00
Joshua Daniel Franklin 45bfd8ed74 * mkpasswd.c (usage) Remove extra newline from description output. 2003-04-26 22:33:00 +00:00
Joshua Daniel Franklin aa275fe010 * cygcheck.cc (usage) Add description output. 2003-04-26 21:52:03 +00:00
Pierre Humblet 57efd527df 2003-04-10 Pierre Humblet <pierre.humblet@ieee.org>
* mkpasswd.c (current_user): print uid and gid as unsigned.
        (enum_users): Ditto. Do not free servername.
        (usage): Update to allow several domains and improve -p.
        (main): On Win9x limit uids to 1000. Only print specials
        when -l is specified. Add a loop to allow several domains
        and free servername in the loop.
        * mkgroup.c (enum_groups): Do not free servername.
        (usage): Update to allow several domains. Change uid to gid.
        (main): Only print specials when -l is specified. Add a
        loop to allow several domains and free servername in the loop.
2003-04-10 01:14:18 +00:00
Pierre Humblet f78765dadd 2003-03-01 Pierre Humblet <pierre.humblet@ieee.org>
* mkpasswd.cc (main): On Win95, output both a default line and a
       line for the current user (if known) with a pseudorandom uid. If
       the -u switch is given, produce a line for the specified user.
       * mkgroup.cc (main): On Win95 change the group name from "unknown" to
       "all".
2003-03-01 16:38:26 +00:00
Corinna Vinschen 3903b47b79 * mkgroup.c: Fix copyright date.
* mkpasswd.c: Ditto.
	* setfacl.c: Ditto.

	Fix ChangeLog typos.
2003-01-15 10:08:37 +00:00
Corinna Vinschen f1c9046a57 * mkpasswd.cc (current_user): Create.
(usage): Reorganize to support Win95/98/ME.
	(main): Add option for -c. Reorganize to parse options for
	Win95/98/ME and to call current_user. Add username in gecos field
	on Win95/98/ME.
	* mkgroup.cc (enum_groups): Print gid with %u.
	(print_win_error): Create from passwd.cc.
	(current_group): Create.
	(usage): Reorganize to support Win95/98/ME.
	(main): Add option for -c. Reorganize to parse options for
	Win95/98/ME and to call current_group.
2003-01-08 17:38:11 +00:00
Corinna Vinschen d1b6d5cd14 * mkpasswd.c (main): Set pw_passwd field to '*' on 9x/Me. 2002-11-25 15:12:50 +00:00
Christopher Faylor 0fa64fa3a7 * cygpath.cc (close_arg): Remove unused static.
* mkgroup.c (enum_local_users): Avoid compiler warning.
(enum_users): Ditto.
* mkpasswd.c: Ditto throughout.
* ssp.c: Ditto throughout.
2002-09-30 03:01:17 +00:00
Joshua Daniel Franklin 98467dae59 Add final newlines to utils 2002-09-15 19:24:37 +00:00
Corinna Vinschen 32c803daa2 * mkgroup.c (main): Don't print an entry for "Everyone".
* mkpasswd.c (print_special): Set pw_gid to 544 for SYSTEM user.
	(main): Don't print an entry for "Everyone".
2002-08-02 11:14:35 +00:00
Christopher Faylor dfe569334a * mkpasswd.cc (main): Don't reset to binmode if stdout is a terminal. 2002-05-30 19:35:51 +00:00
Corinna Vinschen eccebec08d * mkgroup.c (main): Change call to exit() to a return statement.
* mkpasswd.c (main): Ditto.

	* mkpasswd.c (usage): Simplify usage output.  Generalize to allow use
	for help. Correct '?' typo to 'h'.
	(longopts): Add version option.
	(opts): Add 'v' version option.
	(print_version): New function.
	(main): Accommodate new version option.  Accommodate usage parameter
	changes.
2002-04-29 10:21:54 +00:00
Corinna Vinschen 29a1ad942e * mkpasswd.c (main): Set default home path for 9x/Me if --path-to-home
isn't given.
2002-01-31 12:43:29 +00:00