From 22e6c2c57d310d9c9312adf958b3f1d6dada267c Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Wed, 8 Oct 2014 15:04:57 -0700 Subject: [PATCH] Allow the filter agent's bind address to be specified Add an additional command-line option (-b / --bind) that can be used to specify an alternate path for the filter agent's UNIX domain socket. --- ssh-agent-filter.C | 3 ++- ssh-agent-filter.bash-completion | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ssh-agent-filter.C b/ssh-agent-filter.C index faa31f9..f36b44c 100644 --- a/ssh-agent-filter.C +++ b/ssh-agent-filter.C @@ -196,6 +196,7 @@ int make_listen_sock () { void parse_cmdline (int const argc, char const * const * const argv) { po::options_description opts{"OPTIONS"}; opts.add_options() + ("bind,b", po::value(&path), "bind address specified by filesystem path") ("all-confirmed,A", po::bool_switch(&all_confirmed),"allow all other keys with confirmation") ("comment,c", po::value(&allowed_comment), "key specified by comment") ("comment-confirmed,C", po::value(&confirmed_comment), "key specified by comment, with confirmation") @@ -518,11 +519,11 @@ void sighandler (int sig) { } int main (int const argc, char const * const * const argv) { + path = fs::current_path() / ("agent." + std::to_string(getpid())); parse_cmdline(argc, argv); setup_filters(); - path = fs::current_path() / ("agent." + std::to_string(getpid())); int listen_sock = make_listen_sock(); if (not debug) { diff --git a/ssh-agent-filter.bash-completion b/ssh-agent-filter.bash-completion index 61debb9..976de27 100644 --- a/ssh-agent-filter.bash-completion +++ b/ssh-agent-filter.bash-completion @@ -23,9 +23,13 @@ _ssh-agent-filter () { _quote_readline_by_ref "$cur" cur - opts="--all-confirmed --comment --comment-confirmed --debug --fingerprint --fingerprint-confirmed --help --key --key-confirmed --name --version" + opts="--all-confirmed --bind --comment --comment-confirmed --debug --fingerprint --fingerprint-confirmed --help --key --key-confirmed --name --version" case "$prev" in + -b|--bind) + COMPREPLY=() + return 0 + ;; -c|--comment|-C|--comment-confirmed) # hm, key comments might contain anything, how can I quote them ? local comments="$(ssh-add -L | cut -d\ -f3- )" @@ -52,7 +56,7 @@ _ssh-agent-filter () { COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) return 0 -} && complete -F _ssh-agent-filter ssh-agent-filter +} && complete -o default -F _ssh-agent-filter ssh-agent-filter _ssh-agent-filter_have_dash-dash () { local i