Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion Lsof.8
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ components from the kernel's name cache.
See the
.B "KERNEL NAME CACHE"
section for more information.
.IP
The Solaris procfs backend does not have a kernel DNLC and does not
support this option.
.TP \w'names'u+4
.BI +d " s"
causes
Expand Down Expand Up @@ -1205,6 +1208,9 @@ specifies a kernel name list file,
in place of /vmunix, /mach, etc.
.B \-k
is not available under AIX on the IBM RISC/System 6000.
.IP
The Solaris procfs backend does not read kernel memory or kernel name
lists and does not support this option.
.TP \w'names'u+4
.B \-l
inhibits the conversion of user ID numbers to login names.
Expand Down Expand Up @@ -1250,6 +1256,9 @@ or
.I /dev/mem
\&\- e.g., a crash dump file.
.IP
The Solaris procfs backend does not use kernel memory and does not support
the kernel memory form of this option.
.IP
The option form
.B +m
requests that a mount supplement file be written to the standard output
Expand Down Expand Up @@ -2027,6 +2036,9 @@ to display isn't associated with open TCP, UDP or UDPLITE socket files.
.HP \w'names'u+4
\ \ \ \ Solaris 10 and above:
.br
The Solaris procfs backend does not support this option. The following
description applies to the legacy kernel backend.
.IP
This Solaris 10 and above option requests the reporting of cached
paths for files that have been deleted \- i.e., removed with
.IR rm (1)
Expand Down Expand Up @@ -2239,9 +2251,10 @@ versions):
AIX 4.1.4 (AFS 3.4a)
HP\-UX 9.0.5 (AFS 3.4a)
Linux 1.2.13 (AFS 3.3)
Solaris 2.[56] (AFS 3.4a)
.fi
.PP
The Solaris procfs backend does not support AFS recognition.
.PP
It may recognize AFS files on other versions of these dialects,
but has not been tested there.
Depending on how AFS is implemented,
Expand Down Expand Up @@ -2288,6 +2301,65 @@ Because AFS path lookups don't seem to participate in the
kernel's name cache operations,
.I lsof
can't identify path name components for AFS files.
.SH "SOLARIS PROCFS BACKEND"
The Solaris dialect uses the procfs interface on Solaris 11 and illumos.
It does not read kernel memory, and therefore does not require
.BR /dev/kmem ,
.BR libkvm ,
.BR libctf ,
or
.BR libelf .
.PP
Process information is read from
.IR /proc/<pid>/psinfo ,
.IR /proc/<pid>/fd ,
.IR /proc/<pid>/fdinfo ,
and
.IR /proc/<pid>/path .
Zones are reported through
.I psinfo_t.pr_zoneid
and the
.B \-z
option.
.PP
TCP and UDP state, TCP queue and window values, and MSS are obtained
from the userland MIB2 interface on
.IR /dev/arp .
If that interface is unavailable, socket state is reported as unknown.
Socket options are taken from the subset exposed by
.IR /proc/<pid>/fdinfo .
.PP
The following legacy kernel features are not supported by this backend:
.PP
.RS 4
.IP \(bu 2
AFS
.IP \(bu 2
VxFS-specific inode and path information
.IP \(bu 2
streams module and queue information
.IP \(bu 2
kernel DNLC and the
.B \-C
option
.IP \(bu 2
kernel name list/memory options
.B \-k
and
.B \-m
.IP \(bu 2
the Solaris deleted-path
.B \-X
option
.IP \(bu 2
kernel file/vnode addresses and the corresponding field output
.RE
.PP
Ordinary VxFS files remain visible through procfs path and
.BR stat (2)
information.
NFS files are also handled through procfs; testing them requires an
actual NFS mount.
.SH SECURITY
.I Lsof
has three features that may cause security concerns.
Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ LIBLSOF_SOURCES += lib/dialects/sun/ddev.c \
lib/dialects/sun/dstore.c \
lib/dialects/sun/dlsof.h \
lib/dialects/sun/dproto.h \
lib/dialects/sun/dsock.h \
lib/dialects/sun/machine.h
endif

Expand Down Expand Up @@ -142,7 +143,8 @@ DIALECT_NEUTRAL_TESTS = tests/case-00-hello.bash \
tests/case-23-multi-address-hostname.bash \
tests/case-24-dual-stack-socket.bash \
tests/case-30-json-output.bash \
tests/case-31-jsonl-output.bash
tests/case-31-jsonl-output.bash \
tests/case-32-solaris-zone.bash
TESTS = $(DIALECT_NEUTRAL_TESTS)

EXTRA_DIST += $(DIALECT_NEUTRAL_TESTS) \
Expand Down
50 changes: 2 additions & 48 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ AS_CASE([${host_os}],
CFLAGS="$CFLAGS -Dsolaris=$LSOF_VERS"

# Link system libraries
LIBS="$LIBS -lelf -lsocket -lnsl"
LIBS="$LIBS -lsocket -lnsl"

# Handle missing header
mkdir -p ./solaris11/sys
Expand Down Expand Up @@ -362,7 +362,7 @@ AC_CHECK_DECLS([doadump], [], [], [[#define _KERNEL 1

# Detect struct vnode definition for HAS_KVM_VNODE
# Linking libkvm is not required in AIX
AS_IF([test x$LSOF_DIALECT_DIR != xaix], [
AS_IF([test x$LSOF_DIALECT_DIR != xaix && test x$LSOF_DIALECT_DIR != xsun], [
AC_EGREP_CPP([struct vnode], [#define _KVM_VNODE 1
#include <sys/vnode.h>], [AC_DEFINE([HAVE_KVM_VNODE], [1], ["Define to 1 if struct vnode exists"])
LIBS="$LIBS -lkvm"])
Expand Down Expand Up @@ -524,52 +524,6 @@ AS_IF([test "x$ac_cv_sizeof_dev_t" = x8], [
LSOF_TEST_CFLAGS="$LSOF_TEST_CFLAGS -DLT_DEV64"
])

# Detect inet/ipclassifier.h header for HAS_IPCLASSIFIER_H
AC_CHECK_HEADERS([inet/ipclassifier.h], [], [], [#define _KERNEL
#include <inet/ip.h>])

# Detect struct conn_s.conn_ixa header for HAS_CONN_NEW
AC_CHECK_MEMBERS([struct conn_s.conn_ixa], [], [], [#define _KERNEL
#include <inet/ip.h>
#include <inet/ipclassifier.h>])

# Detect sys/zone.h header for HASZONES
AC_CHECK_HEADERS([sys/zone.h])

# Detect pad_mutex_t for HAS_PAD_MUTEX
AC_CHECK_TYPES([pad_mutex_t], [], [], [#define _KERNEL
#include <sys/mutex.h>])

# Detect libctf.h header for HAS_LIBCTF
AC_CHECK_HEADERS([libctf.h], [LIBS="$LIBS -lctf"])

# Detect pc_direntpersec macro for HAS_PC_DIRENTPERSEC
AC_CHECK_DECLS([pc_direntpersec((struct pcfs *)NULL)], [], [], [#include <sys/fs/pc_fs.h>])

# Detect sys/fs/zfs.h header for HAS_ZFS
AC_CHECK_HEADERS([sys/fs/zfs.h])

# Detect sys/cred_impl.h header for HAS_CRED_IMPL_H
AC_CHECK_HEADERS([sys/cred_impl.h])

# Detect struct vnode.v_path for HAS_V_PATH
AC_CHECK_MEMBERS([struct vnode.v_path], [
LSOF_TEST_CFLAGS="$LSOF_TEST_CFLAGS -DLT_VPATH"
], [], [#include <sys/vnode.h>])

# Detect VSOCK for HAS_VSOCK
AC_CHECK_DECLS([VSOCK], [], [], [#include <sys/vnode.h>])

# Detect struct aio_req for HAS_AIO_REQ_STRUCT
AC_CHECK_TYPES([struct aio_req], [], [], [#define _KERNEL
#include <sys/aio_req.h>])

# Detect sys/rgm.h header for HAS_SYS_RGM_H
AC_CHECK_HEADERS([sys/rgm.h])

# Detect rpc/rpc_tags.h header for HAS_RPC_RPC_TAGS_H
AC_CHECK_HEADERS([rpc/rpc_tags.h])

# Generate Makefile from Makefile.in/am
AC_CONFIG_FILES([Makefile])

Expand Down
8 changes: 2 additions & 6 deletions lib/dialects/sun/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ CFLAGS= ${CDEFS} ${INCL} ${DEBUG}

HDR= lsof.h lsof_fields.h dlsof.h machine.h proto.h dproto.h

SRC= ddev.c dfile.c dmnt.c dnode.c dnode1.c dnode2.c dproc.c dsock.c \
SRC= ddev.c dfile.c dmnt.c dnode.c dproc.c dsock.c \
dstore.c dprint.c \
arg.c main.c misc.c node.c print.c proc.c store.c usage.c util.c

OBJ= ddev.o dfile.o dmnt.o dnode.o dnode1.o dnode2.o dproc.o dsock.o \
OBJ= ddev.o dfile.o dmnt.o dnode.o dproc.o dsock.o \
dstore.o dprint.o \
arg.o main.o misc.o node.o print.o proc.o store.o usage.o util.o

Expand Down Expand Up @@ -128,10 +128,6 @@ dmnt.o: ${HDR} dmnt.c

dnode.o: ${HDR} dnode.c

dnode1.o: ${HDR} dnode1.c

dnode2.o: ${HDR} dnode2.c

dproc.o: ${HDR} kernelbase.h dproc.c

dsock.o: ${HDR} dsock.c
Expand Down
2 changes: 1 addition & 1 deletion lib/dialects/sun/Mksrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mksrc() {
}

D=lib/dialects/sun
L="ddev.c dfile.c dlsof.h dmnt.c dnode.c dnode1.c dnode2.c dproc.c dproto.h dsock.c dstore.c machine.h"
L="ddev.c dfile.c dlsof.h dmnt.c dnode.c dproc.c dproto.h dsock.c dsock.h dstore.c machine.h"

mksrc

Expand Down
12 changes: 0 additions & 12 deletions lib/dialects/sun/ddev.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,7 @@ void read_clone(struct lsof_context *ctx) {
Error(ctx);
}

#if defined(USE_STAT)
if (stat(fp, &sb) != 0)
#else /* !defined(USE_STAT) */
if (lstat(fp, &sb) != 0)
#endif /* defined(USE_STAT) */

{
if (!Fwarn) {
Expand Down Expand Up @@ -482,11 +478,7 @@ void readdev(struct lsof_context *ctx, /* context */
Error(ctx);
}

#if defined(USE_STAT)
if (stat(fp, &sb) != 0)
#else /* !defined(USE_STAT) */
if (lstat(fp, &sb) != 0)
#endif /* defined(USE_STAT) */

{
if (errno == ENOENT) /* symbolic link to nowhere? */
Expand Down Expand Up @@ -998,11 +990,7 @@ int vfy_dev(struct lsof_context *ctx, /* context */
if (!DCunsafe || dp->v)
return (1);

# if defined(USE_STAT)
if (stat(dp->name, &sb) != 0
# else /* !defined(USE_STAT) */
if (lstat(dp->name, &sb) != 0
# endif /* defined(USE_STAT) */

|| dp->rdev != sb.st_rdev || dp->inode != (INODETYPE)sb.st_ino) {
(void)rereaddev(ctx);
Expand Down
Loading
Loading