* path.cc (path_conv::update_fs_info): Don't consider remote drives to be NTFS.
Set root_dir before invoking GetDriveType (from Kazuhiro Fujieda
<fujieda@jaist.ac.jp>). Eliminate extra checks for rootdir.
* exceptions.cc (sigdelayed): Ensure that signal is cleared as the last
operation or suffer races.
* sigproc.cc (proc_subproc): Deal with zombie array overflow.
Corinna Vinschen [Sun, 10 Jun 2001 10:00:21 +0000 (10:00 +0000)]
* cygwin.din: Add fchdir symbols.
* path.cc (chdir): Guard against invalid parameter.
(fchdir): New function.
* include/cygwin/version.h: Bump API minor version to 40.
* uinfo.cc (internal_getlogin): Remove unused variable.
* syscalls.cc (seteuid): Set environment variables USERNAME and
USERDOMAIN before impersonation to workaround a LookupAccountSid()
misbehaviour.
* uinfo.cc (internal_getlogin): Revert most of the previous change.
Don't set environment variables USERNAME and USERDOMAIN. That's
the job of seteuid() now. Try to get logon server from Lsa
only if logon server isn't already known.
* fhandler_console.cc (fhandler_console::dup): Allocate space for
savebuf on Cygwin heap.
(fhandler_console::char_command): Ditto. Use correct values for size.
Egor Duda [Tue, 5 Jun 2001 10:45:52 +0000 (10:45 +0000)]
* security.h (NTWriteEA): Change prototype.
* ntea.cc (NTReadEA): Don't check for global ntea setting, now
it's caller responsibility.
(NTWriteEA): Ditto.
* security.cc (get_file_attribute): Read attribute from EA only
if 'ntea' is enabled.
(set_file_attribute): Ditto.
* path.h: (class path_conv): Add members to store file system
information.
(path_conv::get_drive_type): New function.
* syscalls.cc (stat_worker): Use it.
* path.cc (path_conv::update_fs_info): New functions.
(path_conv::check): Get file system information from device where
file resides. On NTFS, try to read symlink contents from EA.
(get_symlink_ea): New function.
(set_symlink_ea): Ditto.
(symlink): Store symlink in extended attribute, if possible.
* cygheap.cc (cygheap_root::cygheap_rot): Remove constructor.
(cygheap_root::~cygheap_root): Remove destructor.
(cygheap_root::operator =): Remove.
(cygheap_root::set): New method.
* cygheap.h (cygheap_root): Reflect above changes. Store root info in
mount-like structure.
(cygheap_root:posix_ok): New method.
(cygheap_root::ischroot_native): Ditto.
(cygheap_root::unchroot): Ditto.
(cygheap_root::exists): Ditto.
(cygheap_root::posix_length): Ditto.
(cygheap_root::posix_path): Ditto.
(cygheap_root::native_length): Ditto.
(cygheap_root::native_path): Ditto.
* dir.cc (opendir): Remove special chroot test.
* path.cc (path_prefix_p): Remove front end.
(normalize_posix_path): Reorganize chroot tests to accomodate new convention of
allowing paths using posix chroot prefix.
(path_conv::check): Pass a "already ran normalize" option to
conv_to_win32_path. Return if there is an error from this function.
(mount_info::conv_to_win32_path): Add extra argument. Don't call
normalize_posix_path if caller has already done so. Substitute chroot setting,
if any, for root translation. Add chroot checking to final output step.
* shared_info (mount_info): Accomodate additional argument to
conv_to_win32_path.
* syscalls.cc (chroot): Store both normalized posix path and native path in
chroot.
* path.cc (chdir): Always send unsigned chars to isspace since newlib's isspace
doesn't deal well with "negative" chars.
* fhandler.cc (fhandler_disk_file::open): Propagate remote status of file
garnered from path_conv. Move #! checking to fstat.
(fhandler_disk_file::fstat): Reorganize st_mode setting to eliminate
duplication. Move check for #! here from fhandler::open.
* fhandler.h (fhandler_base::isremote): New method.
(fhandler_base::set_isremote): Ditto.
(fhandler_base::set_execable_p): Also record "don't care if executable state".
(fhandler_base::dont_care_if_execable): New method.
* path.cc (path_conv::check): Clear new flags. Appropriately set vol_flags,
drive_type, and is_remote_drive.
* path.h: Add new flags and methods for manipulating them.
* syscalls.cc (_unlink): Use isremote() to determine if a path is remote rather
than calling GetDriveType.
(stat_worker): Ditto.
* security.cc (get_file_attribute): Or attribute with result of NTReadEA to be
consistent with get_nt_attribute.
Corinna Vinschen [Tue, 29 May 2001 20:43:40 +0000 (20:43 +0000)]
* sec_helper.cc (cygsid::getfrompw): Change parameter to `const'.
(cygsid::getfromgr): Ditto.
* security.cc: Use `sys_mbstowcs' and `sys_wcstombs' throughout.
(extract_nt_dom_user): Try to get user and domain from SID in
pw->pw_gecos first.
* security.h (class cygsid): Change parameter of getfrompw() and
getfromgr() to `const'.
* uinfo.cc (internal_getlogin): Change order for evaluating user
information in winNT case. Drop usage of NetWkstaUserGetInfo().
Nick Clifton [Fri, 25 May 2001 21:17:06 +0000 (21:17 +0000)]
Fix bug when both pointers have matching, non-word alignment, and the length
is <= 4 but more than enough to move them over a word boundary.
Add comments explaining what each instruction does.
* path.cc (symlink_info::check): Correctly set 'ext_tacked_on'. Use this to
determine if user specified 'foo.lnk' explicitly. Reorganize slightly to get
rid of one goto.
Corinna Vinschen [Wed, 23 May 2001 15:49:22 +0000 (15:49 +0000)]
* syscalls.cc (seteuid): Restrict overriding external provided
user tokens to ntsec. Don't test external tokens for primary
group to evaluate if it should be overridden. Restrict creating
internal tokens to ntsec.
Alexandre Oliva [Sun, 20 May 2001 19:02:54 +0000 (19:02 +0000)]
* ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh, ltcf-cxx.sh,
ltcf-gcj.sh: Upgraded to libtool 1.4a 1.641.2.254. Rebuilt a number
of subdir/configure scripts to use the new libtool.m4.
Corinna Vinschen [Sun, 20 May 2001 08:10:47 +0000 (08:10 +0000)]
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
Corinna Vinschen [Wed, 16 May 2001 16:01:45 +0000 (16:01 +0000)]
* include/winnt.h: Add defines for group attributes.
Add define for SYSTEM_LUID.
Add missing types `PTOKEN_DEFAULT_DACL', `PTOKEN_OWNER' and
`PTOKEN_PRIMARY_GROUP'.
* autoload.h: Eliminate.
* autoload.cc: Pull in autoload.h. Eliminate many macros. Rewrite to avoid
necessity of initialization routines. Just use a standard one.
(wsock_init): New function. Moved from net.cc.
* net.cc (wsock_init): Move to autoload.cc.
(wsadata): Make global.
* dtable.cc (dtable::build_fhandler): Use more reliable method for checking if
net stuff has been loaded.
Corinna Vinschen [Tue, 15 May 2001 19:23:31 +0000 (19:23 +0000)]
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
Corinna Vinschen [Tue, 15 May 2001 08:15:54 +0000 (08:15 +0000)]
* autoload.cc: Add autoload statements for ws2_32 functions
`WSACloseEvent', `WSACreateEvent', `WSAGetOverlappedResult',
`WSARecv', `WSARecvFrom', `WSASend', `WSASendTo' and `WSASetEvent',
`WSAWaitForMultipleEvents'.
* net.cc: Define wsock_evt.
(wsock_event): New class.
(cygwin_sendto): Use overlapped socket io if available.
(cygwin_recvfrom): Ditto.
(cygwin_recv): Ditto.
(cygwin_send): Ditto.
* security.cc (subauth): Set Win32 error to 0 to safely ask for the
error code of dynamically loaded function `LsaRegisterLogonProcess'.