commit 4224df7c26f18821719f9e657cc3e9fbfd5aa6ca Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 11:02:50 2019 -0400 Package init diff --git a/0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch b/0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch new file mode 100644 index 0000000..b927684 --- /dev/null +++ b/0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch @@ -0,0 +1,82 @@ +From 7360d80e08abf18dcce61fe033de548ac2378f06 Mon Sep 17 00:00:00 2001 +From: kangenbo +Date: Wed, 17 Apr 2019 12:20:39 -0400 +Subject: [PATCH 50/83] endpoint(pipe),fix: list the same fd in a different process + +Description: backport patch from github, see following in details: +https://github.com/lsof-org/lsof-linux/commit/28f96d5875086d92b5f1cb3f3473ac1184cf155e +--- + dialects/linux/dnode.c | 7 +++++-- + proc.c | 4 ++-- + proto.h | 2 +- + 3 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c +index 58288d6..ddd99cf 100644 +--- a/dialects/linux/dnode.c ++++ b/dialects/linux/dnode.c +@@ -383,13 +383,15 @@ is_pty_ptmx(dev) + */ + + pxinfo_t * +-find_pepti(lf, pp) ++find_pepti(pid, lf, pp) ++ int pid; /* pid of the process owning lf */ + struct lfile *lf; /* pipe's lfile */ + pxinfo_t *pp; /* previous pipe info (NULL == none) */ + { + struct lfile *ef; /* pipe end local file structure */ + int h; /* hash result */ + pxinfo_t *pi; /* pipe info pointer */ ++ struct lproc *ep; + + if (Pinfo) { + if (pp) +@@ -401,7 +403,8 @@ find_pepti(lf, pp) + while (pi) { + if (pi->ino == lf->inode) { + ef = pi->lf; +- if (strcmp(lf->fd, ef->fd)) ++ ep = &Lproc[pi->lpx]; ++ if ((strcmp(lf->fd, ef->fd)) || (pid != ep->pid)) + return(pi); + } + pi = pi->next; +diff --git a/proc.c b/proc.c +index 34cb4b8..e4c3591 100644 +--- a/proc.c ++++ b/proc.c +@@ -992,7 +992,7 @@ process_pinfo(f) + * its being a pipe. Look up the pipe's endpoints. + */ + do { +- if ((pp = find_pepti(Lf, pp))) { ++ if ((pp = find_pepti(Lp->pid, Lf, pp))) { + + /* + * This pipe endpoint is linked to the selected pipe +@@ -1033,7 +1033,7 @@ process_pinfo(f) + Lf->sf = Selflags; + Lp->pss |= PS_SEC; + do { +- if ((pp = find_pepti(Lf, pp))) { ++ if ((pp = find_pepti(Lp->pid, Lf, pp))) { + ep = &Lproc[pp->lpx]; + ef = pp->lf; + for (i = 0; i < (FDLEN - 1); i++) { +diff --git a/proto.h b/proto.h +index 75c74a1..7f65d67 100644 +--- a/proto.h ++++ b/proto.h +@@ -112,7 +112,7 @@ _PROTOTYPE(extern void find_ch_ino,(void)); + + # if defined(HASEPTOPTS) + _PROTOTYPE(extern void clear_pinfo,(void)); +-_PROTOTYPE(extern pxinfo_t *find_pepti,(struct lfile *lf, pxinfo_t *pp)); ++_PROTOTYPE(extern pxinfo_t *find_pepti,(int pid, struct lfile *lf, pxinfo_t *pp)); + _PROTOTYPE(extern void process_pinfo,(int f)); + # if defined(HASUXSOCKEPT) + _PROTOTYPE(extern void clear_uxsinfo,(void)); +-- +1.8.3.1 + diff --git a/0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch b/0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch new file mode 100644 index 0000000..97d19af --- /dev/null +++ b/0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch @@ -0,0 +1,92 @@ +From f8ff9c832d45d44007e936ad3110c227241612d8 Mon Sep 17 00:00:00 2001 +From: kangenbo +Date: Mon, 15 Apr 2019 16:38:23 -0400 +Subject: [PATCH 52/83] endpoint(pty),bug fix: list the same fd in a different process + +Description: This change is simillar to 28f96d58 (endpoint(pipe),fix: list the same +fd in a different process). 28f96d58 is about pipe. This change is about pty. + +Source: backport patch from github, see following in detail: +https://github.com/lsof-org/lsof-linux/commit/cea5e144ee6ac16fd0c82c0a7d25790d5f60b823 + +--- + dialects/linux/dnode.c | 10 +++++----- + proc.c | 4 ++-- + proto.h | 2 +- + 3 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c +index ddd99cf..ee12227 100644 +--- a/dialects/linux/dnode.c ++++ b/dialects/linux/dnode.c +@@ -307,7 +307,8 @@ enter_ptmxi(mn) + */ + + pxinfo_t * +-find_ptyepti(lf, m, pp) ++find_ptyepti(pid, lf, m, pp) ++ int pid; + struct lfile *lf; /* pseudoterminal's lfile */ + int m; /* minor number type: + * 0 == use tty_index +@@ -319,6 +320,7 @@ find_ptyepti(lf, m, pp) + int h; /* hash result */ + INODETYPE mn; /* minor number */ + pxinfo_t *pi; /* pseudoterminal info pointer */ ++ struct lproc *ep; + + + mn = m ? GET_MIN_DEV(lf->rdev) : lf->tty_index; +@@ -332,12 +334,10 @@ find_ptyepti(lf, m, pp) + while (pi) { + if (pi->ino == mn) { + ef = pi->lf; +- if (((m && is_pty_ptmx(ef->rdev)) ++ ep = &Lproc[pi->lpx]; ++ if ((m && is_pty_ptmx(ef->rdev)) + || ((!m) && is_pty_slave(GET_MAJ_DEV(ef->rdev)))) +- && strcmp(lf->fd, ef->fd) +- ) { + return(pi); +- } + } + pi = pi->next; + } +diff --git a/proc.c b/proc.c +index e4c3591..7fe3998 100644 +--- a/proc.c ++++ b/proc.c +@@ -1443,7 +1443,7 @@ process_ptyinfo(f) + */ + pc = 1; + do { +- if ((pp = find_ptyepti(Lf, !mos, pp))) { ++ if ((pp = find_ptyepti(Lp->pid, Lf, !mos, pp))) { + + /* + * This pseudoterminal endpoint is linked to the +@@ -1468,7 +1468,7 @@ process_ptyinfo(f) + Lp->pss |= PS_SEC; + pc = 1; + do { +- if ((pp = find_ptyepti(Lf, !mos, pp))) { ++ if ((pp = find_ptyepti(Lp->pid, Lf, !mos, pp))) { + prt_ptyinfo(pp, (mos && pc), 0); + pp = pp->next; + pc = 0; +diff --git a/proto.h b/proto.h +index 7f65d67..2df360a 100644 +--- a/proto.h ++++ b/proto.h +@@ -122,7 +122,7 @@ _PROTOTYPE(extern void process_uxsinfo,(int f)); + # if defined(HASPTYEPT) + _PROTOTYPE(extern void clear_ptyinfo,(void)); + _PROTOTYPE(extern void enter_ptmxi,(int mn)); +-_PROTOTYPE(extern pxinfo_t *find_ptyepti,(struct lfile *lf,int m,pxinfo_t *pp)); ++_PROTOTYPE(extern pxinfo_t *find_ptyepti,(int pid, struct lfile *lf,int m,pxinfo_t *pp)); + _PROTOTYPE(extern int is_pty_slave,(int sm)); + _PROTOTYPE(extern int is_pty_ptmx,(dev_t dev)); + _PROTOTYPE(extern void process_ptyinfo,(int f)); +-- +1.8.3.1 + diff --git a/0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch b/0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch new file mode 100644 index 0000000..9e3c8b0 --- /dev/null +++ b/0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch @@ -0,0 +1,43 @@ +From abbcbb099008dfed895adbd54d60f10e4129c7aa Mon Sep 17 00:00:00 2001 +From: Masatake YAMATO +Date: Wed, 5 Dec 2018 00:12:06 +0900 +Subject: [PATCH 60/83] endpoint(pseudoterminal),bug fix: fix wrong Unix98 PTY + slaves major number detection + +A typo was in the code detecting Unix98 PTY slave device. + +Signed-off-by: Masatake YAMATO +--- + dialects/linux/dnode.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c +index 68b6a04..fa60557 100644 +--- a/dialects/linux/dnode.c ++++ b/dialects/linux/dnode.c +@@ -354,8 +354,21 @@ int + is_pty_slave(sm) + int sm; /* slave major device number */ + { ++ /* linux/Documentation/admin-guide/devices.txt ++ ------------------------------------------- ++ 136-143 char Unix98 PTY slaves ++ 0 = /dev/pts/0 First Unix98 pseudo-TTY ++ 1 = /dev/pts/1 Second Unix98 pseudo-TTY ++ ... ++ ++ These device nodes are automatically generated with ++ the proper permissions and modes by mounting the ++ devpts filesystem onto /dev/pts with the appropriate ++ mount options (distribution dependent, however, on ++ *most* distributions the appropriate options are ++ "mode=0620,gid=".) */ + if ((UNIX98_PTY_SLAVE_MAJOR <= sm) +- && (sm < (UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_SLAVE_MAJOR)) ++ && (sm < (UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_MAJOR_COUNT)) + ) { + return 1; + } +-- +1.8.3.1 + diff --git a/PATCH-FIX-OPENEULER-man-page-section.patch b/PATCH-FIX-OPENEULER-man-page-section.patch new file mode 100644 index 0000000..e5ca4ea --- /dev/null +++ b/PATCH-FIX-OPENEULER-man-page-section.patch @@ -0,0 +1,12 @@ +diff --git a/Lsof.8 b/Lsof.8 +index 5ad6234..4453fb4 100644 +--- a/Lsof.8 ++++ b/Lsof.8 +@@ -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-4.93.2.tar.gz b/lsof-4.93.2.tar.gz new file mode 100644 index 0000000..adc61a2 Binary files /dev/null and b/lsof-4.93.2.tar.gz differ diff --git a/lsof-tirpc.patch b/lsof-tirpc.patch new file mode 100644 index 0000000..efe343e --- /dev/null +++ b/lsof-tirpc.patch @@ -0,0 +1,11 @@ +--- 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 new file mode 100644 index 0000000..157704f --- /dev/null +++ b/lsof.spec @@ -0,0 +1,52 @@ +Name: lsof +Version: 4.93.2 +Release: 1 +Summary: A tool for list open files +License: zlib and Sendmail and LGPLv2+ +URL: https://people.freebsd.org/~abe/ +Source0: https://github.com/lsof-org/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1: upstream2downstream.sh +Patch0: PATCH-FIX-OPENEULER-man-page-section.patch +Patch6002: 0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch +Patch6003: 0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch +Patch6004: 0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch + +BuildRequires: gcc git libtirpc-devel libselinux-devel + +%description +Lsof is a free, open-source, Unix administrative tool for displays information +about files open to Unix processes. It runs on many Unix dialects. + +%package help +Summary: Doc files for %{name} +BuildArch: noarch + +%description help +The %{name}-help package contains doc files for %{name}. + +%prep +ls +%autosetup -n %{name}-%{version} -p1 -S git + +%build +./Configure -n linux +%make_build DEBUG="%{build_cflags} -I/usr/include/tirpc" CFGL="%{build_ldflags} -L./lib -llsof -lselinux -ltirpc" +#%make_build DEBUG="-I/usr/include/tirpc" CFGL="-L./lib -llsof -lselinux -ltirpc" + +%install +mkdir -p %{buildroot}/%{_bindir} +install -p -m 0755 lsof %{buildroot}/%{_bindir} +mkdir -p %{buildroot}/%{_mandir}/man1 +install -p -m 0644 Lsof.8 %{buildroot}/%{_mandir}/man1/lsof.1 + +%files +%doc 00CREDITS +%{_bindir}/%{name} + +%files help +%doc 00README 00FAQ 00LSOF-L 00QUICKSTART +%{_mandir}/man*/* + +%changelog +* Tue Sep 3 2019 luhuaxin - 4.93.2-1 +- Package init diff --git a/upstream2downstream.sh b/upstream2downstream.sh new file mode 100755 index 0000000..247ee29 --- /dev/null +++ b/upstream2downstream.sh @@ -0,0 +1,45 @@ +#!/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. +# +# Usage: ./upstream2downstream +# +# This code is in the public domain; do with it what you wish. +# +# Copyright (C) 2007 Karel Zak +# + +UPSTREAM="$1" +NAME=$(basename $UPSTREAM .tar.bz2) +MYPWD=$(pwd) +TMP=$(mktemp -d) + +echo +echo -n "Extracting upstream code..." +tar -jxf $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* RELEASE* "$NAME"-rh +echo " done." + +echo -n "Removing non-Linux dialects..." +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..." +tar Jcf $MYPWD/"$NAME"-rh.tar.xz "$NAME"-rh +echo " done." + +rm -rf $TMP +cd $MYPWD + +echo +echo "Linux-only tarball: $MYPWD/"$NAME"-rh.tar.xz" +echo +