summaryrefslogtreecommitdiff
authordwmw2 <dwmw2>2002-09-21 08:42:42 (UTC)
committer dwmw2 <dwmw2>2002-09-21 08:42:42 (UTC)
commit51f94f502b2b9a92d562a3ad726ad58372860c5e (patch) (unidiff)
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" };
39SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) 39SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl )
40 : SSHKeysBase( parent, name, fl ) 40 : SSHKeysBase( parent, name, fl )
41{ 41{
42 char *home = getenv("HOME"); 42 char *home = getenv("HOME");
43 unsigned i; 43 unsigned i;
44 44
45 connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); 45 connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton()));
46 connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); 46 connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton()));
47 connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); 47 connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton()));
48 48
49 connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), 49 connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)),
50 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 50 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
51 connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)),
52 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
51 connect(&addprocess, SIGNAL(processExited(OProcess*)), 53 connect(&addprocess, SIGNAL(processExited(OProcess*)),
52 this, SLOT(ssh_add_exited(OProcess*))); 54 this, SLOT(ssh_add_exited(OProcess*)));
53 55
54 connect(KeyFileName, SIGNAL(textChanged(const QString&)), 56 connect(KeyFileName, SIGNAL(textChanged(const QString&)),
55 this, SLOT(add_text_changed(const QString&))); 57 this, SLOT(add_text_changed(const QString&)));
56 58
57 if (home) { 59 if (home) {
58 for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { 60 for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) {
59 char thiskeyname[32]; 61 char thiskeyname[32];
60 62
61 thiskeyname[31] = 0; 63 thiskeyname[31] = 0;
62 snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); 64 snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]);
@@ -78,39 +80,40 @@ void SSHKeysApp::doRefreshListButton()
78 OProcess sshadd_process; 80 OProcess sshadd_process;
79 QListViewItem *t = KeyList->firstChild(); 81 QListViewItem *t = KeyList->firstChild();
80 82
81 while(t) { 83 while(t) {
82 QListViewItem *next = t->nextSibling(); 84 QListViewItem *next = t->nextSibling();
83 KeyList->takeItem(t); 85 KeyList->takeItem(t);
84 delete(t); 86 delete(t);
85 t = next; 87 t = next;
86 } 88 }
87 89
88 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), 90 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
89 this, SLOT(get_list_keys_output(OProcess*,char*,int))); 91 this, SLOT(get_list_keys_output(OProcess*,char*,int)));
92 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
93 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
90 94
91 keystate = KeySize; 95 keystate = KeySize;
92 incoming_keyname=""; 96 incoming_keyname="";
93 incoming_keysize=""; 97 incoming_keysize="";
94 incoming_keyfingerprint=""; 98 incoming_keyfingerprint="";
95 99
96 //log_text("Running ssh-add -l"); 100 //log_text("Running ssh-add -l");
97 sshadd_process << "ssh-add" << "-l"; 101 sshadd_process << "ssh-add" << "-l";
98 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); 102 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
99 if (!ret) { 103 if (!ret) {
100 log_text(tr("Error running ssh-add")); 104 log_text(tr("Error running ssh-add"));
101 return; 105 return;
102 } 106 }
103 if (sshadd_process.exitStatus() == 2) { 107 if (sshadd_process.exitStatus() == 2) {
104 log_text(tr("Connection to ssh-agent failed"));
105 setEnabled(FALSE); 108 setEnabled(FALSE);
106 } 109 }
107} 110}
108 111
109void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) 112void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen)
110{ 113{
111 int i; 114 int i;
112 (void) proc; 115 (void) proc;
113 116
114 for (i=0; i<buflen; i++) { 117 for (i=0; i<buflen; i++) {
115 switch(keystate) { 118 switch(keystate) {
116 case Noise: 119 case Noise:
@@ -179,27 +182,26 @@ void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen)
179 (void)proc; 182 (void)proc;
180 (void)buflen; 183 (void)buflen;
181 184
182 log_text(buffer); 185 log_text(buffer);
183} 186}
184 187
185void SSHKeysApp::ssh_add_exited(OProcess *proc) 188void SSHKeysApp::ssh_add_exited(OProcess *proc)
186{ 189{
187 (void)proc; 190 (void)proc;
188 191
189 doRefreshListButton(); 192 doRefreshListButton();
190 setEnabled(TRUE); 193 setEnabled(TRUE);
191 if (proc->exitStatus()) { 194 if (proc->exitStatus() == 2) {
192 195 setEnabled(FALSE);
193 log_text(QString(tr("ssh-add failed")));
194 } 196 }
195} 197}
196 198
197void SSHKeysApp::add_text_changed(const QString &text) 199void SSHKeysApp::add_text_changed(const QString &text)
198{ 200{
199 struct stat sbuf; 201 struct stat sbuf;
200 202
201 if (!text.length() || (!access(text.ascii(), R_OK) && 203 if (!text.length() || (!access(text.ascii(), R_OK) &&
202 !stat(text.ascii(), &sbuf) && 204 !stat(text.ascii(), &sbuf) &&
203 S_ISREG(sbuf.st_mode))) 205 S_ISREG(sbuf.st_mode)))
204 AddButton->setEnabled(TRUE); 206 AddButton->setEnabled(TRUE);
205 else 207 else
@@ -230,21 +232,23 @@ void SSHKeysApp::doAddButton()
230void SSHKeysApp::log_text(const char *text) 232void SSHKeysApp::log_text(const char *text)
231{ 233{
232 TextOutput->append(text); 234 TextOutput->append(text);
233 TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); 235 TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE);
234} 236}
235 237
236void SSHKeysApp::doRemoveAllButton() 238void SSHKeysApp::doRemoveAllButton()
237{ 239{
238 OProcess sshadd_process; 240 OProcess sshadd_process;
239 241
240 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), 242 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
241 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 243 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
244 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
245 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
242 246
243 log_text(tr("Running ssh-add -D")); 247 log_text(tr("Running ssh-add -D"));
244 sshadd_process << "ssh-add" << "-D"; 248 sshadd_process << "ssh-add" << "-D";
245 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); 249 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
246 if (!ret) { 250 if (!ret) {
247 log_text(tr("Error running ssh-add")); 251 log_text(tr("Error running ssh-add"));
248 } 252 }
249 doRefreshListButton(); 253 doRefreshListButton();
250} 254}