diff --git a/.gitignore b/.gitignore index f785c3b..863218e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1 @@ -/lsof_4.91-rh.tar.xz -/lsof-4.93.2-rh.tar.xz -/lsof-4.94.0-rh.tar.xz -/lsof-4.95.0-rh.tar.xz -/lsof-4.96.3-rh.tar.xz -/lsof-4.98.0-rh.tar.xz +lsof_4.78C-rh.tar.bz2 diff --git a/f42-ftbfs.patch b/f42-ftbfs.patch deleted file mode 100644 index 626bfab..0000000 --- a/f42-ftbfs.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/misc.c b/misc.c -index 9f443ea..a4bb3db 100644 ---- a/misc.c -+++ b/misc.c -@@ -58,7 +58,7 @@ _PROTOTYPE(static void closePipes,(void)); - _PROTOTYPE(static int dolstat,(char *path, char *buf, int len)); - _PROTOTYPE(static int dostat,(char *path, char *buf, int len)); - _PROTOTYPE(static int doreadlink,(char *path, char *buf, int len)); --_PROTOTYPE(static int doinchild,(int (*fn)(), char *fp, char *rbuf, int rbln)); -+_PROTOTYPE(static int doinchild,(int (*fn)(char *, char *, int), char *fp, char *rbuf, int rbln)); - - #if defined(HASINTSIGNAL) - _PROTOTYPE(static int handleint,(int sig)); -@@ -234,7 +234,7 @@ compdev(a1, a2) - - static int - doinchild(fn, fp, rbuf, rbln) -- int (*fn)(); /* function to perform */ -+ int (*fn)(char *, char *, int); /* function to perform */ - char *fp; /* function parameter */ - char *rbuf; /* response buffer */ - int rbln; /* response buffer length */ -@@ -296,7 +296,7 @@ doinchild(fn, fp, rbuf, rbln) - */ - struct stat _; - } r; -- int (*r_fn)(); -+ int (*r_fn)(char *, char *, int); - /* - * Close sufficient open file descriptors except Pipes[0] and - * Pipes[3]. diff --git a/lsof-man-page-section.patch b/lsof-man-page-section.patch deleted file mode 100644 index 47da375..0000000 --- a/lsof-man-page-section.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff -up ./Lsof.8.ori ./Lsof.8 ---- ./Lsof.8.ori 2022-09-20 19:46:03.560004892 +0200 -+++ ./Lsof.8 2022-09-20 19:46:17.578086787 +0200 -@@ -1,5 +1,5 @@ - .so ./version --.TH LSOF 8 Revision-\*(VN -+.TH LSOF 1 Revision-\*(VN - .\" Register )P is used neither by this file nor any groff macro. However, - .\" some versions of nroff require it. - .if !\n(.g \{\ diff --git a/lsof-tirpc.patch b/lsof-tirpc.patch deleted file mode 100644 index efe343e..0000000 --- a/lsof-tirpc.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- lsof_4.91-rh/Configure.orig 2018-05-22 15:54:57.275682247 +0200 -+++ lsof_4.91-rh/Configure 2018-05-22 15:55:22.314556548 +0200 -@@ -2945,7 +2945,7 @@ return(0); } - - # Test for . - -- if ! test -r ${LSOF_INCLUDE}/rpc/rpc.h # { -+ if ! test -r ${LSOF_INCLUDE}/tirpc/rpc/rpc.h # { - then - LSOF_CFGF="$LSOF_CFGF -DHASNORPC_H" - fi # } diff --git a/lsof.spec b/lsof.spec index 04379d5..37fb7bc 100644 --- a/lsof.spec +++ b/lsof.spec @@ -1,263 +1,64 @@ Summary: A utility which lists open files on a Linux/UNIX system Name: lsof -Version: 4.98.0 +Version: 4.78 Release: 8%{?dist} -License: lsof -URL: https://github.com/lsof-org/lsof +License: Distributable +Group: Development/Debuggers # lsof contains licensed code that we cannot ship. Therefore we use # upstream2downstream.sh script to remove the code before shipping it. # -# The script can be found in SCM or downloaded from: -# http://pkgs.fedoraproject.org/cgit/lsof.git/tree/upstream2downstream.sh +# The script you can found in CVS or download from: +# http://cvs.fedoraproject.org/viewcvs/rpms/lsof/devel/upstream2downstream.sh +# +%define lsofrh lsof_4.78C-rh +Source0: %{lsofrh}.tar.bz2 +URL: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof -%global lsofrh lsof-%{version}-rh -Source0: %{lsofrh}.tar.xz -Source1: upstream2downstream.sh +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -# BZ#1260300 - move lsof man page to section 1 -Patch0: lsof-man-page-section.patch -Patch1: f42-ftbfs.patch - -BuildRequires: gcc BuildRequires: libselinux-devel -BuildRequires: libtirpc-devel -BuildRequires: groff-base -BuildRequires: make -BuildRequires: automake -BuildRequires: autoconf -BuildRequires: git + +Patch1: lsof_4.78C-threads.patch +Patch2: lsof_4.78C-inode.patch +Patch3: lsof_4.78C-selinux.patch %description -Lsof stands for LiSt Open Files, and it does just that: it lists information -about files that are open by the processes running on a UNIX system. +Lsof stands for LiSt Open Files, and it does just that: it lists +information about files that are open by the processes running on a +UNIX system. %prep -%autosetup -n %{lsofrh} -S git +%setup -q -n %{lsofrh} +# 184338 - allow lsof access nptl threads +%patch1 -p1 +# 243976 - mmap'd files with large inode numbers confuse lsof +%patch2 -p1 +# 280651 - lsof prints entries in multiple lines when SElinux is disabled +%patch3 -p1 %build -%configure -%make_build DEBUG="%{build_cflags} -I/usr/include/tirpc" CFGL="%{build_ldflags} -L./lib -llsof -lselinux -ltirpc" -# rebase to 4.93 introduced change in Lsof.8 with unhandled .so inclusion -soelim -r Lsof.8 > lsof.1 +LSOF_VSTR=2.6.16 LINUX_BASE=/proc ./Configure -n linux + +make DEBUG="$RPM_OPT_FLAGS" %{?_smp_mflags} %install -mkdir -p ${RPM_BUILD_ROOT}%{_bindir} -install -p -m 0755 lsof ${RPM_BUILD_ROOT}%{_bindir} -mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1 -install -p -m 0644 lsof.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/lsof.1 +rm -rf ${RPM_BUILD_ROOT} +mkdir -p ${RPM_BUILD_ROOT}%{_sbindir} +install -p -m 0755 lsof ${RPM_BUILD_ROOT}%{_prefix}/sbin +mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8 +install -p lsof.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/ + +%clean +rm -rf ${RPM_BUILD_ROOT} %files -%doc 00README 00CREDITS 00FAQ 00LSOF-L 00QUICKSTART -%{_bindir}/lsof +%defattr(644,root,root,755) +%doc 00* +%attr(0755,root,root) %{_sbindir}/lsof %{_mandir}/man*/* %changelog -* Thu Jul 24 2025 Fedora Release Engineering - 4.98.0-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Fri Jan 24 2025 Jan Rybar - 4.98.0-7 -- FTBFS: stricter check, incompatible types - -* Fri Jan 17 2025 Fedora Release Engineering - 4.98.0-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Thu Jul 18 2024 Fedora Release Engineering - 4.98.0-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Thu Jan 25 2024 Fedora Release Engineering - 4.98.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Sun Jan 21 2024 Fedora Release Engineering - 4.98.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Mon Oct 23 2023 Jan Rybar - 4.98.0-2 -- version bump due to licence fix - -* Fri Oct 20 2023 Jan Rybar - 4.98.0-1 -- rebase to lsof-4.98 - -* Thu Jul 20 2023 Fedora Release Engineering - 4.96.3-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Thu Jan 19 2023 Fedora Release Engineering - 4.96.3-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Mon Nov 21 2022 Florian Weimer - 4.96.3-2 -- Fix C89isms in Configure - -* Tue Sep 20 2022 Jan Rybar - 4.96.3-1 -- rebase to 4.96.3 - -* Fri Sep 02 2022 Jan Rybar - 4.95.0-1 -- rebase to 4.95.0 - -* Thu Jul 21 2022 Fedora Release Engineering - 4.94.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Thu Jan 20 2022 Fedora Release Engineering - 4.94.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Thu Jul 22 2021 Fedora Release Engineering - 4.94.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Thu Jan 28 2021 Jan Rybar - 4.94.0-1 -- Rebase to 4.94.0 - -* Tue Jan 26 2021 Fedora Release Engineering - 4.93.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Tue Jul 28 2020 Fedora Release Engineering - 4.93.2-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Wed Jan 29 2020 Fedora Release Engineering - 4.93.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Thu Jul 25 2019 Fedora Release Engineering - 4.93.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Tue May 28 2019 Jan Rybar - 4.93.2-1 -- Rebase to lsof-4.93.2 -- Upstream moved to GitHub and tarball structure changed -- Manpage patch needed to reflect the tarball changes - -* Fri Feb 01 2019 Fedora Release Engineering - 4.91-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Fri Jul 13 2018 Fedora Release Engineering - 4.91-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Tue May 22 2018 Peter Schiffer - 4.91-1 -- resolves: #1560993 - updated to 4.91 -- resolves: #1574669 - use tirpc library for rpc - -* Fri Apr 13 2018 Rafael dos Santos - 4.90-2 -- Use standard Fedora build flags (bug #1548552) - -* Wed Feb 21 2018 Peter Schiffer - 4.90-1 -- resolves: #1545963 - updated to 4.90 - -* Thu Feb 08 2018 Fedora Release Engineering - 4.89-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Thu Aug 03 2017 Fedora Release Engineering - 4.89-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild - -* Wed Jul 26 2017 Fedora Release Engineering - 4.89-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild - -* Fri Feb 10 2017 Fedora Release Engineering - 4.89-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - -* Sat Mar 5 2016 Peter Robinson 4.89-4 -- Only ship end user useful docs, don't ship bits for building - -* Thu Feb 04 2016 Fedora Release Engineering - 4.89-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - -* Mon Nov 30 2015 Peter Schiffer - 4.89-2 -- resolves #1260300 - moved lsof to /usr/bin, it's not sysadmin only utility - -* Wed Jul 29 2015 Peter Schiffer - 4.89-1 -- updated to 4.89 - -* Wed Jun 17 2015 Fedora Release Engineering - 4.88-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild - -* Tue Jan 6 2015 Peter Schiffer - 4.88-2 -- added upstream patch fixing unwanted pipe file output -- cleaned .spec file - -* Wed Oct 15 2014 Peter Schiffer - 4.88-1 -- updated to 4.88 - -* Sun Aug 17 2014 Fedora Release Engineering - 4.87-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild - -* Sat Jun 07 2014 Fedora Release Engineering - 4.87-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild - -* Sat Aug 03 2013 Fedora Release Engineering - 4.87-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild - -* Thu Feb 14 2013 Fedora Release Engineering - 4.87-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild - -* Thu Jan 3 2013 Peter Schiffer - 4.87-1 -- resolves: #891508 - updated to 4.87 - -* Tue Aug 28 2012 Peter Schiffer - 4.86-4 -- .spec file cleanup - -* Thu Jul 19 2012 Fedora Release Engineering - 4.86-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Mon Jun 04 2012 Peter Schiffer - 4.86-2 -- added support for files on anon_inodefs - -* Fri Apr 20 2012 Peter Schiffer - 4.86-1 -- resolves: #811520 - update to 4.86 - -* Fri Jan 13 2012 Fedora Release Engineering - 4.85-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Fri Sep 30 2011 Peter Schiffer - 4.85-1 -- resolves: #741882 - update to 4.85 - -* Tue Feb 08 2011 Fedora Release Engineering - 4.84-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Thu Jan 13 2011 Ville Skyttä - 4.84-3 -- Fix man page permissions. - -* Wed Sep 29 2010 jkeating - 4.84-2 -- Rebuilt for gcc bug 634757 - -* Wed Sep 15 2010 Karel Zak 4.84-1 -- upgrade to 4.84 -- remove lsof_4.81-threads.patch, "lsof -K" provides basic support for tasks now - -* Fri Feb 19 2010 Karel Zak 4.83-2 -- minor changes in spec file (#226108 - Merge Review) - -* Thu Feb 11 2010 Karel Zak 4.83-1 -- upgrade to 4.83 (see the 00DIST file for list of changes) -- remove lsof_4.83A-selinux-typo.patch (fixed upstream) - -* Mon Jul 27 2009 Karel Zak 4.82-1 -- upgrade to 4.82 (see the 00DIST file for list of changes) -- backport an upstream patch from 4.83A-linux -- remove lsof_4.81-man.patch (fixed upstream) - -* Sat Jul 25 2009 Fedora Release Engineering - 4.81-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Wed Feb 25 2009 Fedora Release Engineering - 4.81-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild - -* Fri Jan 30 2009 Karel Zak 4.81-2 -- fix #480694 - lsof manpage mismarked and formats badly - -* Tue Dec 2 2008 Karel Zak 4.81-1 -- upgrade to 4.81 - - lsof_4.80-threads.patch - rebased - -* Thu Aug 7 2008 Tom "spot" Callaway 4.80-2 -- fix license tag - -* Tue May 20 2008 Karel Zak 4.80-1 -- upgrade to 4.80 - - lsof_4.78C-inode.patch - merged upstream - - lsof_4.78C-selinux.patch - merged upstream - - lsof_4.78C-threads.patch - rebased - * Tue Feb 19 2008 Fedora Release Engineering - 4.78-8 - Autorebuild for GCC 4.3 @@ -333,3 +134,104 @@ install -p -m 0644 lsof.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/lsof.1 - update to 4.73 - remove lsof_4.72-sock.patch, already in the upstream code +* Fri Jul 30 2004 Jakub Jelinek 4.72-1 +- update to 4.72 +- use st_dev/st_ino comparison for sockets by name if possible + (#126419) + +* Fri Jul 18 2003 Jakub Jelinek 4.68-1 +- update to 4.68 (#99064) + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Thu Dec 12 2002 Tim Powers 4.63-3 +- rebuild on all arches + +* Fri Jun 21 2002 Tim Powers +- automated rebuild + +* Fri Jun 21 2002 Jakub Jelinek 4.63-1 +- update to 4.63 (#66333). + +* Thu May 23 2002 Tim Powers +- automated rebuild + +* Wed Jan 09 2002 Tim Powers +- automated rebuild + +* Sun Jun 24 2001 Elliot Lee +- Bump release + rebuild. + +* Thu Sep 7 2000 Jeff Johnson +- update to 4.51. + +* Wed Jul 12 2000 Prospector +- automatic rebuild + +* Wed Jun 14 2000 Jeff Johnson +- FHS packaging. + +* Sun Mar 26 2000 Florian La Roche +- change to root:root perms + +* Wed Feb 02 2000 Cristian Gafton +- fix description +- man pages are compressed + +* Wed Dec 22 1999 Jeff Johnson +- update to 4.47. + +* Tue Aug 3 1999 Jeff Johnson +- update to 4.45. + +* Fri Jun 25 1999 Jeff Johnson +- update to 4.44. + +* Fri May 14 1999 Jeff Johnson +- upgrade to 4.43 with sparc64 tweak (#2803) + +* Thu Apr 08 1999 Preston Brown +- upgrade to 4.42 (security fix) + +* Sun Mar 21 1999 Cristian Gafton +- auto rebuild in the new build environment (release 5) + +* Fri Mar 19 1999 Jeff Johnson +- turn off setgid kmem "just in case". + +* Thu Feb 18 1999 Jeff Johnson +- buffer overflow patch. +- upgrade to 4.40. + +* Wed Dec 30 1998 Jeff Johnson +- update to "official" 4.39 release. + +* Wed Dec 16 1998 Jeff Johnson +- update to 4.39B (linux) with internal kernel src. + +* Tue Dec 15 1998 Jeff Johnson +- update to 4.39A (linux) + +* Sat Sep 19 1998 Jeff Johnson +- update to 4.37 + +* Thu Sep 10 1998 Jeff Johnson +- update to 4.36 + +* Thu Jul 23 1998 Jeff Johnson +- upgrade to 4.35. +- rewrap for RH 5.2. + +* Mon Jun 29 1998 Maciej Lesniewski + [4.34-1] +- New version +- Spec rewriten to use %%{name} and %%{version} macros +- Removed old log enteries + +* Tue Apr 28 1998 Maciej Lesniewski +- Built under RH5 +- install macro was changed diff --git a/lsof_4.78C-inode.patch b/lsof_4.78C-inode.patch new file mode 100644 index 0000000..bff5baf --- /dev/null +++ b/lsof_4.78C-inode.patch @@ -0,0 +1,337 @@ +diff -up lsof_4.78C-rh/dialects/linux/dnode.c.inode lsof_4.78C-rh/dialects/linux/dnode.c +--- lsof_4.78C-rh/dialects/linux/dnode.c.inode 2006-06-12 19:10:05.000000000 +0200 ++++ lsof_4.78C-rh/dialects/linux/dnode.c 2007-10-03 14:01:54.000000000 +0200 +@@ -191,7 +191,7 @@ get_locks(p) + char buf[MAXPATHLEN], *ec, **fp; + dev_t dev; + int ex, i, h, mode, pid; +- unsigned long inode; ++ INODETYPE inode; + struct llock *lp, *np; + FILE *ls; + long maj, min; +@@ -267,7 +267,7 @@ get_locks(p) + */ + ec = (char *)NULL; + if (!fp[7] || !*fp[7] +- || (inode = strtoul(fp[7], &ec, 0)) == ULONG_MAX ++ || (inode = strtoull(fp[7], &ec, 0)) == ULONG_MAX + || !ec || *ec) + continue; + /* +@@ -297,7 +297,7 @@ get_locks(p) + for (lp = LckH[h]; lp; lp = lp->next) { + if (lp->pid == pid + && lp->dev == dev +- && lp->inode == (INODETYPE)inode ++ && lp->inode == inode + && lp->type == type) + break; + } +@@ -307,14 +307,15 @@ get_locks(p) + * Allocate a new llock structure and link it to the PID hash bucket. + */ + if (!(lp = (struct llock *)malloc(sizeof(struct llock)))) { ++ (void) snpf(buf, sizeof(buf), InodeFmt_d, inode); + (void) fprintf(stderr, +- "%s: can't allocate llock: PID %d; dev %x; inode %ld\n", +- Pn, pid, (int)dev, inode); ++ "%s: can't allocate llock: PID %d; dev %x; inode %s\n", ++ Pn, pid, (int)dev, buf); + Exit(1); + } + lp->pid = pid; + lp->dev = dev; +- lp->inode = (INODETYPE)inode; ++ lp->inode = inode; + lp->type = type; + lp->next = LckH[h]; + LckH[h] = lp; +diff -up lsof_4.78C-rh/dialects/linux/dproc.c.inode lsof_4.78C-rh/dialects/linux/dproc.c +--- lsof_4.78C-rh/dialects/linux/dproc.c.inode 2007-10-03 14:01:54.000000000 +0200 ++++ lsof_4.78C-rh/dialects/linux/dproc.c 2007-10-03 14:01:54.000000000 +0200 +@@ -41,6 +41,9 @@ static char *rcsid = "$Id: dproc.c,v 1.1 + #include + #endif /* defined(HASSELINUX) */ + ++#if !defined(ULLONG_MAX) ++#define ULLONG_MAX 18446744073709551615ULL ++#endif /* !defined(ULLONG_MAX) */ + + /* + * Local definitions +@@ -790,7 +793,10 @@ process_proc_map(p, s, ss) + dev = (dev_t)makedev((int)maj, (int)min); + if (!fp[5] || !*fp[5]) + continue; +- inode = (INODETYPE)atoi(fp[5]); ++ ep = (char *)NULL; ++ if ((inode = strtoull(fp[5], &ep, 0)) == ULLONG_MAX ++ || !ep || *ep) ++ continue; + if (!dev && !inode) + continue; + /* +diff -up lsof_4.78C-rh/dialects/linux/dsock.c.inode lsof_4.78C-rh/dialects/linux/dsock.c +--- lsof_4.78C-rh/dialects/linux/dsock.c.inode 2006-06-12 19:10:05.000000000 +0200 ++++ lsof_4.78C-rh/dialects/linux/dsock.c 2007-10-03 14:02:39.000000000 +0200 +@@ -350,7 +350,8 @@ get_ax25(p) + FILE *as; + char buf[MAXPATHLEN], *da, *dev_ch, *ep, **fp, *sa; + int h, nf; +- unsigned long inode, rq, sq, state; ++ INODETYPE inode; ++ unsigned long rq, sq, state; + MALLOC_S len; + unsigned char rqs, sqs; + /* +@@ -410,12 +411,12 @@ get_ax25(p) + */ + ep = (char *)NULL; + if (!fp[23] || !*fp[23] +- || (inode = strtoul(fp[23], &ep, 0)) == ULONG_MAX ++ || (inode = strtoull(fp[23], &ep, 0)) == ULONG_MAX + || !ep || *ep) + continue; + h = INOHASH((INODETYPE)inode); + for (ap = AX25sin[h]; ap; ap = ap->next) { +- if ((INODETYPE)inode == ap->inode) ++ if (inode == ap->inode) + break; + } + if (ap) +@@ -496,7 +497,7 @@ get_ax25(p) + } + ap->da = da; + ap->dev_ch = dev_ch; +- ap->inode = (INODETYPE)inode; ++ ap->inode = inode; + ap->rq = rq; + ap->rqs = rqs; + ap->sa = sa; +@@ -521,7 +522,8 @@ get_ipx(p) + char buf[MAXPATHLEN], *ep, **fp, *la, *ra; + int fl = 1; + int h; +- unsigned long inode, rxq, state, txq; ++ INODETYPE inode; ++ unsigned long rxq, state, txq; + struct ipxsin *ip, *np; + MALLOC_S len; + FILE *xs; +@@ -588,12 +590,12 @@ get_ipx(p) + */ + ep = (char *)NULL; + if (!fp[6] || !*fp[6] +- || (inode = strtoul(fp[6], &ep, 0)) == ULONG_MAX ++ || (inode = strtoull(fp[6], &ep, 0)) == ULONG_MAX + || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (ip = Ipxsin[h]; ip; ip = ip->next) { +- if ((INODETYPE)inode == ip->inode) ++ if (inode == ip->inode) + break; + } + if (ip) +@@ -653,7 +655,7 @@ get_ipx(p) + Pn, sizeof(struct ipxsin)); + Exit(1); + } +- ip->inode = (INODETYPE)inode; ++ ip->inode = inode; + ip->la = la; + ip->ra = ra; + ip->txq = txq; +@@ -676,7 +678,7 @@ get_raw(p) + { + char buf[MAXPATHLEN], *ep, **fp, *la, *ra, *sp; + int h; +- unsigned long inode; ++ INODETYPE inode; + int nf = 12; + struct rawsin *np, *rp; + MALLOC_S lal, ral, spl; +@@ -741,12 +743,12 @@ get_raw(p) + */ + ep = (char *)NULL; + if (!fp[9] || !*fp[9] +- || (inode = strtoul(fp[9], &ep, 0)) == ULONG_MAX ++ || (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX + || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (rp = Rawsin[h]; rp; rp = rp->next) { +- if ((INODETYPE)inode == rp->inode) ++ if (inode == rp->inode) + break; + } + if (rp) +@@ -800,7 +802,7 @@ get_raw(p) + Pn, sizeof(struct rawsin)); + Exit(1); + } +- rp->inode = (INODETYPE)inode; ++ rp->inode = inode; + rp->la = la; + rp->lal = lal; + rp->ra = ra; +@@ -825,9 +827,10 @@ get_tcpudp(p, pr, clr) + int clr; /* 1 == clear the table */ + { + char buf[MAXPATHLEN], *ep, **fp; +- unsigned long faddr, fport, inode, laddr, lport, rxq, state, txq; ++ unsigned long faddr, fport, laddr, lport, rxq, state, txq; + int h, nf; + FILE *fs; ++ INODETYPE inode; + struct tcp_udp *np, *tp; + /* + * Delete previous table contents. Allocate a table for the first time. +@@ -902,7 +905,7 @@ get_tcpudp(p, pr, clr) + || (fport = strtoul(fp[4], &ep, 16)) == ULONG_MAX || !ep || *ep) + continue; + /* +- * Get the state, queue sizes, and inode. ++ * Get the state and queue sizes. + */ + ep = (char *)NULL; + if (!fp[5] || !*fp[5] +@@ -921,11 +924,11 @@ get_tcpudp(p, pr, clr) + */ + ep = (char *)NULL; + if (!fp[13] || !*fp[13] +- || (inode = strtoul(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep) ++ || (inode = strtoull(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (tp = TcpUdp[h]; tp; tp = tp->next) { +- if (tp->inode == (INODETYPE)inode) ++ if (tp->inode == inode) + break; + } + if (tp) +@@ -939,7 +942,7 @@ get_tcpudp(p, pr, clr) + Pn, sizeof(struct tcp_udp)); + Exit(1); + } +- tp->inode = (INODETYPE)inode; ++ tp->inode = inode; + tp->faddr = faddr; + tp->fport = (int)(fport & 0xffff); + tp->laddr = laddr; +@@ -966,7 +969,7 @@ get_raw6(p) + { + char buf[MAXPATHLEN], *ep, **fp, *la, *ra, *sp; + int h; +- unsigned long inode; ++ INODETYPE inode; + int nf = 12; + struct rawsin *np, *rp; + MALLOC_S lal, ral, spl; +@@ -1031,12 +1034,12 @@ get_raw6(p) + */ + ep = (char *)NULL; + if (!fp[9] || !*fp[9] +- || (inode = strtoul(fp[9], &ep, 0)) == ULONG_MAX ++ || (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX + || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (rp = Rawsin6[h]; rp; rp = rp->next) { +- if ((INODETYPE)inode == rp->inode) ++ if (inode == rp->inode) + break; + } + if (rp) +@@ -1090,7 +1093,7 @@ get_raw6(p) + Pn, sizeof(struct rawsin)); + Exit(1); + } +- rp->inode = (INODETYPE)inode; ++ rp->inode = inode; + rp->la = la; + rp->lal = lal; + rp->ra = ra; +@@ -1116,9 +1119,10 @@ get_tcpudp6(p, pr, clr) + { + char buf[MAXPATHLEN], *ep, **fp; + struct in6_addr faddr, laddr; +- unsigned long fport, inode, lport, rxq, state, txq; ++ unsigned long fport, lport, rxq, state, txq; + int h, nf; + FILE *fs; ++ INODETYPE inode; + struct tcp_udp6 *np6, *tp6; + /* + * Delete previous table contents. Allocate a table for the first time. +@@ -1189,7 +1193,7 @@ get_tcpudp6(p, pr, clr) + || (fport = strtoul(fp[4], &ep, 16)) == ULONG_MAX || !ep || *ep) + continue; + /* +- * Get the state, queue sizes, and inode. ++ * Get the state and queue sizes. + */ + ep = (char *)NULL; + if (!fp[5] || !*fp[5] +@@ -1208,11 +1212,11 @@ get_tcpudp6(p, pr, clr) + */ + ep = (char *)NULL; + if (!fp[13] || !*fp[13] +- || (inode = strtoul(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep) ++ || (inode = strtoull(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (tp6 = TcpUdp6[h]; tp6; tp6 = tp6->next) { +- if (tp6->inode == (INODETYPE)inode) ++ if (tp6->inode == inode) + break; + } + if (tp6) +@@ -1226,7 +1230,7 @@ get_tcpudp6(p, pr, clr) + Pn, sizeof(struct tcp_udp6)); + Exit(1); + } +- tp6->inode = (INODETYPE)inode; ++ tp6->inode = inode; + tp6->faddr = faddr; + tp6->fport = (int)(fport & 0xffff); + tp6->laddr = laddr; +@@ -1254,7 +1258,7 @@ get_unix(p) + char buf[MAXPATHLEN], *ep, **fp, *path, *pcb; + int fl = 1; + int h, nf; +- unsigned long inode; ++ INODETYPE inode; + MALLOC_S len; + struct uxsin *np, *up; + FILE *us; +@@ -1319,11 +1323,11 @@ get_unix(p) + */ + ep = (char *)NULL; + if (!fp[6] || !*fp[6] +- || (inode = strtoul(fp[6], &ep, 0)) == ULONG_MAX || !ep || *ep) ++ || (inode = strtoull(fp[6], &ep, 0)) == ULONG_MAX || !ep || *ep) + continue; +- h = INOHASH((INODETYPE)inode); ++ h = INOHASH(inode); + for (up = Uxsin[h]; up; up = up->next) { +- if ((INODETYPE)inode == up->inode) ++ if (inode == up->inode) + break; + } + if (up) +@@ -1362,7 +1366,7 @@ get_unix(p) + Pn, sizeof(struct uxsin)); + Exit(1); + } +- up->inode = (INODETYPE)inode; ++ up->inode = inode; + up->pcb = pcb; + up->sb_def = 0; + if ((up->path = path) && (*path == '/')) { diff --git a/lsof_4.78C-selinux.patch b/lsof_4.78C-selinux.patch new file mode 100644 index 0000000..106dce2 --- /dev/null +++ b/lsof_4.78C-selinux.patch @@ -0,0 +1,113 @@ +diff -up lsof_4.78C-rh/proc.c.selinux lsof_4.78C-rh/proc.c +--- lsof_4.78C-rh/proc.c.selinux 2006-06-12 19:10:02.000000000 +0200 ++++ lsof_4.78C-rh/proc.c 2007-10-03 12:15:57.000000000 +0200 +@@ -968,7 +968,7 @@ print_proc() + #endif /* defined(HASZONES) */ + + #if defined(HASSELINUX) +- if (FieldSel[LSOF_FIX_CNTX].st && Fcntx && Lp->cntx) ++ if (FieldSel[LSOF_FIX_CNTX].st && Fcntx && Lp->cntx && CntxStatus) + (void) printf("%c%s%c", LSOF_FID_CNTX, Lp->cntx, Terminator); + #endif /* defined(HASSELINUX) */ + +diff -up lsof_4.78C-rh/store.c.selinux lsof_4.78C-rh/store.c +--- lsof_4.78C-rh/store.c.selinux 2006-06-12 19:10:03.000000000 +0200 ++++ lsof_4.78C-rh/store.c 2007-10-03 12:15:57.000000000 +0200 +@@ -70,7 +70,9 @@ lsof_rx_t *CmdRx = (lsof_rx_t *)NULL; + cntxlist_t *CntxArg = (cntxlist_t *)NULL; + /* security context arguments supplied with + * -Z */ +-int CntxColW; /* security context column width */ ++int CntxColW; /* security context column width */ ++int CntxStatus = 0; /* security context status: 0 == disabled, ++ * 1 == enabled */ + #endif /* defined(HASSELINUX) */ + + #if defined(HASDCACHE) +diff -up lsof_4.78C-rh/dialects/linux/dproc.c.selinux lsof_4.78C-rh/dialects/linux/dproc.c +--- lsof_4.78C-rh/dialects/linux/dproc.c.selinux 2007-10-03 12:15:57.000000000 +0200 ++++ lsof_4.78C-rh/dialects/linux/dproc.c 2007-10-03 12:17:22.000000000 +0200 +@@ -468,7 +468,7 @@ gather_proc_info() + Lp->cntx = (char *)NULL; + if (!Fwarn) { + (void) snpf(nmabuf, sizeof(nmabuf), +- "(getpidcon: %s)\n", strerror(errno)); ++ "(getpidcon: %s)", strerror(errno)); + if (!(Lp->cntx = strdup(nmabuf))) { + (void) fprintf(stderr, + "%s: no context error space: PID %ld", +diff -up lsof_4.78C-rh/usage.c.selinux lsof_4.78C-rh/usage.c +--- lsof_4.78C-rh/usage.c.selinux 2006-06-12 19:10:03.000000000 +0200 ++++ lsof_4.78C-rh/usage.c 2007-10-03 12:15:57.000000000 +0200 +@@ -787,7 +788,10 @@ usage(xv, fh, version) + continue; + #endif /* !defined(HASZONES) */ + +-#if !defined(HASSELINUX) ++#if defined(HASSELINUX) ++ if ((FieldSel[i].id == LSOF_FID_CNTX) && !CntxStatus) ++ continue; ++#else /* !defined(HASSELINUX) */ + if (FieldSel[i].id == LSOF_FID_CNTX) + continue; + #endif /* !defined(HASSELINUX) */ +diff -up lsof_4.78C-rh/main.c.selinux lsof_4.78C-rh/main.c +--- lsof_4.78C-rh/main.c.selinux 2006-06-12 19:10:02.000000000 +0200 ++++ lsof_4.78C-rh/main.c 2007-10-03 12:15:57.000000000 +0200 +@@ -84,14 +84,20 @@ main(argc, argv) + int version = 0; + int xover = 0; + +-#if defined(HASSELINUX) +- cntxlist_t *cntxp; +-#endif /* defined(HASSELINUX) */ +- + #if defined(HASZONES) + znhash_t *zp; + #endif /* defined(HASZONES) */ + ++#if defined(HASSELINUX) ++/* ++ * This stanza must be immediately before the "Save progam name." code, since ++ * it contains code itself. ++ */ ++ cntxlist_t *cntxp; ++ ++ CntxStatus = is_selinux_enabled() ? 1 : 0; ++#endif /* defined(HASSELINUX) */ ++ + /* + * Save program name. + */ +@@ -414,7 +420,10 @@ main(argc, argv) + continue; + #endif /* !defined(HASZONES) */ + +-#if !defined(HASSELINUX) ++#if defined(HASSELINUX) ++ if ((FieldSel[i].id == LSOF_FID_CNTX) && !CntxStatus) ++ continue; ++#else /* !defined(HASSELINUX) */ + if (FieldSel[i].id == LSOF_FID_CNTX) + continue; + #endif /* !defined(HASSELINUX) */ +@@ -822,7 +831,7 @@ main(argc, argv) + + #if defined(HASSELINUX) + case 'Z': +- if (!is_selinux_enabled()) { ++ if (!CntxStatus) { + (void) fprintf(stderr, "%s: -Z limited to SELinux\n", Pn); + err = 1; + } else { +diff -up lsof_4.78C-rh/lsof.h.selinux lsof_4.78C-rh/lsof.h +--- lsof_4.78C-rh/lsof.h.selinux 2006-06-12 19:10:02.000000000 +0200 ++++ lsof_4.78C-rh/lsof.h 2007-10-03 12:15:57.000000000 +0200 +@@ -548,6 +548,7 @@ typedef struct cntxlist { + struct cntxlist *next; /* next zone hash entry */ + } cntxlist_t; + extern cntxlist_t *CntxArg; ++extern int CntxStatus; + # endif /* defined(HASSELINUX) */ + + # if defined(HASDCACHE) diff --git a/lsof_4.78C-threads.patch b/lsof_4.78C-threads.patch new file mode 100644 index 0000000..6f28078 --- /dev/null +++ b/lsof_4.78C-threads.patch @@ -0,0 +1,128 @@ +--- lsof_4.78C-rh/dialects/linux/dproc.c.kzak 2006-06-12 19:10:05.000000000 +0200 ++++ lsof_4.78C-rh/dialects/linux/dproc.c 2006-08-10 00:14:23.000000000 +0200 +@@ -69,7 +69,8 @@ + _PROTOTYPE(static int read_proc_stat,(char *p, int pid, char **cmd, int *ppid, + int *pgid)); + _PROTOTYPE(static int statEx,(char *p, struct stat *s, int *ss)); +- ++_PROTOTYPE(static int get_other_thread,(int pid, char **tid)); ++ + + #if defined(HASSELINUX) + _PROTOTYPE(static int cmp_cntx_eq,(char *pcntx, char *ucntx)); +@@ -148,6 +149,7 @@ + static char *path = (char *)NULL; + static int pathl = 0; + int pgid, pid, ppid; ++ char *tid = NULL; + static char *pidpath = (char *)NULL; + static MALLOC_S pidpathl = 0; + static MALLOC_S pidx = 0; +@@ -253,6 +255,13 @@ + } + if (f) + continue; ++ ++ tid = NULL; ++ if (get_other_thread(pid, &tid) < 0) ++ continue; ++ if (tid) ++ n += sizeof("task/") + strlen(tid); ++ + /* + * Build path to PID's directory. + */ +@@ -266,7 +275,14 @@ + Exit(1); + } + } +- (void) snpf(pidpath + pidx, pidpathl - pidx, "%s/", dp->d_name); ++ if (tid) { ++ /* /proc/ is useless (zombie), we have to use /proc//task/ ++ * where is still running thread ++ */ ++ (void) snpf(pidpath + pidx, pidpathl - pidx, "%s/task/%s/", dp->d_name, tid); ++ free(tid); ++ } else ++ (void) snpf(pidpath + pidx, pidpathl - pidx, "%s/", dp->d_name); + n += (pidx + 1); + /* + * Process the PID's stat info. +@@ -897,6 +913,64 @@ + (void) fclose(ms); + } + ++/* fill tid if the initial thread is zombie, ++ * but other thread still alive ++ * ++ * returns -1=error, 0=nothing, 1=ok ++ */ ++static int ++get_other_thread(pid, tid) ++ int pid; ++ char **tid; ++{ ++ char path[MAXPATHLEN]; ++ DIR *tdp; ++ struct dirent *td; ++ char pstate; ++ FILE *f; ++ int _pid; ++ int re = 0, x; ++ ++ snpf(path, sizeof(path), "%s/%d/stat", PROCFS, pid); ++ if (!(f = fopen(path, "r"))) ++ return -1; ++ x = fscanf(f, "%d %*s %c", &_pid, &pstate); ++ fclose(f); ++ if (x!=2) ++ return -1; ++ if (_pid != pid) ++ return -1; /* corrupted /proc? */ ++ if (pstate!='Z') ++ return 0; /* ignore normal proceses */ ++ ++ snpf(path, sizeof(path), "%s/%d/task", PROCFS, pid); ++ ++ /* open /proc//task */ ++ if (!(tdp = opendir(path))) ++ return 0; /* kernel < 2.6.x */ ++ ++ /* look for first alive thread */ ++ while ((td = readdir(tdp))) { ++ if (strcmp(td->d_name, ".")==0 || strcmp(td->d_name, "..")==0) ++ continue; ++ ++ /* /proc//task//stat */ ++ snpf(path, sizeof(path), "%s/%d/task/%s/stat", PROCFS, pid, td->d_name); ++ if (!(f = fopen(path, "r"))) ++ continue; ++ x = fscanf(f, "%*d %*s %c", &pstate); ++ fclose(f); ++ if (x!=1) ++ continue; ++ if (pstate!='Z') { ++ re = 1; ++ *tid = strdup(td->d_name); ++ break; ++ } ++ } ++ closedir(tdp); ++ return re; ++} + + /* + * read_proc_stat() - read process status +@@ -931,12 +1005,6 @@ + if ((nf = get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0)) < 5) + return(1); + /* +- * Convert the first field to an integer; its conversion must match the +- * PID argument. +- */ +- if (atoi(fp[0]) != pid) +- return(1); +-/* + * Get the command name from the second field. Strip a starting '(' and + * an ending ')'. Allocate space to hold the result and return the space + * pointer. diff --git a/sources b/sources index 339a190..4658793 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (lsof-4.98.0-rh.tar.xz) = a0938c4c431d2aed7ce7e09560b45acefb5c2730c707817b3013f564defa381391ee113e7989fc21eec4703f4ac112104ec0edd9d51a024797116416a4717683 +6a604dacc4544486634d5421f7d6d31b lsof_4.78C-rh.tar.bz2 diff --git a/upstream2downstream.sh b/upstream2downstream.sh index 0dd7b87..4ef3e89 100755 --- a/upstream2downstream.sh +++ b/upstream2downstream.sh @@ -1,12 +1,10 @@ #!/bin/bash # -# This script removes non-linux dialects from upstream source package before -# release. There is a problem with copyrights for some UN*Xes ... also .. this -# script merges all to the one normal tarball and rename all to lsof_X.XX-rh. +# This script removes non-linux dialects from upstream source package before release. +# There is a problem with copyrights for some UN*Xes ... also .. this script merges all +# to the one normal tarball and rename all to lsof_X.XX-rh. # # Usage: ./upstream2downstream -# -# This code is in the public domain; do with it what you wish. # # Copyright (C) 2007 Karel Zak # @@ -18,28 +16,28 @@ TMP=$(mktemp -d) echo echo -n "Extracting upstream code..." -tar -xf $UPSTREAM -C $TMP +tar -zxf $UPSTREAM -C $TMP cd $TMP/$NAME +tar xf "$NAME"_src.tar +echo " done." + +echo -n "Moving files to downstream directory..." +mv "$NAME"_src/ "$NAME"-rh +mv README* 00* "$NAME"-rh echo " done." echo -n "Removing non-Linux dialects..." -rm -rf ./dialects/{aix,darwin,du,freebsd,hpux,n+obsd,n+os,osr,sun,uw} -echo " done." - -echo -n "Removing unused distribution scripts..." -rm -rf ./support +rm -rf "$NAME"-rh/dialects/{aix,darwin,du,freebsd,hpux,n+obsd,n+os,osr,sun,uw} echo " done." echo -n "Creating final downstream tarball..." -cd .. -mv $NAME $NAME-rh -tar Jcf $MYPWD/"$NAME"-rh.tar.xz "$NAME"-rh +tar jcf $MYPWD/"$NAME"-rh.tar.bz2 "$NAME"-rh echo " done." rm -rf $TMP cd $MYPWD echo -echo "Linux-only tarball: $MYPWD/"$NAME"-rh.tar.xz" +echo "Linux-only tarball: $MYPWD/"$NAME"-rh.tar.bz2" echo