commit 97b43f8b5b7feb86c19d5b386a73423349ac9e67 Author: zyppe <210hcl@gmail.com> Date: Thu Feb 29 16:13:57 2024 +0800 Initialize for lsof diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa31268 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lsof_4.91_src_repacked.tar.xz diff --git a/.lsof.metadata b/.lsof.metadata new file mode 100644 index 0000000..72af877 --- /dev/null +++ b/.lsof.metadata @@ -0,0 +1 @@ +e0a6a31aeea0de61af563c47b7d327df5696c41676b2eaa159e952188023b382 lsof_4.91_src_repacked.tar.xz diff --git a/lsof-no-build-date-etc.patch b/lsof-no-build-date-etc.patch new file mode 100644 index 0000000..f6465c4 --- /dev/null +++ b/lsof-no-build-date-etc.patch @@ -0,0 +1,52 @@ +Index: usage.c +=================================================================== +--- usage.c.orig 2010-07-29 11:59:45.000000000 -0400 ++++ usage.c 2010-08-29 14:39:17.366314422 -0400 +@@ -890,47 +890,6 @@ usage(xv, fh, version) + LSOF_URL); + (void) fprintf(stderr, " latest man page: %slsof_man\n", + LSOF_URL); +- +-#if defined(LSOF_CINFO) +- if ((cp = isnullstr(LSOF_CINFO))) +- (void) fprintf(stderr, " configuration info: %s\n", cp); +-#endif /* defined(LSOF_CINFO) */ +- +- if ((cp = isnullstr(LSOF_CCDATE))) +- (void) fprintf(stderr, " constructed: %s\n", cp); +- cp = isnullstr(LSOF_HOST); +- if (!(cp1 = isnullstr(LSOF_LOGNAME))) +- cp1 = isnullstr(LSOF_USER); +- if (cp || cp1) { +- if (cp && cp1) +- cp2 = "by and on"; +- else if (cp) +- cp2 = "on"; +- else +- cp2 = "by"; +- (void) fprintf(stderr, " constructed %s: %s%s%s\n", +- cp2, +- cp1 ? cp1 : "", +- (cp && cp1) ? "@" : "", +- cp ? cp : "" +- ); +- } +- +-#if defined(LSOF_BLDCMT) +- if ((cp = isnullstr(LSOF_BLDCMT))) +- (void) fprintf(stderr, " builder's comment: %s\n", cp); +-#endif /* defined(LSOF_BLDCMT) */ +- +- if ((cp = isnullstr(LSOF_CC))) +- (void) fprintf(stderr, " compiler: %s\n", cp); +- if ((cp = isnullstr(LSOF_CCV))) +- (void) fprintf(stderr, " compiler version: %s\n", cp); +- if ((cp = isnullstr(LSOF_CCFLAGS))) +- (void) fprintf(stderr, " compiler flags: %s\n", cp); +- if ((cp = isnullstr(LSOF_LDFLAGS))) +- (void) fprintf(stderr, " loader flags: %s\n", cp); +- if ((cp = isnullstr(LSOF_SYSINFO))) +- (void) fprintf(stderr, " system info: %s\n", cp); + (void) report_SECURITY(" ", ".\n"); + (void) report_WARNDEVACCESS(" ", "are", ".\n"); + (void) report_HASKERNIDCK(" K", "is"); diff --git a/lsof.changes b/lsof.changes new file mode 100644 index 0000000..b662a08 --- /dev/null +++ b/lsof.changes @@ -0,0 +1,340 @@ +* Tue Mar 27 2018 kstreitova@suse.com +- Update to version 4.91 + * This revision applies two fixes that correct the Linux PTY + endpoint processing bug [bsc#1082900] +* Mon Feb 19 2018 kstreitova@suse.com +- Update to version 4.90 [bsc#1081562] + * Taught the Configure script to create a dummy opt_random.h + for FreeBSD systems whose includes it. + * Added support for the FreeBSD ZFUSE file system. + * Corrected the quoting in a Darwin putchar() statement in the + dfile.c source file. + * Added support for the FreeBSD DTYPE_PTS file descriptor and + for unknown descriptors that reference the kernel's badfileops + operation switch. Enabled FreeBSD 12.0 support. + * Enhanced -K option with the form "-K i" to direct lsof to + (i)gnore tasks. Linux task reports now include both + process and task command names, making lsof's "-c " + option work correctly. + * Added a patch to prevent NFS blocking in Linux + * Installed a FreeBSD patch that prevents examining a TCP state + structure during a race condition. + * Updated FreeBSD for new UFS inode structure that lacks an i_dev + member in the most recent 12.0-CURRENT. + * Added "#define KLD_MODULE" to dlsof.h and dnode2.c to prevent + from generating an "ARM_NARCH is 0" error. + This is needed so lsof can access kernel structures. + * Added recognition of the FreeBSD 11 file system name "nullfs". + * Added a patch that is needed on FreeBSD 12 so the lsof + compilation can obtain the inpcb and tcpcb structures from + their respective header files. Updated FreeBSD dmnt.c for the + ino64 changes. + * Inserted a patch for Solaris 12.x to avoid compilation errors + from . + * Added performance enhancement that uses the FreeBSD closefrom() + and dup2() C library functions when available. + * Corrected FreeBSD lsof's gathering of ZFS file device numbers. + * Updated lsof test library for FreeBSD. + * Updated socket optons information collection from the socket + structure + * Added patch to dlsof.h that avoids a _KERNEL conflict with + bzero. + * Corrected test library to handle 64 bit FreeBSD device numbers. + * Added #defines for FreeBSD 12, src r324225 + * Incorporated Linux pseudoterminal endpoint processing (+|-E) + * Corrected Linux command extraction for commands that include + parentheses -- e.g., "(sd-pam)". +- remove lsof_4.89-nfs_hanging.patch that was applied upstream +* Mon Aug 29 2016 kstreitova@suse.com +- modify lsof_4.89-nfs_hanging.patch and add a check for HasNFS + variable as HasNFS may already have been set to 2 in the + readmnt() function [bsc#995061] +* Fri Aug 26 2016 kstreitova@suse.com +- add lsof_4.89-nfs_hanging.patch to prevent 'lsof -b' from hanging + when NFS server is unavailable [bsc#995061] +* Thu May 5 2016 kstreitova@suse.com +- submit utilities/lsof package to SUSE:SLE-12-SP2:GA [fate#320541] +* Mon May 2 2016 kstreitova@suse.com +- Update to version 4.89 + * Applied correction from Casper Dik to + his patch for Solaris 11 that I applied incorrectly in revision + 4.88. + * Updated for latest version of FreeBSD 11.0-CURRENT. + * Compensated for a missing FreeBSD 10.0 typedef of bool on the + i386 architecture. Allen Hewes provided + a test system. Andrey Chernov provided + useful advice. + * Improved tests/Add2TestDB script with a patch from Peter + Schiffer . Added patches from Peter to + eliminate Linux gcc warnings. Updated Lsof.8 with improvements + supplied by Bjarni Ingi Gislason . + * Changed FreeBSD global CFLAGS extraction per Terry Kennedy + . Also made sure -DNEEDS_BOOL_TYPEDEF is + [#]define'd when the resulting CFLAGS doesn't contain it. Terry + reported that need. + * Improved Linux test for tcp.h in response to a report from + Cato Auestad . Cato did the testing. + * Fixed Linux UNIX socket search by name bug reported by + Stephane Chazelas . + * Added Linux display of UNIX socket endpoint information with + code provided by Masatake YAMATO . Peter + Schiffer provided a test system. + * Insured that type definitions from were again made + visible to lsof on FreeBSD 11 after a system header file change + hid them. +- use spec-cleaner to clean specfile +* Sun Mar 1 2015 p.drouand@gmail.com +- Update to version 4.88 + * Reduced to 50 the number of open file descriptors lsof attempts + to close while trying to protect itself from a file descriptor + exec() attack. This limits the overhead lsof incurs on systems + that have large file descriptor limits, yet provides sufficient + open descriptors for the library functions lsof calls. + * Updated for changes in FreeBSD 10. Taught Configure to recognize + FreeBSD 8.4. + * lsof for Solaris 10 or 11 is no longer supported. + * Initialized local variables in the Linux process_id() function. + * Added support for FreeBSD 11. + * Updated FreeBSD ZFS Configure stanza to supply a dummy opt_kdtrace.h + when needed. + * Added tmpfs file system support for FreeBSD. + * Since a test system is no longer available, dropped the claim of + FreeBSD 4.9 support. + * Added the +|-E options for Linux. -E displays endpoint info; +E + displays endpoint info and endpopint files. + * Fixed a Linux bug handling processes whose command includes a + non-printing character, particularly a NEWLINE character, and + clarified printing of single '\\' characters in command and file names. + * Added support for Linux RDMA and CRYPTO protocal names and UNIX + socket type + * Fixed field output to insure that the field descriptor field is + always selected, since it identifies the file set. +- Spec file cleanup +* Mon Mar 26 2012 cfarrell@suse.com +- license update: Zlib + lsof license is most similar to Zlib (also use SPDX format) +* Tue Aug 16 2011 puzel@novell.com +- repack the tarball to remove legally problematic files + (bnc#705143) +* Mon Jun 27 2011 ro@suse.de +- change perl reference to /usr/bin/perl which actually exists +* Thu Jun 9 2011 k0da@opensuse.org +- perl4 refference causes missing perl4 dependency +* Wed Jan 12 2011 puzel@novell.com +- portability fixes (by Pascal) +* Sun Aug 29 2010 cristian.rodriguez@opensuse.org +- Do not include build host specific information including + date and compilation time to make build-compare happy +* Tue Aug 17 2010 puzel@novell.com +- update to lsof 4.84 + * corrects a man page nroff command error + * recognizes FreeBSD 7.3 + * adds improved task support, initially for Linux +* Fri Apr 9 2010 puzel@novell.com +- update to lsof 4.83 + * corrects an over-zealous test that causes lsof to produce no + ouput when the HASSECURITY and HASNOSOCKSECURITTY have been + specified at lsof build time + * fixes a typo with the LINUX_HASSELUNIX Configure variable + * accepts LSOF_RANLIB from the environment + * added Linux test for __UCLIBC__ +* Fri Feb 19 2010 coolo@novell.com +- fix 64bit issue (gcc 4.5) +* Sun Dec 20 2009 jengelh@medozas.de +- enable parallel build +* Mon Jan 19 2009 prusnak@suse.cz +- updated to 4.81 + * Updated the Darwin libproc sources with changes from + Allan Nathanson . Tested them on a iMac + mini, provided by Apple Inc. + * Changed dummy declarations in library source files to + eliminate complaints about unused variables and empty + object files. This change may not work on dialects I + can no longer test; it has been tested on some versions + of AIX, Darwin, FreeBSD, Linux and Solaris. + * At the request of Hal Brooks added support + for Linux /proc/net/packet files. Hal tested it. + * Added socket file only performance enhancements to Linux + and PSTAT-based HPUX lsof. + * Added htonl call around improper usage of INADDR_LOOPBACK; + report from an Apple engineer forwarded by Allan Nathanson + . + * Adjusted for FreeBSD-8.0 change in device number handling. + The adjustment should work for FreeBSD 5 and above, should + the 8.0 change be propagated downward. The problem was + reported by Pav Lucistnik . An updated + test system was provided by Erwin Lansing . + * Reduced AIX support to version 5.3, since test systems with + older versions are no longer available to me. + * At the request of Marjo F. Mercado + and Phil Shin applied some speed + improvements to lsof, particularly when the files of + interest are /Internet files -- i.e., selected with lsof's + - i" option. Added a two new options to assist the + improvements: 1) "-c^" to tell lsof to exclude the + named command(s); and 2) "-stcp|ud>:[^]state' to tell lsof + to include in its reporting or exclude ('^') from its + reporting Internet files in the named states (e.g., LISTEN, + ^CLOSE_WAIT, IDLE, etc.) For the most part these changes + apply only to AIX, Darwin, FreeBSD, PSTAT-based HP-UX, Linux + and Solaris, since those are the only places I could test + them. They are controlled by the HASTCPUDPSTATE definition + in each dialect's machine.h header file. Marjo and Phil + provided HP-UX 11.23 and 11.31 test systems. + * Fixed a stat(2) problem on HP-UX 11.31 while testing the + speed improvements. + * Adjusted for kernel header file changes in FreeBSD + 8.0-CURRENT. Larry Rosenman provided + a test system. + * Added a warning for Solaris systems where VxFS node info + can't be obtained from the VxFS utility library. The + warning was requested by Tom Matthews . + * Corrected mishandling of file system path name arguments + that have trailing slashes, except, of course, the root + file system, "/". Allan Nathanson reported + the bug. +* Mon Sep 8 2008 prusnak@suse.cz +- updated to 4.80 + * Updated for a FreeBSD 7.0 and above byte level locking + change. The problem was reported by Conrad J. Sabatier + , who helped test the update. Wesley + Shields provided an 8.0-CURRENT test + system. + * Propagated the FreeBSD 7.0 and above locking changes to + FreeBSD 6.x, based on a report from Edwin Groothuis + . + * Added warnings for unsupported dialects or versions. + * Added Linux support for the UDPLITE protocol. Eric + Dumazet supplied a patch. + * Added a missing quote to the Configure script's + FreeBSD stanza. + * Added a usage.o rule to the HP-UX PSTAT-based + Makefile. I mistakenly deleted the rule at revision + 4.79. The missing rule was reported by Kawaljeet Kaur + who tested the corrected + Makefile. +* Wed Aug 20 2008 prusnak@suse.cz +- enabled SELinux support [Fate#303662] +* Tue Apr 22 2008 prusnak@suse.cz +- updated to 4.79 + * improved Linux /proc file stream reading speed + * improved TCP, TCP6, UDP and UDP6 hashing by determining + the hash bucket count from the /proc/net sockstat and sockstat6 + files + * fixed a Linux maps file processing bug that prevented path names + from having an embedded colon + * added support for the Linux 2.6.22 kernel's /proc//fdinfo + files - i.e. file offset and flags + * fixed a Linux UNIX socket memory leak + * corrected a getpidcon() error message + * insured that inode numbers are handled correctly for their + unsigned long long type + * improved SELinux handling + * fixed a socket file identification problem + * added the ability to format the repeat mode marker line +* Thu Jul 26 2007 prusnak@suse.cz +- update to 4.78 + * simplified stat() and lstat() usage + * avoid processing /proc//maps file entries with zero device + and node numbers + * enabled ZFS support +* Fri Oct 20 2006 mjancar@suse.cz +- update to 4.77 + * lots of small bugfixes +- drop lsof_4.76_src-return.diff (included upstream) +* Wed Jan 25 2006 mls@suse.de +- converted neededforbuild to BuildRequires +* Sun Jan 15 2006 schwab@suse.de +- Don't strip binaries. +* Wed Jan 11 2006 mjancar@suse.cz +- update to 4.76 +* Tue Aug 2 2005 mjancar@suse.cz +- update to 4.75 +* Mon Feb 7 2005 mjancar@suse.cz +- update to 4.74 +* Fri Aug 6 2004 mjancar@suse.cz +- update to 4.72 +* Mon Apr 19 2004 mjancar@suse.cz +- add return to nonvoid functions +* Thu Feb 26 2004 mjancar@suse.cz +- uopdate to 4.70 +* Wed Nov 5 2003 ro@suse.de +- fix make test as non-root +* Thu Oct 30 2003 mjancar@suse.cz +- update to 4.69 +- no root for build +* Thu Jul 24 2003 mjancar@suse.cz +- update to 4.68 +- kill obsolete patches + * lsof_4.67_src-unescape.diff + * lsof_4.68_src-uninitialized.diff +* Thu Jun 12 2003 mjancar@suse.cz +- unescape paths from /proc/mounts (Bug #27321) +- fix mising prototypes and uninitialized variables +* Tue Apr 22 2003 vbobek@suse.cz +- updated to version 4.67 + * added the "+c " option to enable optional changing + of the COMMAND column output maximum width + * many other fixes +* Mon Feb 17 2003 vbobek@suse.cz +- updated to version 4.66 +* Tue Dec 3 2002 jderfina@suse.cz +- upgrade to version 4.65 +* Thu Jul 11 2002 nadvornik@suse.cz +- updated to 4.64 +* Tue Mar 5 2002 nadvornik@suse.cz +- fixed permissions of man page +* Mon Nov 26 2001 nadvornik@suse.cz +- update to 4.60: + - adds an IP version selector to the -i parameters + - adds better handling of IPv6 selectors + - makes safer lsof's ending of its child process + - adds options to affect -v output +- added example scripts to documentation +* Tue Aug 14 2001 nadvornik@suse.cz +- update to 4.57 +* Thu Mar 8 2001 nadvornik@suse.cz +- update to 4.55 +* Sun Dec 3 2000 smid@suse.cz +- new version 4.52 +* Wed Oct 4 2000 smid@suse.cz +- new version 4.51 +* Wed Apr 5 2000 smid@suse.cz +- upgrade to 4.49 +- BuildRoot added +* Thu Jan 20 2000 aj@suse.de +- /usr/man -> /usr/share/man +* Thu Nov 4 1999 ro@suse.de +- update to 4.46 +* Mon Sep 13 1999 bs@suse.de +- ran old prepare_spec on spec file to switch to new prepare_spec. +* Wed Sep 1 1999 ro@suse.de +- update to 4.45 +* Tue Mar 9 1999 ro@suse.de +- force LSOF_VERS=22003 +* Tue Mar 9 1999 ro@suse.de +- use proc-base version for STABLE, now that we're 2.2-based +* Fri Mar 5 1999 ro@suse.de +- for BETA: use proc version +- changed proc/dlsof.h to work with glibc-2.1 +* Fri Feb 26 1999 florian@suse.de +- add security patches +* Thu Dec 10 1998 ro@suse.de +- disabled proc-version in Configure +* Thu Dec 10 1998 ro@suse.de +- update to 4.38 +- added rh-patch for kmem/dlsof.h +- compile as 2.0 (kmem) version +* Tue Sep 22 1998 ro@suse.de +- update to 4.37 / for now only the proc version works with glibc + but that needs a running 2.1 kernel !!!! +* Wed Jun 24 1998 ro@suse.de +- update to 4.31 using diff from jurix/source +* Thu Oct 9 1997 florian@suse.de +- update to version 4.16 +* Wed Oct 8 1997 max@suse.de +- changed to rpm format and eliminated Makefile.Linux +* Mon Jul 7 1997 florian@suse.de +- update to version 4.11 +* Sat Apr 26 1997 florian@suse.de +- add new package of lsof 4.05 diff --git a/lsof.spec b/lsof.spec new file mode 100644 index 0000000..cde7704 --- /dev/null +++ b/lsof.spec @@ -0,0 +1,65 @@ +# +# spec file for package lsof +# +# Copyright (c) 2022-2023 ZhuningOS +# + + +Name: lsof +Version: 4.91 +Release: 1.11 +Summary: A Program That Lists Information about Files Opened by Processes +License: Zlib +Group: System/Monitoring +Url: http://people.freebsd.org/~abe/ +# Always repack the source to remove legally problematic files - bnc#705143 +# dialects/uw/uw7/sys/fs/{fifonode.h,namenode.h,README} +Source: %{name}_%{version}_src_repacked.tar.xz +Patch0: lsof_4.81-include.patch +Patch1: lsof_4.81-fmt.patch +Patch2: lsof-no-build-date-etc.patch +Patch3: lsof_4.81-perl.patch +BuildRequires: libselinux-devel +BuildRequires: xz + +%description +Lsof lists information about files opened by processes. An open file +may be a regular file, a directory, a block special file, a character +special file, an executing text reference, a library, a stream, or a +network file (Internet socket, NFS file, or UNIX domain socket.) A +specific file or all the files in a file system may be selected by +path. + +%prep +%setup -q -n %{name}_%{version}_src +%patch0 +%patch1 +%patch2 +%patch3 + +%build +./Configure -n linux +make %{?_smp_mflags} DEBUG="%{optflags} -Wall -Wno-unused" +cd tests +chmod u+w TestDB +./Add2TestDB +make %{?_smp_mflags} DEBUG="%{optflags} -Wall -Wno-unused" + +%install +install -m755 -d %{buildroot}%{_bindir} %{buildroot}%{_mandir}/man8 +install -m755 lsof %{buildroot}%{_bindir} +install -m644 lsof.8 %{buildroot}%{_mandir}/man8 +mkdir SUSE_docs +for s in 00* ; do + mv $s SUSE_docs/${s#00} +done +sed -i -e "s|%{_prefix}/local/bin/perl|%{_bindir}/perl|g" scripts/* +mv scripts/00MANIFEST scripts/MANIFEST +mv scripts/00README scripts/README + +%files +%doc SUSE_docs/* scripts +%{_mandir}/man8/lsof.8%{ext_man} +%{_bindir}/lsof + +%changelog diff --git a/lsof_4.81-fmt.patch b/lsof_4.81-fmt.patch new file mode 100644 index 0000000..0dfde28 --- /dev/null +++ b/lsof_4.81-fmt.patch @@ -0,0 +1,11 @@ +--- node.c ++++ node.c +@@ -53,7 +53,7 @@ + + (void) snpf(buf ? buf : dbuf, + buf ? bufl : sizeof(dbuf), +- KA_T_FMT_X, kp); ++ KA_T_FMT_X, (unsigned long)kp); + return(buf ? buf : dbuf); + } + diff --git a/lsof_4.81-include.patch b/lsof_4.81-include.patch new file mode 100644 index 0000000..805f8d3 --- /dev/null +++ b/lsof_4.81-include.patch @@ -0,0 +1,33 @@ +--- + arg.c | 3 +++ + print.c | 3 +++ + 2 files changed, 6 insertions(+) + +Index: arg.c +=================================================================== +--- arg.c.orig 2009-03-25 20:20:33.000000000 +0100 ++++ arg.c 2010-04-09 12:38:06.000000000 +0200 +@@ -37,6 +37,9 @@ static char *rcsid = "$Id: arg.c,v 1.49 + + + #include "lsof.h" ++#include ++#include ++#include + + + /* +Index: print.c +=================================================================== +--- print.c.orig 2010-01-18 20:01:17.000000000 +0100 ++++ print.c 2010-04-09 12:38:06.000000000 +0200 +@@ -37,6 +37,9 @@ static char *rcsid = "$Id: print.c,v 1.5 + + + #include "lsof.h" ++#include ++#include ++#include + + + /* diff --git a/lsof_4.81-perl.patch b/lsof_4.81-perl.patch new file mode 100644 index 0000000..28bf4fe --- /dev/null +++ b/lsof_4.81-perl.patch @@ -0,0 +1,8 @@ +--- scripts/list_fields.perl.orig 2011-06-09 13:19:05.000000000 +0200 ++++ scripts/list_fields.perl 2011-06-09 13:19:17.000000000 +0200 +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/perl4 ++#!/usr/bin/perl + # + # $Id: list_fields.perl,v 1.5 2000/07/14 17:03:37 abe Exp $ + #