From 611aea92bdace2289611d7802c56b51425dac3ff Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Tue, 5 Oct 2010 14:24:13 -0400 Subject: [PATCH] Add 'no-prompt' to the --trust-servers option to bypass prompting the user for confirmation. --- csclient.cxx | 44 ++++++++++++++++++++++++++++++++------------ stap.1 | 9 +++++++-- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/csclient.cxx b/csclient.cxx index ff5813740..04ff3e034 100644 --- a/csclient.cxx +++ b/csclient.cxx @@ -1125,6 +1125,7 @@ manage_server_trust (systemtap_session &s) // signer - trust the specified servers as module signers // revoke - revoke the requested trust // all-users - apply/revoke the requested trust for all users + // no-prompt - don't prompt the user for confirmation vectorcomponents; tokenize (s.server_trust_spec, components, ","); bool ssl = false; @@ -1132,6 +1133,7 @@ manage_server_trust (systemtap_session &s) bool revoke = false; bool all_users = false; bool error = false; + bool no_prompt = false; for (vector::const_iterator i = components.begin (); i != components.end (); ++i) @@ -1160,6 +1162,8 @@ manage_server_trust (systemtap_session &s) else all_users = true; } + else if (*i == "no-prompt") + no_prompt = true; else cerr << "Warning: Unrecognized server trust specification: " << *i << endl; @@ -1216,22 +1220,38 @@ manage_server_trust (systemtap_session &s) } // Prompt the user to confirm what's about to happen. - if (revoke) - clog << "Revoke trust "; + if (no_prompt) + { + if (revoke) + clog << "Revoking trust "; + else + clog << "Adding trust "; + } else - clog << "Add trust "; - clog << "in the following servers " << trustString.str () << '?' << endl; + { + if (revoke) + clog << "Revoke trust "; + else + clog << "Add trust "; + } + clog << "in the following servers " << trustString.str (); + if (! no_prompt) + clog << '?'; + clog << endl; for (unsigned i = 0; i < limit; ++i) clog << " " << server_list[i] << endl; - clog << "[y/N] " << flush; - - // Only carry out the operation if the response is "yes" - string response; - cin >> response; - if (response[0] != 'y' && response [0] != 'Y') + if (! no_prompt) { - clog << "Server trust unchanged" << endl; - return; + clog << "[y/N] " << flush; + + // Only carry out the operation if the response is "yes" + string response; + cin >> response; + if (response[0] != 'y' && response [0] != 'Y') + { + clog << "Server trust unchanged" << endl; + return; + } } // Now add/revoke the requested trust. diff --git a/stap.1 b/stap.1 index aabe9a2d3..d8dc41a1f 100644 --- a/stap.1 +++ b/stap.1 @@ -191,7 +191,7 @@ ldd to be necessary for user-space binaries being probe or listed with the \-d option. Caution: this can make the probe modules considerably larger. .TP -.BI \-\-all-modules +.BI \-\-all\-modules Equivalent to specifying "-dkernel" and a "-d" for each kernel module that is currently loaded. Caution: this can make the probe modules considerably larger. @@ -369,6 +369,10 @@ signer is always granted for all users. Only root can specify .TP .BI revoke revoke the specified trust. The default is to grant it. +.TP +.BI no\-prompt +do not prompt the user for confirmation before carrying out the requested +action. The default is to prompt the user for confirmation. .RE If no argument is provided, then the default is @@ -377,7 +381,8 @@ If no servers were specified using .IR \-\-use\-server , then no trust will be granted or revoked. -The user will be prompted to confirm the trust to be granted or revoked before +Unless \fBno\-prompt\fR has been specified, +the user will be prompted to confirm the trust to be granted or revoked before the operation is performed. .SH ARGUMENTS -- 2.43.5