summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sshkeys/opie-sshkeys.control2
-rw-r--r--noncore/settings/sshkeys/sshkeys.cpp417
-rw-r--r--noncore/settings/sshkeys/sshkeys.h53
-rw-r--r--noncore/settings/sshkeys/sshkeys.pro2
4 files changed, 237 insertions, 237 deletions
diff --git a/noncore/settings/sshkeys/opie-sshkeys.control b/noncore/settings/sshkeys/opie-sshkeys.control
index 4deccf4..08e3508 100644
--- a/noncore/settings/sshkeys/opie-sshkeys.control
+++ b/noncore/settings/sshkeys/opie-sshkeys.control
@@ -4,6 +4,6 @@ Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: David Woodhouse <dwmw2@infradead.org> 5Maintainer: David Woodhouse <dwmw2@infradead.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, ssh, opie-sh-ssh-askpass 7Depends: task-opie-minimal, ssh, opie-sh-ssh-askpass, libopiecore2
8Description: Utility for managing ssh-agent keys. 8Description: Utility for managing ssh-agent keys.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp
index 43e02af..e76fd6b 100644
--- a/noncore/settings/sshkeys/sshkeys.cpp
+++ b/noncore/settings/sshkeys/sshkeys.cpp
@@ -1,4 +1,4 @@
1/* 1/*
2 * ssh-agent key manipulation utility 2 * ssh-agent key manipulation utility
3 * 3 *
4 * (C) 2002 David Woodhouse <dwmw2@infradead.org> 4 * (C) 2002 David Woodhouse <dwmw2@infradead.org>
@@ -21,7 +21,6 @@
21#include "sshkeys.h" 21#include "sshkeys.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oprocess.h>
25#include <qmultilineedit.h> 24#include <qmultilineedit.h>
26#include <qpushbutton.h> 25#include <qpushbutton.h>
27#include <qlistview.h> 26#include <qlistview.h>
@@ -39,36 +38,36 @@ static char *keynames[] = { "identity", "id_rsa", "id_dsa" };
39SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) 38SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl )
40 : SSHKeysBase( parent, name, fl ) 39 : SSHKeysBase( parent, name, fl )
41{ 40{
42 char *home = getenv("HOME"); 41 char *home = getenv("HOME");
43 unsigned i; 42 unsigned i;
44 43
45 connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); 44 connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton()));
46 connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); 45 connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton()));
47 connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); 46 connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton()));
48 47
49 connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), 48 connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)),
50 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 49 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
51 connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)), 50 connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)),
52 this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); 51 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
53 connect(&addprocess, SIGNAL(processExited(OProcess*)), 52 connect(&addprocess, SIGNAL(processExited(OProcess*)),
54 this, SLOT(ssh_add_exited(OProcess*))); 53 this, SLOT(ssh_add_exited(OProcess*)));
55 54
56 connect(KeyFileName, SIGNAL(textChanged(const QString&)), 55 connect(KeyFileName, SIGNAL(textChanged(const QString&)),
57 this, SLOT(add_text_changed(const QString&))); 56 this, SLOT(add_text_changed(const QString&)));
58 57
59 if (home) { 58 if (home) {
60 for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { 59 for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) {
61 char thiskeyname[32]; 60 char thiskeyname[32];
62 61
63 thiskeyname[31] = 0; 62 thiskeyname[31] = 0;
64 snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); 63 snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]);
65 if (!access(thiskeyname, R_OK)) { 64 if (!access(thiskeyname, R_OK)) {
66 KeyFileName->insertItem(thiskeyname); 65 KeyFileName->insertItem(thiskeyname);
67 } 66 }
68 } 67 }
69 } 68 }
70 69
71 doRefreshListButton(); 70 doRefreshListButton();
72} 71}
73 72
74SSHKeysApp::~SSHKeysApp() 73SSHKeysApp::~SSHKeysApp()
@@ -77,218 +76,218 @@ SSHKeysApp::~SSHKeysApp()
77 76
78void SSHKeysApp::doRefreshListButton() 77void SSHKeysApp::doRefreshListButton()
79{ 78{
80 OProcess sshadd_process; 79 OProcess sshadd_process;
81 QListViewItem *t = KeyList->firstChild(); 80 QListViewItem *t = KeyList->firstChild();
82 81
83 while(t) { 82 while(t) {
84 QListViewItem *next = t->nextSibling(); 83 QListViewItem *next = t->nextSibling();
85 KeyList->takeItem(t); 84 KeyList->takeItem(t);
86 delete(t); 85 delete(t);
87 t = next; 86 t = next;
88 } 87 }
89 88
90 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), 89 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
91 this, SLOT(get_list_keys_output(OProcess*,char*,int))); 90 this, SLOT(get_list_keys_output(OProcess*,char*,int)));
92 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), 91 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
93 this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); 92 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
94 93
95 keystate = KeySize; 94 keystate = KeySize;
96 incoming_keyname=""; 95 incoming_keyname="";
97 incoming_keysize=""; 96 incoming_keysize="";
98 incoming_keyfingerprint=""; 97 incoming_keyfingerprint="";
99 98
100 //log_text("Running ssh-add -l"); 99// log_text("Running ssh-add -l");
101 sshadd_process << "ssh-add" << "-l"; 100 sshadd_process << "ssh-add" << "-l";
102 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); 101 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
103 if (!ret) { 102 if (!ret) {
104 log_text(tr("Error running ssh-add")); 103 log_text(tr("Error running ssh-add"));
105 return; 104 return;
106 } 105 }
107 flush_sshadd_output(); 106 flush_sshadd_output();
108 if (sshadd_process.exitStatus() == 2) { 107 if (sshadd_process.exitStatus() == 2) {
109 setEnabled(FALSE); 108 setEnabled(FALSE);
110 } 109 }
111} 110}
112 111
113void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) 112void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen)
114{ 113{
115 int i; 114 int i;
116 (void) proc; 115 (void) proc;
117 116
118 for (i=0; i<buflen; i++) { 117 for (i=0; i<buflen; i++) {
119 switch(keystate) { 118 switch(keystate) {
120 case Noise: 119 case Noise:
121 noise: 120 noise:
122 if (buffer[i] == '\n') { 121 if (buffer[i] == '\n') {
123 log_text(incoming_noise.local8Bit()); 122 log_text(incoming_noise.local8Bit());
124 incoming_noise = ""; 123 incoming_noise = "";
125 keystate = KeySize; 124 keystate = KeySize;
126 } else { 125 } else {
127 incoming_noise += buffer[i]; 126 incoming_noise += buffer[i];
128 } 127 }
129 break; 128 break;
130 129
131 case KeySize: 130 case KeySize:
132 if (isdigit(buffer[i])) { 131 if (isdigit(buffer[i])) {
133 incoming_keysize += buffer[i]; 132 incoming_keysize += buffer[i];
134 } else if (buffer[i] == ' ') { 133 } else if (buffer[i] == ' ') {
135 keystate = KeyFingerprint; 134 keystate = KeyFingerprint;
136 } else { 135 } else {
137 incoming_keysize = ""; 136 incoming_keysize = "";
138 incoming_noise = ""; 137 incoming_noise = "";
139 keystate = Noise; 138 keystate = Noise;
140 goto noise; 139 goto noise;
141 } 140 }
142 break; 141 break;
143 142
144 case KeyFingerprint: 143 case KeyFingerprint:
145 if (isxdigit(buffer[i]) || buffer[i] == ':') { 144 if (isxdigit(buffer[i]) || buffer[i] == ':') {
146 incoming_keyfingerprint += buffer[i]; 145 incoming_keyfingerprint += buffer[i];
147 } else if (buffer[i] == ' ') { 146 } else if (buffer[i] == ' ') {
148 keystate = KeyName; 147 keystate = KeyName;
149 } else { 148 } else {
150 incoming_keysize = ""; 149 incoming_keysize = "";
151 incoming_keyfingerprint = ""; 150 incoming_keyfingerprint = "";
152 incoming_noise = ""; 151 incoming_noise = "";
153 keystate = Noise; 152 keystate = Noise;
154 goto noise; 153 goto noise;
155 } 154 }
156 break; 155 break;
157 156
158 case KeyName: 157 case KeyName:
159 if (buffer[i] == '\n') { 158 if (buffer[i] == '\n') {
160 /* Wheee. Got one. */ 159 /* Wheee. Got one. */
161 KeyList->insertItem(new 160 KeyList->insertItem(new
162 QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint)); 161 QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint));
163 incoming_keysize = ""; 162 incoming_keysize = "";
164 incoming_keyfingerprint = ""; 163 incoming_keyfingerprint = "";
165 incoming_keyname = ""; 164 incoming_keyname = "";
166 keystate = KeySize; 165 keystate = KeySize;
167 } else if (isprint(buffer[i])) { 166 } else if (isprint(buffer[i])) {
168 incoming_keyname += buffer[i]; 167 incoming_keyname += buffer[i];
169 } else { 168 } else {
170 incoming_keysize = ""; 169 incoming_keysize = "";
171 incoming_keyfingerprint = ""; 170 incoming_keyfingerprint = "";
172 incoming_noise = ""; 171 incoming_noise = "";
173 keystate = Noise; 172 keystate = Noise;
174 goto noise; 173 goto noise;
175 } 174 }
176 break; 175 break;
177 } 176 }
178 } 177 }
179} 178}
180 179
181void SSHKeysApp::flush_sshadd_output(void) 180void SSHKeysApp::flush_sshadd_output(void)
182{ 181{
183 if (pending_stdout.length()) { 182 if (pending_stdout.length()) {
184 log_text(pending_stdout.ascii()); 183 log_text(pending_stdout.ascii());
185 } 184 }
186 pending_stdout = ""; 185 pending_stdout = "";
187 186
188 if (pending_stderr.length()) { 187 if (pending_stderr.length()) {
189 log_text(pending_stderr.ascii()); 188 log_text(pending_stderr.ascii());
190 } 189 }
191 pending_stderr = ""; 190 pending_stderr = "";
192} 191}
193 192
194void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) 193void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen)
195{ 194{
196 (void) proc; 195 (void) proc;
197 196
198 while (buflen) { 197 while (buflen) {
199 if (*buffer == '\n') { 198 if (*buffer == '\n') {
200 log_text(pending_stdout); 199 log_text(pending_stdout);
201 pending_stdout = ""; 200 pending_stdout = "";
202 } else { 201 } else {
203 pending_stdout += *buffer; 202 pending_stdout += *buffer;
204 } 203 }
205 buffer++; 204 buffer++;
206 buflen--; 205 buflen--;
207 } 206 }
208} 207}
209 208
210void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) 209void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen)
211{ 210{
212 (void) proc; 211 (void) proc;
213 212
214 while (buflen) { 213 while (buflen) {
215 if (*buffer == '\n') { 214 if (*buffer == '\n') {
216 log_text(pending_stderr); 215 log_text(pending_stderr);
217 pending_stderr = ""; 216 pending_stderr = "";
218 } else { 217 } else {
219 pending_stderr += *buffer; 218 pending_stderr += *buffer;
220 } 219 }
221 buffer++; 220 buffer++;
222 buflen--; 221 buflen--;
223 } 222 }
224} 223}
225 224
226void SSHKeysApp::ssh_add_exited(OProcess *proc) 225void SSHKeysApp::ssh_add_exited(OProcess *proc)
227{ 226{
228 (void)proc; 227 (void)proc;
229 228
230 doRefreshListButton(); 229 doRefreshListButton();
231 setEnabled(TRUE); 230 setEnabled(TRUE);
232 if (proc->exitStatus() == 2) { 231 if (proc->exitStatus() == 2) {
233 setEnabled(FALSE); 232 setEnabled(FALSE);
234 } 233 }
235} 234}
236 235
237void SSHKeysApp::add_text_changed(const QString &text) 236void SSHKeysApp::add_text_changed(const QString &text)
238{ 237{
239 struct stat sbuf; 238 struct stat sbuf;
240 239
241 if (!text.length() || (!access(text.ascii(), R_OK) && 240 if (!text.length() || (!access(text.ascii(), R_OK) &&
242 !stat(text.ascii(), &sbuf) && 241 !stat(text.ascii(), &sbuf) &&
243 S_ISREG(sbuf.st_mode))) 242 S_ISREG(sbuf.st_mode)))
244 AddButton->setEnabled(TRUE); 243 AddButton->setEnabled(TRUE);
245 else 244 else
246 AddButton->setEnabled(FALSE); 245 AddButton->setEnabled(FALSE);
247} 246}
248 247
249void SSHKeysApp::doAddButton() 248void SSHKeysApp::doAddButton()
250{ 249{
251 addprocess.clearArguments(); 250 addprocess.clearArguments();
252 251
253 setEnabled(FALSE); 252 setEnabled(FALSE);
254 253
255 if (KeyFileName->currentText().length()) { 254 if (KeyFileName->currentText().length()) {
256 addprocess << "ssh-add" << "--" << KeyFileName->currentText(); 255 addprocess << "ssh-add" << "--" << KeyFileName->currentText();
257 // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); 256// log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText());
258 } else { 257 } else {
259 addprocess << "ssh-add"; 258 addprocess << "ssh-add";
260 // log_text(tr("Running ssh-add")); 259// log_text(tr("Running ssh-add"));
261 } 260 }
262 bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput); 261 bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput);
263 if (!ret) { 262 if (!ret) {
264 log_text(tr("Error running ssh-add")); 263 log_text(tr("Error running ssh-add"));
265 doRefreshListButton(); 264 doRefreshListButton();
266 setEnabled(TRUE); 265 setEnabled(TRUE);
267 } 266 }
268 flush_sshadd_output(); 267 flush_sshadd_output();
269} 268}
270 269
271void SSHKeysApp::log_text(const char *text) 270void SSHKeysApp::log_text(const char *text)
272{ 271{
273 TextOutput->append(text); 272 TextOutput->append(text);
274 TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); 273 TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE);
275} 274}
276 275
277void SSHKeysApp::doRemoveAllButton() 276void SSHKeysApp::doRemoveAllButton()
278{ 277{
279 OProcess sshadd_process; 278 OProcess sshadd_process;
280 279
281 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), 280 connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)),
282 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 281 this, SLOT(log_sshadd_output(OProcess*,char*,int)));
283 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), 282 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
284 this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); 283 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
285 284
286 //log_text(tr("Running ssh-add -D")); 285// log_text(tr("Running ssh-add -D"));
287 sshadd_process << "ssh-add" << "-D"; 286 sshadd_process << "ssh-add" << "-D";
288 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); 287 bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput);
289 if (!ret) { 288 if (!ret) {
290 log_text(tr("Error running ssh-add")); 289 log_text(tr("Error running ssh-add"));
291 } 290 }
292 flush_sshadd_output(); 291 flush_sshadd_output();
293 doRefreshListButton(); 292 doRefreshListButton();
294} 293}
diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h
index bbc6993..7483bbc 100644
--- a/noncore/settings/sshkeys/sshkeys.h
+++ b/noncore/settings/sshkeys/sshkeys.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * ssh-agent key manipulation utility 2 * ssh-agent key manipulation utility
3 * 3 *
4 * (C) 2002 David Woodhouse <dwmw2@infradead.org> 4 * (C) 2002 David Woodhouse <dwmw2@infradead.org>
@@ -23,38 +23,39 @@
23#define SSHKEYSAPP_H 23#define SSHKEYSAPP_H
24 24
25#include "sshkeysbase.h" 25#include "sshkeysbase.h"
26#include <opie/oprocess.h> 26
27#include <opie2/oprocess.h>
27 28
28class SSHKeysApp : public SSHKeysBase 29class SSHKeysApp : public SSHKeysBase
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31 32
32 public: 33 public:
33 SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 34 SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
34 ~SSHKeysApp(); 35 ~SSHKeysApp();
35 36
36 private: 37 private:
37 void log_text(const char *text); 38 void log_text(const char *text);
38 void flush_sshadd_output(void); 39 void flush_sshadd_output(void);
39 40
40 enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; 41 enum { Noise, KeyName, KeySize, KeyFingerprint } keystate;
41 QString incoming_keyname; 42 QString incoming_keyname;
42 QString incoming_keysize; 43 QString incoming_keysize;
43 QString incoming_keyfingerprint; 44 QString incoming_keyfingerprint;
44 QString incoming_noise; 45 QString incoming_noise;
45 OProcess addprocess; 46 OProcess addprocess;
46 QString pending_stdout; 47 QString pending_stdout;
47 QString pending_stderr; 48 QString pending_stderr;
48 49
49 private slots: 50 private slots:
50 void doAddButton(); 51 void doAddButton();
51 void doRefreshListButton(); 52 void doRefreshListButton();
52 void doRemoveAllButton(); 53 void doRemoveAllButton();
53 void get_list_keys_output(OProcess *proc, char *buffer, int buflen); 54 void get_list_keys_output(OProcess *proc, char *buffer, int buflen);
54 void log_sshadd_output(OProcess *proc, char *buffer, int buflen); 55 void log_sshadd_output(OProcess *proc, char *buffer, int buflen);
55 void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen); 56 void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen);
56 void ssh_add_exited(OProcess *proc); 57 void ssh_add_exited(OProcess *proc);
57 void add_text_changed(const QString &text); 58 void add_text_changed(const QString &text);
58}; 59};
59#endif 60#endif
60 61
diff --git a/noncore/settings/sshkeys/sshkeys.pro b/noncore/settings/sshkeys/sshkeys.pro
index e98df2e..273db3c 100644
--- a/noncore/settings/sshkeys/sshkeys.pro
+++ b/noncore/settings/sshkeys/sshkeys.pro
@@ -6,7 +6,7 @@ TARGET = sshkeys
6INTERFACES = sshkeysbase.ui 6INTERFACES = sshkeysbase.ui
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie 9LIBS += -lqpe -lopiecore2
10DESTDIR = $(OPIEDIR)/bin 10DESTDIR = $(OPIEDIR)/bin
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )