freebsd-ports/security/pssh/files/patch-psshlib_psshutil.py
Brooks Davis a4694ad913 Fix a couple bugs and remove the IGNORE variable:
- select can be interrupted and return EINTR so we need to loop around it
   while it does so rather than treating it as a fatal error.
 - all process creations are matched with a wait() so having a SIGCHLD
   handler that performs a wait(-1) is pointless and racy.  We tend to
   loose the race over half the time and as a result were reporting
   successful processes as failed.

Add a couple features:
 - Skip commented lines in the host specification.
 - Allow '-' as an alias for stdin in the host file specification.
2007-07-06 20:30:24 +00:00

43 lines
1.1 KiB
Python

$FreeBSD$
--- psshlib/psshutil.py.orig
+++ psshlib/psshutil.py
@@ -1,22 +1,18 @@
import os, signal, sys
-def reaper(signo, frame):
- while 1:
- try:
- pid, status = os.waitpid(-1, os.WNOHANG)
- except:
- break
- if not pid:
- break
-
def read_hosts(pathname):
"""
Read hostfile with lines of the form: host[:port] [login]. Return
three arrays: hosts, ports, and users. These can be used directly
for all ssh-based commands (e.g., ssh, scp, rsync -e ssh, etc.)
+ Empty lines and lines where the first non-blank character is a
+ '#' character are ignored.
"""
import re
- f = open(pathname)
+ if pathname == "-":
+ f = open("/dev/stdin")
+ else:
+ f = open(pathname)
lines = f.readlines()
lines = map(lambda x: x.strip(), lines)
addrs = []
@@ -24,7 +20,7 @@
ports = []
users = []
for line in lines:
- if re.match("^\s+$", line) or len(line) == 0:
+ if re.match("^\s*(#|$)", line):
continue
fields = re.split("\s", line)
if len(fields) == 1: