summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-11-22 03:36:44 +0000
committerMike Frysinger <vapier@gentoo.org>2005-11-22 03:36:44 +0000
commite10be983d17b885763322e271ab870fe1a7531ac (patch)
treea6f490a4d8cd2625aaa6e750bdff57f574ae05d8 /sys-process
parentHelping ce^H^Hclean up old Perl ebuilds. Version bump. (diff)
downloadgentoo-2-e10be983d17b885763322e271ab870fe1a7531ac.tar.gz
gentoo-2-e10be983d17b885763322e271ab870fe1a7531ac.tar.bz2
gentoo-2-e10be983d17b885763322e271ab870fe1a7531ac.zip
Grabbed updates from upstream cvs to control ipv6 support #113212.
(Portage version: 2.0.53_rc7)
Diffstat (limited to 'sys-process')
-rw-r--r--sys-process/psmisc/ChangeLog6
-rw-r--r--sys-process/psmisc/files/psmisc-21.8-ipv6.patch418
-rw-r--r--sys-process/psmisc/psmisc-21.8.ebuild6
3 files changed, 427 insertions, 3 deletions
diff --git a/sys-process/psmisc/ChangeLog b/sys-process/psmisc/ChangeLog
index 7ea00676fe19..5fdd28bf1bf1 100644
--- a/sys-process/psmisc/ChangeLog
+++ b/sys-process/psmisc/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for sys-process/psmisc
# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-process/psmisc/ChangeLog,v 1.17 2005/11/18 00:48:27 pebenito Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-process/psmisc/ChangeLog,v 1.18 2005/11/22 03:36:44 vapier Exp $
+
+ 22 Nov 2005; Mike Frysinger <vapier@gentoo.org>
+ +files/psmisc-21.8-ipv6.patch, psmisc-21.8.ebuild:
+ Grabbed updates from upstream cvs to control ipv6 support #113212.
18 Nov 2005; Chris PeBenito <pebenito@gentoo.org> psmisc-21.8.ebuild:
Remove SELinux patching as support is now integrated upstream.
diff --git a/sys-process/psmisc/files/psmisc-21.8-ipv6.patch b/sys-process/psmisc/files/psmisc-21.8-ipv6.patch
new file mode 100644
index 000000000000..074f684ee434
--- /dev/null
+++ b/sys-process/psmisc/files/psmisc-21.8-ipv6.patch
@@ -0,0 +1,418 @@
+http://bugs.gentoo.org/113212
+
+--- src/fuser.c
++++ src/fuser.c
+@@ -66,6 +66,7 @@ static dev_t get_netdev(void);
+ int parse_mount(struct names *this_name, struct device_list **dev_list);
+ static void add_device(struct device_list **dev_list, struct names *this_name, dev_t device);
+ void scan_mount_devices(const opt_type opts, struct mountdev_list **mount_devices);
++void scan_unixsockets(struct unixsocket_list **unixsocket_head);
+ #ifdef DEBUG
+ static void debug_match_lists(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head);
+ #endif
+@@ -94,8 +95,10 @@ static void usage (const char *errormsg)
+ " -u display user IDs\n"
+ " -v verbose output\n"
+ " -V display version information\n"
++#ifdef WITH_IPV6
+ " -4 search IPv4 sockets only\n"
+ " -6 search IPv6 sockets only\n"
++#endif
+ " - reset options\n\n"
+ " udp/tcp names: [local_port][,[rmt_host][,[rmt_port]]]\n\n"));
+ exit (1);
+@@ -228,6 +231,7 @@ static void add_ip_conn(struct ip_connec
+ *ip_list = ip_tmp;
+ }
+
++#ifdef WITH_IPV6
+ static void add_ip6_conn(struct ip6_connections **ip_list, const char *protocol, struct names *this_name, const int lcl_port, const int rmt_port, struct in6_addr rmt_address)
+ {
+ struct ip6_connections *ip_tmp, *ip_head;
+@@ -244,6 +248,7 @@ static void add_ip6_conn(struct ip6_conn
+
+ *ip_list = ip_tmp;
+ }
++#endif
+
+ static void add_matched_proc(struct names *name_list, const pid_t pid, const uid_t uid, const char access)
+ {
+@@ -322,6 +329,19 @@ int parse_file(struct names *this_name,
+ return 0;
+ }
+
++int parse_unixsockets(struct names *this_name, struct inode_list **ino_list, struct unixsocket_list *sun_head)
++{
++ struct unixsocket_list *sun_tmp;
++
++ for (sun_tmp = sun_head; sun_tmp != NULL ; sun_tmp = sun_tmp->next)
++ {
++ if (strcmp(this_name->filename, sun_tmp->sun_name) == 0) {
++ add_inode(ino_list, this_name, sun_tmp->dev, sun_tmp->inode);
++ }
++ }
++ return 0;
++}
++
+ int parse_mounts(struct names *this_name, struct mountdev_list *mounts, struct device_list **dev_list, const char opts)
+ {
+ struct stat st;
+@@ -347,7 +369,11 @@ int parse_mounts(struct names *this_name
+ return 0;
+ }
+
++#ifdef WITH_IPV6
+ int parse_inet(struct names *this_name, const int ipv6_only, const int ipv4_only, struct ip_connections **ip_list, struct ip6_connections **ip6_list)
++#else
++int parse_inet(struct names *this_name, struct ip_connections **ip_list)
++#endif
+ {
+ struct addrinfo *res, *resptr;
+ struct addrinfo hints;
+@@ -355,7 +381,9 @@ int parse_inet(struct names *this_name,
+ char *lcl_port_str, *rmt_addr_str, *rmt_port_str, *tmpstr, *tmpstr2;
+ in_port_t lcl_port;
+ struct sockaddr_in *sin;
++#ifdef WITH_IPV6
+ struct sockaddr_in6 *sin6;
++#endif
+ char hostspec[100];
+ char *protocol;
+ int i;
+@@ -402,12 +430,16 @@ int parse_inet(struct names *this_name,
+ /*printf("parsed to lp %s rh %s rp %s\n", lcl_port_str, rmt_addr_str, rmt_port_str);*/
+
+ memset(&hints, 0, sizeof(hints));
++#ifdef WITH_IPV6
+ if (ipv6_only) {
+ hints.ai_family = PF_INET6;
+ } else if (ipv4_only) {
+ hints.ai_family = PF_INET;
+ } else
+ hints.ai_family = PF_UNSPEC;
++#else
++ hints.ai_family = PF_INET;
++#endif
+ if (strcmp(protocol, "tcp") == 0)
+ hints.ai_socktype = SOCK_STREAM;
+ else
+@@ -428,9 +460,11 @@ int parse_inet(struct names *this_name,
+ case AF_INET:
+ lcl_port = ((struct sockaddr_in*)(res->ai_addr))->sin_port;
+ break;
++#ifdef WITH_IPV6
+ case AF_INET6:
+ lcl_port = ((struct sockaddr_in6*)(res->ai_addr))->sin6_port;
+ break;
++#endif
+ default:
+ fprintf(stderr, _("Unknown local port AF %d\n"), res->ai_family);
+ freeaddrinfo(res);
+@@ -442,7 +476,9 @@ int parse_inet(struct names *this_name,
+ res = NULL;
+ if (rmt_addr_str == NULL && rmt_port_str == NULL) {
+ add_ip_conn(ip_list, protocol, this_name, ntohs(lcl_port), 0, INADDR_ANY);
++#ifdef WITH_IPV6
+ add_ip6_conn(ip6_list, protocol,this_name, ntohs(lcl_port), 0, in6addr_any);
++#endif
+ return 0;
+ } else {
+ /* Resolve remote address and port */
+@@ -453,10 +489,12 @@ int parse_inet(struct names *this_name,
+ sin = (struct sockaddr_in*)resptr->ai_addr;
+ add_ip_conn(ip_list, protocol, this_name, ntohs(lcl_port), ntohs(sin->sin_port), sin->sin_addr.s_addr);
+ break;
++#ifdef WITH_IPV6
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6*)resptr->ai_addr;
+ add_ip6_conn(ip6_list, protocol, this_name, ntohs(lcl_port), ntohs(sin6->sin6_port), sin6->sin6_addr);
+ break;
++#endif
+ }
+ } /*while */
+ return 0;
+@@ -481,7 +519,7 @@ void find_net_sockets(struct inode_list
+ return ;
+
+ if ( (fp = fopen(pathname, "r")) == NULL) {
+- fprintf(stderr, _("Cannot open protocol file: %s"), strerror(errno));
++ fprintf(stderr, _("Cannot open protocol file \"%s\": %s"), pathname,strerror(errno));
+ return;
+ }
+ while (fgets(line, BUFSIZ, fp) != NULL) {
+@@ -512,6 +550,7 @@ void find_net_sockets(struct inode_list
+ return ;
+ }
+
++#ifdef WITH_IPV6
+ void find_net6_sockets(struct inode_list **ino_list, struct ip6_connections *conn_list, const char *protocol, const dev_t netdev)
+ {
+ FILE *fp;
+@@ -565,38 +606,48 @@ void find_net6_sockets(struct inode_list
+ }
+ }
+ }
++#endif
+
+ int main(int argc, char *argv[])
+ {
+ opt_type opts;
+ int sig_number;
++#ifdef WITH_IPV6
+ int ipv4_only, ipv6_only;
++#endif
+ unsigned char default_namespace = NAMESPACE_FILE;
+ struct mountdev_list *mount_devices = NULL;
+ struct device_list *match_devices = NULL;
++ struct unixsocket_list *unixsockets = NULL;
+
+ dev_t netdev;
+ struct ip_connections *tcp_connection_list = NULL;
+ struct ip_connections *udp_connection_list = NULL;
++#ifdef WITH_IPV6
+ struct ip6_connections *tcp6_connection_list = NULL;
+ struct ip6_connections *udp6_connection_list = NULL;
++#endif
+ struct inode_list *match_inodes = NULL;
+ struct names *names_head, *this_name, *names_tail;
+- int optc, option;
++ int optc;
++ char *option;
+ char *nsptr;
+
++#ifdef WITH_IPV6
+ ipv4_only = ipv6_only = 0;
++#endif
+ names_head = this_name = names_tail = NULL;
+ opts = 0;
+ sig_number = SIGKILL;
+
+ netdev = get_netdev();
+ scan_mount_devices(opts, &mount_devices);
++ scan_unixsockets(&unixsockets);
+
+ /* getopt doesnt like things like -SIGBLAH */
+ for(optc = 1; optc < argc; optc++) {
+ if (argv[optc][0] == '-') { /* its an option */
+- option=argv[optc][1];
++ option=argv[optc] + 1;
+ if (argv[optc][1] == '-') { /* its a long option */
+ if (argv[optc][2] == '\0') {
+ continue;
+@@ -604,13 +655,15 @@ int main(int argc, char *argv[])
+ /* FIXME longopts */
+ continue;
+ }
+- switch(argv[optc][1]) {
++ while (*option) switch(*option++) {
++#ifdef WITH_IPV6
+ case '4':
+ ipv4_only = 1;
+ break;
+ case '6':
+ ipv6_only = 1;
+ break;
++#endif
+ case 'a':
+ opts |= OPT_ALLFILES;
+ break;
+@@ -662,8 +715,8 @@ int main(int argc, char *argv[])
+ print_version();
+ return 0;
+ default:
+- if ( isupper(argv[optc][1]) || isdigit(argv[optc][1])) {
+- sig_number = get_signal(argv[optc]+1,"fuser");
++ if ( isupper(*option) || isdigit(*option) ) {
++ sig_number = get_signal(option,"fuser");
+ break;
+ }
+ fprintf(stderr,"%s: Invalid option %c\n",argv[0] , argv[optc][1]);
+@@ -703,15 +756,24 @@ int main(int argc, char *argv[])
+ switch(this_name->name_space) {
+ case NAMESPACE_TCP:
+ asprintf(&(this_name->filename), "%s/tcp", argv[optc]);
++#ifdef WITH_IPV6
+ parse_inet(this_name, ipv4_only, ipv6_only, &tcp_connection_list, &tcp6_connection_list);
++#else
++ parse_inet(this_name, &tcp_connection_list);
++#endif
+ break;
+ case NAMESPACE_UDP:
+ asprintf(&(this_name->filename), "%s/udp", argv[optc]);
++#ifdef WITH_IPV6
+ parse_inet(this_name, ipv4_only, ipv6_only, &tcp_connection_list, &tcp6_connection_list);
++#else
++ parse_inet(this_name, &tcp_connection_list);
++#endif
+ break;
+ default: /* FILE */
+ this_name->filename = strdup(argv[optc]);
+ parse_file(this_name, &match_inodes);
++ parse_unixsockets(this_name, &match_inodes, unixsockets);
+ if (opts & OPT_MOUNTPOINT || opts & OPT_MOUNTS)
+ parse_mounts(this_name, mount_devices, &match_devices, opts);
+ break;
+@@ -733,13 +795,16 @@ int main(int argc, char *argv[])
+ if (opts & OPT_ALLFILES)
+ usage(_("all option cannot be used with silent option."));
+ }
++#ifdef WITH_IPV6
+ if (ipv4_only && ipv6_only)
+ usage(_("You cannot search for only IPv4 and only IPv6 sockets at the same time"));
+ if (!ipv4_only) {
++#endif
+ if (tcp_connection_list != NULL)
+ find_net_sockets(&match_inodes, tcp_connection_list, "tcp",netdev);
+ if (udp_connection_list != NULL)
+ find_net_sockets(&match_inodes, udp_connection_list, "udp",netdev);
++#ifdef WITH_IPV6
+ }
+ if (!ipv6_only) {
+ if (tcp6_connection_list != NULL)
+@@ -747,6 +812,7 @@ int main(int argc, char *argv[])
+ if (udp6_connection_list != NULL)
+ find_net6_sockets(&match_inodes, udp6_connection_list, "udp",netdev);
+ }
++#endif
+ #ifdef DEBUG
+ debug_match_lists(names_head, match_inodes, match_devices);
+ #endif
+@@ -761,25 +827,27 @@ static int print_matches(struct names *n
+ {
+ struct names *nptr;
+ struct procs *pptr;
+- char first;
+- int len;
++ char head = 0;
++ char first = 1;
++ int len = 0;
+ struct passwd *pwent = NULL;
+- int have_match = 1;
+-
++ int have_match = 0;
+
+- if (opts & OPT_VERBOSE)
+- fprintf(stderr, _("\n%*s USER PID ACCESS COMMAND\n"),
+- NAME_FIELD, "");
+ for (nptr = names_head; nptr != NULL ; nptr = nptr->next) {
+- fprintf(stderr, "%s", nptr->filename);
+- first = 1;
+- len = strlen(nptr->filename);
+- if (!(opts & OPT_VERBOSE)) {
+- putc(':', stderr);
+- len++;
++ if (nptr->matched_procs != NULL || opts & OPT_ALLFILES) {
++ if (head == 0 && opts & OPT_VERBOSE) {
++ fprintf(stderr, _("\n%*s USER PID ACCESS COMMAND\n"),
++ NAME_FIELD, "");
++ head = 1;
++ }
++
++ fprintf(stderr, "%s:", nptr->filename);
++ len = strlen(nptr->filename) + 1;
+ }
++
++ first = 1;
+ for (pptr = nptr->matched_procs; pptr != NULL ; pptr = pptr->next) {
+- have_match = 0;
++ have_match = 1;
+ if (opts & (OPT_VERBOSE|OPT_USER)) {
+ if (pwent == NULL || pwent->pw_uid != pptr->uid)
+ pwent = getpwuid(pptr->uid);
+@@ -831,13 +899,13 @@ static int print_matches(struct names *n
+ len = 0;
+ first = 0;
+ }
+- if (nptr->matched_procs == NULL || !(opts & OPT_VERBOSE))
++ if (nptr->matched_procs != NULL || opts & OPT_ALLFILES)
+ putc('\n', stderr);
+ if (opts & OPT_KILL)
+ kill_matched_proc(nptr->matched_procs, opts, sig_number);
+
+ } /* next name */
+- return have_match;
++ return !have_match;
+
+ }
+
+@@ -960,6 +1028,44 @@ void add_mount_device(struct mountdev_li
+ }
+
+ /*
++ * scan_unixsockets : Create a list of Unix sockets
++ * This list is used later for matching purposes
++ */
++void scan_unixsockets(struct unixsocket_list **unixsocket_head)
++{
++ FILE *fp;
++ char line[BUFSIZ];
++ char *scanned_path;
++ int scanned_inode;
++ struct stat st;
++ struct unixsocket_list *newsocket;
++
++ if ( (fp = fopen("/proc/net/unix","r")) == NULL) {
++ fprintf(stderr, _("Cannot open /proc/net/unix: %s\n"),
++ strerror(errno));
++ return;
++ }
++ while (fgets(line, BUFSIZ, fp) != NULL) {
++ if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %as",
++ &scanned_inode,
++ &scanned_path) != 2)
++ continue;
++ if (stat(scanned_path, &st) < 0) {
++ free(scanned_path);
++ continue;
++ }
++ if ( (newsocket = malloc(sizeof(struct unixsocket_list))) == NULL)
++ continue;
++ newsocket->sun_name = strdup(scanned_path);
++ newsocket->inode = scanned_inode; /* st.st_ino;*/
++ newsocket->dev = 0; /* st.st_dev;*/
++ newsocket->next = *unixsocket_head;
++ *unixsocket_head = newsocket;
++ } /* while */
++
++}
++
++/*
+ * scan_mount_devices : Create a list of mount points and devices
+ * This list is used later for matching purposes
+ */
+@@ -1001,7 +1107,7 @@ static void debug_match_lists(struct nam
+ struct inode_list *iptr;
+ struct device_list *dptr;
+
+- fprintf(stderr,"Names:\n");
++ fprintf(stderr,"Specified Names:\n");
+ for (nptr=names_head; nptr!= NULL; nptr=nptr->next)
+ {
+ fprintf(stderr, "\t%s %c\n", nptr->filename, nptr->name_space);
+@@ -1009,8 +1115,8 @@ static void debug_match_lists(struct nam
+ fprintf(stderr,"\nInodes:\n");
+ for (iptr=ino_head; iptr!=NULL; iptr=iptr->next)
+ {
+- fprintf(stderr, "\tDev:%0lx Inode:%0lx\n",
+- (unsigned long)iptr->device, (unsigned long)iptr->inode);
++ fprintf(stderr, " Dev:%0lx Inode:(%0ld) 0x%0lx => %s\n",
++ (unsigned long)iptr->device, (unsigned long)iptr->inode, (unsigned long)iptr->inode, iptr->name->filename);
+ }
+ fprintf(stderr,"\nDevices:\n");
+ for (dptr=dev_head; dptr!=NULL; dptr=dptr->next)
+--- src/fuser.h
++++ src/fuser.h
+@@ -72,6 +72,13 @@ struct device_list {
+ struct device_list *next;
+ };
+
++struct unixsocket_list {
++ char *sun_name;
++ ino_t inode;
++ dev_t dev;
++ struct unixsocket_list *next;
++};
++
+ #define NAMESPACE_FILE 0
+ #define NAMESPACE_TCP 1
+ #define NAMESPACE_UDP 2
diff --git a/sys-process/psmisc/psmisc-21.8.ebuild b/sys-process/psmisc/psmisc-21.8.ebuild
index dfc4228ca91d..c9457ee22329 100644
--- a/sys-process/psmisc/psmisc-21.8.ebuild
+++ b/sys-process/psmisc/psmisc-21.8.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-process/psmisc/psmisc-21.8.ebuild,v 1.2 2005/11/18 00:48:27 pebenito Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-process/psmisc/psmisc-21.8.ebuild,v 1.3 2005/11/22 03:36:44 vapier Exp $
inherit eutils
@@ -11,7 +11,7 @@ SRC_URI="mirror://sourceforge/psmisc/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
-IUSE="nls selinux"
+IUSE="ipv6 nls selinux"
RDEPEND=">=sys-libs/ncurses-5.2-r2
selinux? ( sys-libs/libselinux )"
@@ -22,6 +22,8 @@ DEPEND="${RDEPEND}
src_unpack() {
unpack ${A}
cd "${S}"
+ epatch "${FILESDIR}"/${P}-ipv6.patch
+ use ipv6 && echo '#define HAVE_IPV6' >> config.h.in
epunt_cxx #73632
}