Commit Graph

810 Commits

Author SHA1 Message Date
Brian Inglis 23bb2f6608 get and convert boot time once and use as needed 2019-03-25 11:26:17 +01:00
Brian Inglis ee1ad64234 default ps -W process start time to system boot time when inaccessible, 0, -1 2019-03-25 11:26:17 +01:00
Corinna Vinschen ae3370bb9d Cygwin: strace: print windows and cygwin pid in event output
strace only printed the Windows PID in event output so far.

Especially now that Windows and Cygwin PID are decoupled, the
strace user might like to see the Cygwin pid in event output as
well.  However, at process startup, the process might not have
a Cygwin PID yet.

To mitigate this, always print the Windows PID and only add the
Cygwin pid if it exists.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-23 17:50:00 +01:00
Corinna Vinschen 1def2148d2 Cygwin: ps: simplify code
Always use NtQuerySystemInformation(SystemProcessIdInformation).
This drops two code paths calling NtQueryInformationProcess or
GetModuleFileNameExW and only requires to open the process
to fetch system time info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 21:21:13 +01:00
Corinna Vinschen 37a046181e Cygwin: ps: show *all* processes in ps -W output
There's a long-standing bug in ps -W.  It only shows processes which ps
can open with PROCESS_QUERY_LIMITED_INFORMATION permissions.  However,
that fails for a lot of system processes. Due to that, output is
basically restricted to processes in the same session, as well as Cygwin
processes... which isn't *quite* what ps -W was supposed to do.

Basically we only need to open the process to fetch the image name.  If
that fails, utilize the undocumented SystemProcessIdInformation info
class introduced with Windows Vista, which allows to fetch the image
name by specifying the PID.  Restructure the code a bit.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 20:55:29 +01:00
Corinna Vinschen 26e0b37ed0 Cygwin: utils: MOUNT_BINARY -> MOUNT_TEXT
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 11:02:03 +01:00
Corinna Vinschen 5e6ce1cfb2 Cygwin: utils: kill: revert erroneously removed optind correction
When recognizing a negative pid, optind is off by one.  The
code correcting this has been erroneously removed by commit
8de660271f.  Revert that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 10:22:37 +01:00
Corinna Vinschen 49ea15ef17 Cygwin: fix typo
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-02 21:15:50 +01:00
Corinna Vinschen 658f939003 Cygwin: kill(1): introduce a -W option
Allow to kill processes using Windows PIDs on the command line.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-02 21:02:00 +01:00
Corinna Vinschen f5c2d4db5b Cygwin: kill(1): revert casts required for 32 bit to avoid spurious warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-02 15:32:28 +01:00
Corinna Vinschen 8de660271f Cygwin: kill(1): disallow killing process using raw Windows PID
This may end up killing the wrong process.  Only allow Cygwin PID.

Slightly clean up code: Remove outdated W95 considerations.  Fix
a bug in commandline argument processing.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-02 15:00:39 +01:00
Corinna Vinschen c1023ee353 Cygwin: path_conv: decouple path_types from mount types
- Remove another unfortunate amalgamation: Mount flags (MOUNT_xxx)
  are converted to path_types (PATH_xxx) and mixed with non-mount
  path_types flags in the same storage, leading to a tangled,
  pell-mell usage of mount flags and path flags in path_conv and
  symlink_info.

- There's also the case of PC_NONULLEMPTY.  It's used in exactly
  one place with a path_conv constructor only used in this single
  place, just to override the automatic PC_NULLEMPTY addition
  when calling the other path_conv constructors.  Crazily,
  PC_NONULLEMPTY is a define, no path_types flag, despite its
  name.

- It doesn't help that the binary flag exists as mount and path
  flag, while the text flag only exists as path flag.  This leads
  to mount code using path flags to set text/binary.  Very confusing
  is the fact that a text mount/path flag is not actually required;
  the mount code sets the text flag on non binary mounts anyway, so
  there are only two states.  However, to puzzle people a bit more,
  path_conv::binary wrongly implies there's a third, non-binary/non-text
  state.

Clean up this mess:

- Store path flags separately from mount flags in path_conv and
  symlink_info classes and change all checks and testing inline
  methods accordingly.

- Make PC_NONULLEMPTY a simple path_types flag and drop the
  redundant path_check constructor.

- Clean up the definition of pathconv_arg, path_types, and mount flags.
  Use _BIT expression, newly define in cygwin/bits.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-06 20:30:14 +01:00
Corinna Vinschen 0d4b39d37b Cygwin: Add lsattr and chattr tools
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-12-26 09:24:33 +01:00
Ken Brown ed4d919c24 setfacl: Rename the option --file to --set-file, as on Linux
Retain --file as an undocumented option for backwards compatibility.
2018-08-17 11:35:24 +02:00
Corinna Vinschen 423fc83dfd Cygwin: utils: ps: use fputs to print fixed strings
Avoid gcc warning "format not a string literal and no format arguments"

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-09 08:41:18 +02:00
Corinna Vinschen 8bfb1afd6b Cygwin: utils: strace: fix format string
%ll is long valid for mingw builds.  Use this rather than %I64
to avoid a gcc warning

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08 10:50:19 +02:00
Corinna Vinschen 37f4fea07c Cygwin: utils: change 3rd readlink param to size_t
Avoid gcc warnings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08 10:50:19 +02:00
Corinna Vinschen 13909bc262 Cygwin: utils: cygcheck: fix filesystem output format
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08 10:50:13 +02:00
Mark Geisert 7f32efbf73 POSIX Asynchronous I/O support: other files
Updates to misc files to integrate AIO into the Cygwin source tree.
Much of it has to be done when adding any new syscalls.  There are
some updates to limits.h for AIO-specific limits.  And some doc mods.
2018-07-25 09:36:24 +02:00
Ken Brown 982dd20ed9 getfacl: Simplify by using acl_to_any_text 2018-07-25 09:32:36 +02:00
Ken Brown b610a9cf29 getfacl and setfacl: Align with Linux
Make getfacl print two colons instead of one after "other" and "mask".
Change the help text for setfacl to indicate that there can be either
one colon or two.
2018-07-23 17:31:09 +02:00
Corinna Vinschen 6497fdfaf4 Cygwin: fix bumptious GCC 7 warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-26 17:20:48 +02:00
Corinna Vinschen 26bcedda20 Cygwin: fix utils path handling in case cygdrive path is just '/'
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:21:48 +01:00
Yaakov Selkowitz e5d52a2db9 cygwin: add gencat tool
This is needed for compiling catalog files used in catgets(3) calls.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-19 13:19:21 -06:00
Yaakov Selkowitz 2cb24159fb cygwin: add LFS_CFLAGS etc. to confstr/getconf
These are used, for instance, when cross-compiling the Linux kernel.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-16 12:12:45 -06:00
Yaakov Selkowitz c37171b528 cygwin: fix getconf after commit 032aa2dba5
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 11:36:14 -06:00
Ken Brown 3e8323dc06 winsup/utils/dump_setup.cc: Remove the function 'base'
This was called only on filenames in /etc/setup/installed.db, which
are all basenames anyway.  Moreover, base wasn't correctly handling
filenames containing colons.
2017-10-25 17:02:26 +02:00
Fujii Hironori 4d336756fa cygwin: regtool: encode error messages correctly
Error messages of regtool can't be read, which are encoded in,
for instance, SHIFT_JIS in Japanese Windows.  Fix by using
wide chars instead of multibyte.
2017-06-20 13:17:49 +02:00
Daniel Santos b43e28aef0 strace: Fix "over-optimization" flaw in strace.
Recent versions of gcc are optimizing away the TLS buffer allocated in
main, so we need to tell gcc that it's really used.  RtlSecureZeroMemory
accomplishes this while also inlining the memset.

Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
2017-04-19 20:17:04 +02:00
Jon Turney a9da3e4e67 Make ldd stop after any non-continuable exception
Ensure that ldd always stops when the exception is flagged as
non-continuable.

Also arrange for ldd to exit with a non-zero exit code if something went
wrong which prevented us from listing all dynamic dependencies.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-04-04 18:47:44 +01:00
Corinna Vinschen f5ecacfc6c Generate output with Unix line endings even from Mingw64 utils
This affects cygcheck and strace.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-24 20:55:14 +01:00
Jon Turney a15297381d Fix handling of '+' by 'cygcheck -p'
The form data sent to the server should be application/x-www-form-urlencoded

This replaces spaces with '+' before being RFC 1738 encoded, so a literal
'+' must be %-encoded also.

See https://cygwin.com/ml/cygwin/2014-01/msg00287.html et seq.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-01-31 19:55:38 +00:00
Corinna Vinschen 584c6643fe cygutils: Fix resource leak in get_short_paths
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 16:04:42 +01:00
Corinna Vinschen 9b01c29c04 Fix typo in kill(1)
buf is just a local buffer, sig is ultimately pointing to the
signal string.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 16:00:28 +01:00
Corinna Vinschen bb7ad4ed64 pldd: Fix resource leak and missing check if fopen failed
Fixes Coverity CID 66903

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:22:34 +02:00
Corinna Vinschen 79edb254ac passwd: Fix potential buffer overflow
Fixes Coverity CID 66956

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:16:30 +02:00
Corinna Vinschen 526107a753 mkgroup/mkpasswd: Fix potential buffer overwrite in corner case
Fixes Coverity CIDs 60076, 60077 and 60081

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:04:55 +02:00
Corinna Vinschen 7d5af6f0ba getfacl: Don't trust length of incoming user/groupname
Fixes Coverity CIDs 60079 and 60080

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:52:28 +02:00
Corinna Vinschen cf01b8f029 tzset: Fix array length given to GetGeoInfoW
Fixes Coverity CID 66916

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:45:21 +02:00
Corinna Vinschen 5e087a8373 strace: Fix Coverity issues
CID 66964: Don't trust environment variable without length check
CID 66968: Add missing va_end

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:38:48 +02:00
Corinna Vinschen 9807a501b1 cygcheck: Use snprintf instead of multiple strcat
This not only simplifies the code but also fixes potential
memory corruption

Fixes Coverity CID 66952

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:16:22 +02:00
Corinna Vinschen f16f20ff95 cygcheck: Eenable output of Vista++ FS flags
Also, code cleanup

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 15:57:40 +02:00
Corinna Vinschen 015f6894a0 cygcheck: Eliminate dead code
Fixes Coverity CID 66907

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:57:03 +02:00
Corinna Vinschen bbeef8ef3f cygcheck: Fix broken test for invalid wcstombs conversion reading symlinks
Fixes Coverity CID 66905

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:53:29 +02:00
Corinna Vinschen 7909b528e5 cygcheck: Fix check for Cygwin symlink
Fixes Coverity CID 66904 and 66906

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:50:33 +02:00
Corinna Vinschen 61401f24ef strace: Add comment trying to explain confusing code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:39:31 +02:00
Corinna Vinschen 46c472a1c1 cygcheck: Close with pclose what has been opened with popen
Fixes Coverity CID 66900

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:14:34 +02:00
Corinna Vinschen db8bda4b47 Remove unreachable code from passwd(1)
Fixed Coverity CID 66966

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 21:20:28 +02:00
Ken Brown dda82d1a7b Add _PC_CASE_INSENSITIVE to [f]pathconf
Update the getconf utility to support the new flag as well as
_PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY.  These were previously
unsupported, probably as an oversight.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-21 13:39:02 +02:00
Corinna Vinschen a157df3165 strace: Don't print exception info for SetThreadName exception
The new functionality to set the thread name for debugging purposes
creates exception debugging events.  These are printed out when running
strace.  Since these exceptions have nothing to do with real exceptions
but are, like breakpoint execptions, expected and non-fatal, don't print
exception info for them.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-31 12:15:29 +02:00