summaryrefslogtreecommitdiff
authordwmw2 <dwmw2>2002-09-21 08:42:42 (UTC)
committer dwmw2 <dwmw2>2002-09-21 08:42:42 (UTC)
commit51f94f502b2b9a92d562a3ad726ad58372860c5e (patch) (side-by-side diff)
tree3f587669a6fd91b36a68a37d1c2d3182d92eaab8
parent0bb8b359d20f7d5ead88c260c5560ab7b60358b9 (diff)
downloadopie-51f94f502b2b9a92d562a3ad726ad58372860c5e.zip
opie-51f94f502b2b9a92d562a3ad726ad58372860c5e.tar.gz
opie-51f94f502b2b9a92d562a3ad726ad58372860c5e.tar.bz2
display stderr from ssh-add process too.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sshkeys/sshkeys.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp
index 88acf94..c5e1170 100644
--- a/noncore/settings/sshkeys/sshkeys.cpp
+++ b/noncore/settings/sshkeys/sshkeys.cpp
@@ -39,24 +39,26 @@ static char *keynames[] = { "identity", "id_rsa", "id_dsa" };
SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl )
: SSHKeysBase( parent, name, fl )
{
char *home = getenv("HOME");
unsigned i;
connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton()));
connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton()));
connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton()));
connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)),
this, SLOT(log_sshadd_output(OProcess*,char*,int)));
+ connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(log_sshadd_output(OProcess*,char*,int)));
connect(&addprocess, SIGNAL(processExited(OProcess*)),
this, SLOT(ssh_add_exited(OProcess*)));
connect(KeyFileName, SIGNAL(textChanged(const QString&)),
this, SLOT(add_text_changed(const QString&)));
if (home) {
for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) {
char thiskeyname[32];
thiskeyname[31] = 0;
snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]);
@@ -78,39 +80,40 @@ void SSHKeysApp::doRefreshListButton()
OProcess sshadd_process;
QListViewItem *t = KeyList->firstChild();
while(t) {
QListViewItem *next = t->nextSibling();
KeyList->takeItem(t);
delete(t);
t = next;
}
connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
this, SLOT(get_list_keys_output(OProcess*,char*,int)));
+ connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(log_sshadd_output(OProcess*,char*,int)));
keystate = KeySize;
incoming_keyname="";
incoming_keysize="";
incoming_keyfingerprint="";
// log_text("Running ssh-add -l");
sshadd_process << "ssh-add" << "-l";
bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
if (!ret) {
log_text(tr("Error running ssh-add"));
return;
}
if (sshadd_process.exitStatus() == 2) {
- log_text(tr("Connection to ssh-agent failed"));
setEnabled(FALSE);
}
}
void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen)
{
int i;
(void) proc;
for (i=0; i<buflen; i++) {
switch(keystate) {
case Noise:
@@ -179,27 +182,26 @@ void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen)
(void)proc;
(void)buflen;
log_text(buffer);
}
void SSHKeysApp::ssh_add_exited(OProcess *proc)
{
(void)proc;
doRefreshListButton();
setEnabled(TRUE);
- if (proc->exitStatus()) {
-
- log_text(QString(tr("ssh-add failed")));
+ if (proc->exitStatus() == 2) {
+ setEnabled(FALSE);
}
}
void SSHKeysApp::add_text_changed(const QString &text)
{
struct stat sbuf;
if (!text.length() || (!access(text.ascii(), R_OK) &&
!stat(text.ascii(), &sbuf) &&
S_ISREG(sbuf.st_mode)))
AddButton->setEnabled(TRUE);
else
@@ -230,21 +232,23 @@ void SSHKeysApp::doAddButton()
void SSHKeysApp::log_text(const char *text)
{
TextOutput->append(text);
TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE);
}
void SSHKeysApp::doRemoveAllButton()
{
OProcess sshadd_process;
connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
this, SLOT(log_sshadd_output(OProcess*,char*,int)));
+ connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(log_sshadd_output(OProcess*,char*,int)));
log_text(tr("Running ssh-add -D"));
sshadd_process << "ssh-add" << "-D";
bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
if (!ret) {
log_text(tr("Error running ssh-add"));
}
doRefreshListButton();
}