Commit Graph

225 Commits

Author SHA1 Message Date
simonb e7f8f72d9d Since we have an "extern.h", put all external variable declarations in
that file and not sprinkled around various .c files.
1999-12-03 02:26:36 +00:00
simonb 5801c247fa "ps -e" only shows the environment for the processes owned by the
current user id or all process if run by root.

Fixes PR security/5967 from Todd Vierling.
1999-12-03 02:16:41 +00:00
drochner 85cbf55d16 Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
1999-11-09 15:06:30 +00:00
jdolecek a5ae7c6ca4 command(): don't start using procfs_getargv() instead of kvm_getargv()
just because the latter returned a NULL - that may normally happen,
when the process is, for example, a kernel thread

procfs_getargv(): if the name is brackened in '(' and ')', just
	return NULL immediately - the code in command() will DTRT
	and the output will be same for procfs- and kvm- based lookup
	in all cases
1999-10-15 20:39:52 +00:00
jdolecek e52880e76a getkinfo_kvm(): fix bug in previous - handled size_t i as if it would be signed
saveuser(): don't check kd - if we get here, kd is never NULL
1999-10-15 20:01:33 +00:00
jdolecek f848d2ec0c When using the procfs for extracting process information, extract
also process start time, process arguments and session leadership status.

The procfs fallback is also used when kvm_openfiles() completely fails
(e.g. when /dev/mem is not readable).

Solves PR 7772, though the final implementation is different.
1999-10-15 19:31:24 +00:00
mrg fdea8ae38f skip "dty" just like we skip "tty", otherwise we just get "dt" in ps output for all dty's 1999-10-11 09:18:09 +00:00
chs 21eedb0ec1 the PMAP_NEW option is gone as the new interface is no longer optional. 1999-09-12 01:19:23 +00:00
veego 03fd106af5 According to the previous commit the new process state should be SDEAD and
not SDYING, so s/SDYING/SDEAD/.
1999-07-23 08:56:13 +00:00
thorpej 3586621927 Update for SDEAD. 1999-07-22 18:16:05 +00:00
thorpej 907831a0b3 KNF. 1999-05-09 19:23:38 +00:00
mrg c0999a71b0 oops, fix merge botch in previous.. 1999-05-03 00:20:07 +00:00
mrg d5c7180e2b limit session to 6 chars. from Geoff Wing <gcw@pobox.com> and fixes his PR#7506 1999-05-03 00:17:30 +00:00
christos f3d0eddcde Add support for printing wide sigset_t properly. 1999-04-16 13:34:32 +00:00
bgrayson 2721f671ab - Be really paranoid. Any time we open a file that is in /proc, run
fstatfs() on the open file to verify that no intruder has mounted
  something on portions of /proc.  This will catch, for instance,
  "mount_null /tmp /proc/1378".  We already do 5 syscalls per
  process, so one more won't hurt :) ...  and safety is better than
  performance when ps is otherwise broken.
- Also added a few close()'s at early returns, to avoid chewing up fd's.
1999-03-28 00:46:47 +00:00
bgrayson 05e0706ac9 Minor fixes:
1.  Use statfs() to verify that /proc is a procfs.
2.  Add -K option to disable /proc-based method.
3.  Make warnings less verbose, but still accurate.
1999-03-27 21:38:08 +00:00
tron 0ee6a66c30 Add missing prototype so that this actually compiles. 1999-03-27 15:22:17 +00:00
bgrayson be8534f744 Added experimental fallback /proc-based lookup. Warnings are printed when the
fallback method is used, as the results could be untrustworthy if an
intruder is present.  It is highly likely that NetBSD-1.5 will have
an improved kvm interface for reading process information, at which
point this code can be garbage-collected.  Also added a word to the
man page -x option description while I was here.
1999-03-26 22:36:02 +00:00
mrg d2397ac5f7 completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
1999-03-24 05:50:49 +00:00
garbled f124765044 More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages.  Many more to
come.
1999-03-22 18:25:43 +00:00
msaitoh 0a51b829fa ps's information is sorted by controlling terminal and (among processes with
the same controlling terminal) by PID.
1999-03-17 20:59:55 +00:00
mycroft f6590b22cd Clean up SYNOPSIS formatting. 1999-03-07 11:02:05 +00:00
mycroft 7a981b1dc5 Fix formatting errors. 1999-03-07 10:48:31 +00:00
kim 26cc4401e8 Fixed segfaulting for "ps -T". There is no optarg with -T, so instructions
under label "tty:" need to use ttname instead.
1999-01-04 16:37:28 +00:00
tron 29fe5bf18a The system namelist database is called "/var/db/kvm.db" not
"/var/db/kvm_netbsd.db". Fixes PR bin/6712 by Brian Grayson.
1999-01-02 16:11:43 +00:00
tv 8cfe18e8d3 Add CWARNFLAGS+=-Wno-format-y2k. 1998-08-25 15:13:16 +00:00
ross 17dbc471f0 Kill the CFLAGS+=-Wno-format-y2k which will go, for now, into bsd.sys.mk
It wasn't working anyway, although that could have been fixed by moving it
down below the .include <bsd.prog.mk> line.

It's not completely clear that this usage of %y is in fact y2k-safe, it
seems safer for now to have a single XXX option in bsd.sys.mk, and we need
to rev this anyway for -Wno-uninitialized
1998-08-25 07:43:20 +00:00
tv 19bef08688 This needs strftime()'s %y; use -Wno-format-y2k. 1998-08-21 19:39:41 +00:00
mycroft 975ed85295 Add a -U option to select by user/uid. 1998-07-28 18:54:02 +00:00
mycroft 37e6d2f31d Look for the formats used by setproctitle(3) and login shells, and avoiding
outputting the redundant `(comm)'.
1998-07-28 18:41:59 +00:00
mycroft ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mycroft 9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
mycroft 0e2f9ea923 __AUDIT__ cleanup. 1998-07-27 17:06:48 +00:00
mrg 80efe80bc9 - change setgid kmem programs (that lend themselves to this) so setegid(getgid())
and the top, and then set the effective gid back to kmem around the call to
  kvm_openfiles().  this reduces the time group kmem is available.
- for those above that also allow this, setgid(getgid()) after the call to
  kvm_openfiles() to fully revoke priviledges.
- some KNF
- use err(3) over fprintf(3) in some places
1998-07-06 07:50:18 +00:00
fair fe40034fae change references to vadvise to madvise; remove reference to lisp(1) 1998-04-28 17:59:10 +00:00
kleink 15fbf68ce9 Need <time.h> for localtime(), time() and strftime() prototypes. 1998-04-01 14:19:27 +00:00
is 07a1b88ab8 Use the physmem variable to get at the physical memory size (instead of the
avail_end - avail_start difference which is only correct on machines with
contiguous memory).
1998-03-27 22:45:47 +00:00
bouyer a394682ff6 Sync with reality: the uprocp keyword doesn't exist. 1998-03-24 18:34:12 +00:00
perry ba7b5f16ff add -DPMAP_NEW if PMAP_NEW is on in mk.conf 1998-02-18 03:54:58 +00:00
thorpej 047098bc5c Add a "sid" keyword to print the session ID. 1998-02-17 21:37:56 +00:00
mrg 279ce528ce add -DUVM to CPPFLAGS if defined(UVM) 1998-02-09 06:25:15 +00:00
mrg 79ddb78a38 remove old OLD BSD VM code. 1998-02-06 04:47:30 +00:00
gwr 54bd1bef90 Begone KERNBASE! (Just print kernel pointers as-is.) 1998-02-05 03:51:16 +00:00
perry 2850c7f9f7 add <sys/time.h> to fix compiler error 1998-02-03 03:16:01 +00:00
perry 0a9d9a55b9 RCS Id Police. 1998-01-09 07:00:57 +00:00
enami 3068d97149 Use .Nm "" instead of .Nm ps in SYNOPSIS. 1997-10-11 02:16:56 +00:00
lukem 76e13a0128 all but the first .Nm in SYNOPSIS need to be spelt out. [bin/4256] 1997-10-10 16:12:45 +00:00
lukem a234ba3ffe getopt returns -1 not EOF
cleanup manpage
1997-09-14 08:57:37 +00:00
mikel 2179735ae5 default swap device is /dev/drum, not nonexistent /dev/swap; from
<entropy@tardis.bernstein.com> in PR bin/4042
1997-08-27 05:43:20 +00:00
mikel 6e662001bc use %c not %C for lstart; from tetsuya@secom-sis.co.jp via OpenBSD 1997-08-03 01:57:04 +00:00
christos 23edbe3557 Remove WARNS=1 from all the subdirectory Makefiles, and add it to Makefile.inc
now that all /bin has been cleaned.
1997-07-20 22:36:20 +00:00
christos 78295c8bc1 Fix compiler warnings
Add WARNS=1
1997-07-20 20:37:53 +00:00
pk c7b6ec6b95 Refer to execve(2), add section to `vfork' ref. (almost per PR#3627). 1997-06-23 20:41:50 +00:00
mrg ecdc59670c note that strcpy is safe. 1997-04-21 05:28:43 +00:00
mycroft 7fb9269e92 DTRT if e_wmesg is not NUL-terminated. 1997-03-19 05:45:27 +00:00
mycroft 827a9bc80d DTRT if e_login is not NUL-terminated. 1997-03-19 05:34:47 +00:00
pk bf18a93a17 Message buffer passed to kvm_openfiles() should _POSIX2_LINE_MAX long; PR#3266 1997-02-28 13:34:50 +00:00
ws fddfc1d33f Fix p_nice vs. NZERO code.
Remove some unnecessary casts.
Remove an unused time format field.
1996-10-02 18:07:20 +00:00
thorpej 83e59fbba8 Fix SEGV when kludging old-style options.
From Greg Stark <gsstark@mit.edu>, PR #2550.
1996-09-27 02:59:53 +00:00
explorer b59a6a8b5f return 0.0 cpu usage for zombies. closes pr bin/2693. Perhaps this should
be fixed in exit, so p->p_pctcpu is cleared when the process exits.
1996-08-15 01:41:23 +00:00
explorer e0b43395ad include <pwd.h> for one function (user_from_uid) and correct one
%*d -> %*ld in a format string.  (yes, trying to find the problem with
ps wwwwwwwww1 and core dump, and might as well clean up while here)
1996-07-13 06:58:33 +00:00
cgd 7514e04296 in findvar(), return after warning about unknown keyword so we don't
deref. a null pointer.
1996-05-30 21:16:32 +00:00
jtc 5f1b7809e2 fix damage caused by sccs (long ago) 1996-03-21 01:36:28 +00:00
jtc 41e21e1634 LIBMATH -> LIBM (PR# 1688) 1995-10-26 00:48:59 +00:00
cgd db6548cd7b correct the sizes specified for various variables. 1995-09-29 21:58:59 +00:00
cgd 9b497abb6f add code to convert from INT32 and UINT32 to native types. 1995-09-29 21:58:12 +00:00
cgd ca9f3b6e66 add INT32 and UINT32 variable type specifiers. some of the variables
that are printed are of fixed size.
1995-09-29 21:57:03 +00:00
cgd 81a152541e Kenneth Stailey pointed out that his previous fix was incorrect. RE and SL
should be bounded at 127, not 99.
1995-08-15 14:00:59 +00:00
cgd 731f8de0fa as suggested in PR 1347, by Kenneth Stailey, make "RE" and "SL" fields
show up as two digits, max, displaying "99" if > 99.  allow any field with
an unsigned value to be specified as printing that way (though right now
it's only used for RE and SL, which are both unsigned longs).  This fix
is substantially different than that suggested in the PR.
1995-08-14 05:00:03 +00:00
cgd 8936958f57 typeof(timeval.ts_sec) != time_t 1995-06-07 16:29:30 +00:00
mycroft d91f14cba8 If there is another field after the command, fill in the command field with
blanks.
1995-05-25 04:13:17 +00:00
mycroft 02513843ae Simplify this just a little. 1995-05-25 03:14:37 +00:00
mycroft 8465d5c10c Split out some helper functions again. 1995-05-21 13:38:25 +00:00
mycroft 3541700d61 Create and strvis(3) the argument and environment lists only as needed.
Do not keep extra copies around.
1995-05-18 20:33:20 +00:00
mycroft 3cd42e791d Do the right thing for an empty environment. 1995-05-18 15:35:59 +00:00
mycroft 3a23f31a10 Avoid an extra (gratuitous) pass through strvis(3). 1995-05-18 15:27:31 +00:00
mycroft d70850c69c Gather the argument and environment lists when we actually want to print them. 1995-05-18 14:37:03 +00:00
cgd fe9be699b4 add a 'holdcnt' keyword and document it. 1995-05-08 23:11:31 +00:00
cgd 630b3b093b add the ability to understand and print INT and UINT-sized variables. 1995-05-08 22:39:24 +00:00
pk e9b36a55e7 Sync process flags with sys/proc.h 1995-05-07 12:51:25 +00:00
cgd 49f0ad8601 convert to new RCS id conventions. 1995-03-21 09:01:59 +00:00
mycroft ddc6e993fc Better fix for the previous. 1995-01-08 07:01:36 +00:00
mycroft 3f1b5c3296 Fix oversight in previous change, when argument list is sort of empty. 1995-01-08 06:42:42 +00:00
cgd 6abb26e555 be careful with addresses. 1994-12-23 13:19:41 +00:00
cgd 5dad143982 from James Jegers <jimj@miller.cs.uwm.edu>: quiet -Wall, and squelch
some of the worst style errors.
1994-12-04 07:11:37 +00:00
mycroft a99fc6c377 Format police. 1994-11-25 08:05:55 +00:00
deraadt a583ccb069 print %MEM correctly 1994-11-25 07:01:11 +00:00
deraadt 8f25fc60d3 kill UPAGES 1994-11-03 04:33:17 +00:00
mycroft 07cdfa9cd1 Integrate `-c' option, from Arne Juul. 1994-09-16 22:23:29 +00:00
deraadt 5e6898c083 NBPG -> getpagesize() 1994-09-15 02:00:34 +00:00
jtc 1d1682d63c vmunix -> netbsd (PR #375) 1994-08-06 06:11:03 +00:00
deraadt 1a69335ad4 do not need -I/sys 1994-08-03 20:46:47 +00:00
mycroft afb839bea0 Clean up deleted files. 1994-07-03 07:26:03 +00:00
deraadt 8b8caa9aa0 devname is in libc now 1994-07-03 07:25:57 +00:00
pk e42d6feaa0 No more P_NOSWAP/P_PHYSIO. 1994-06-16 19:30:50 +00:00
pk f7e4697f3d Declare devname(). 1994-06-16 19:29:45 +00:00
cgd ad129cd0c4 kill extra space, save my sanity 1994-05-18 10:05:17 +00:00
pk 8fbf67e44a Restore "${DESTDIR}" in CFLAGS. 1994-05-17 08:58:29 +00:00
mycroft 8912a2daad Need devname.c. 1994-05-12 12:13:51 +00:00
cgd 4d1457ce4e clean up import 1994-05-09 03:31:07 +00:00
cgd b15d84bab0 new ps, to match libkvm 1994-05-09 03:29:37 +00:00
cgd 78be099528 struct element foo 1994-05-05 06:44:24 +00:00
cgd 25718695be update for changed flags 1994-05-05 02:04:10 +00:00
cgd 90ef506be5 needs -lkvm, not -lutil 1994-01-28 00:23:41 +00:00
jtc e04c8e0705 Fix spelling errors. 1994-01-11 02:10:48 +00:00
cgd cd68b34ae6 fix from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de>:
don't try to display the resident text size; we can't do that anymore
1993-10-07 00:45:59 +00:00
mycroft 28f8a1de75 Fix library dependencies. 1993-08-14 13:02:21 +00:00
mycroft d52b7872b8 Fix test for zombie process. 1993-08-14 12:30:04 +00:00
mycroft 8542364e07 Add RCS identifiers. 1993-08-01 18:49:50 +00:00
mycroft b1bd4afedc Add RCS indentifiers. 1993-08-01 07:42:49 +00:00
mycroft cda4f8f6ee Add RCS identifiers. 1993-08-01 05:37:30 +00:00
cgd 40194b0e50 from Brian Somers <brian@awfulhak.demon.co.uk>:
The kvm entry isn't updated for command unless 'time' is given,
therefore
	ps -o command
outputs blank lines [or, in NetBSD, seg faults]
	ps -o time,command
works.
1993-07-19 11:02:10 +00:00
cgd 4434a6ed53 fix alien 'w' handling. you really don't want to know... 1993-07-11 17:34:29 +00:00
cgd ffc8450394 use strvis on the arguments and environment, so we don't end up in
sed and/or xterm-title-changing hell.
1993-06-18 09:32:27 +00:00
mycroft d3bc70b6bb Don't need -I/sys. (Why was it here?) 1993-06-17 13:16:20 +00:00
mycroft 77f1922b02 Fix up FILES sections. 1993-06-13 23:06:41 +00:00
mycroft 9b971264a9 Update file names. 1993-06-13 22:29:02 +00:00
cgd a27ee16690 make ps do something more sensible with zombie processes 1993-06-02 22:02:27 +00:00
cgd 35644dc153 fix more-or-less-uninitialized variable... 1993-06-01 02:33:35 +00:00
cgd 6ed1026d12 add support and documentation for the 'e' option, to print out
the process environment.
1993-06-01 01:38:28 +00:00
proven 01d55229cc Changed hash_open to dbopen. 1993-04-21 08:14:39 +00:00
cgd 06be60083d changed "Id" to "Header" for rcsids 1993-03-23 00:22:59 +00:00
cgd 346aa5dd48 added rcs ids to all files 1993-03-22 08:04:00 +00:00
cgd e541169ce2 after 0.2.2 "stable" patches applied 1993-03-21 18:04:42 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00