[lxc-devel] [PATCH 4/9] lxc-ls: tighten regex search on open sockets
David Ward
david.ward at ll.mit.edu
Mon Mar 5 13:34:56 UTC 2012
lxc-ls returns a list of active containers by searching for UNIX sockets
named '/var/lib/lxc/<name>/command'. Make the regular expression tighter
for this search, to avoid inadvertently picking up other sockets.
Signed-off-by: David Ward <david.ward at ll.mit.edu>
---
src/lxc/lxc-ls.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in
index b923c56..ea68971 100644
--- a/src/lxc/lxc-ls.in
+++ b/src/lxc/lxc-ls.in
@@ -23,8 +23,8 @@ function get_cgroup()
mount_point=`echo "$mount_string" |cut -d' ' -f2`;
}
-active=$(netstat -xl 2>/dev/null | grep $lxcpath | \
- sed -e 's#.*'"$lxcpath/"'\(.*\)/command#\1#');
+active=$(netstat -xl 2>/dev/null | grep "$lxcpath"'/[^/]*/command' | \
+ sed -e 's#.*'"$lxcpath"'/\([^/]*\)/command.*#\1#');
if test -n "$active"; then
get_cgroup
--
1.7.1
More information about the lxc-devel
mailing list