author | dwmw2 <dwmw2> | 2002-09-20 13:38:37 (UTC) |
---|---|---|
committer | dwmw2 <dwmw2> | 2002-09-20 13:38:37 (UTC) |
commit | ba0e9195f95ecb65216851b9b74fd776d307adc3 (patch) (unidiff) | |
tree | 248699c113c9ab5d469d015360baed1f5c4f6dae | |
parent | 07f63d9a2a816f2406b0d8ea0f3c1b813fd13663 (diff) | |
download | opie-ba0e9195f95ecb65216851b9b74fd776d307adc3.zip opie-ba0e9195f95ecb65216851b9b74fd776d307adc3.tar.gz opie-ba0e9195f95ecb65216851b9b74fd776d307adc3.tar.bz2 |
Copyright and licence noise
-rw-r--r-- | noncore/settings/sshkeys/main.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.h | 20 |
3 files changed, 61 insertions, 2 deletions
diff --git a/noncore/settings/sshkeys/main.cpp b/noncore/settings/sshkeys/main.cpp index a7b1d56..9f19d0f 100644 --- a/noncore/settings/sshkeys/main.cpp +++ b/noncore/settings/sshkeys/main.cpp | |||
@@ -1,30 +1,49 @@ | |||
1 | /* | ||
2 | * ssh-agent key manipulation utility | ||
3 | * | ||
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
1 | 21 | ||
2 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
3 | #include "sshkeys.h" | 23 | #include "sshkeys.h" |
4 | #include <stdio.h> | 24 | #include <stdio.h> |
5 | #include <sys/types.h> | 25 | #include <sys/types.h> |
6 | #include <sys/stat.h> | 26 | #include <sys/stat.h> |
7 | #include <fcntl.h> | 27 | #include <fcntl.h> |
8 | #include <sys/ioctl.h> | 28 | #include <sys/ioctl.h> |
9 | #include <unistd.h> | 29 | #include <unistd.h> |
10 | 30 | ||
11 | |||
12 | int main(int argc, char *argv[]) | 31 | int main(int argc, char *argv[]) |
13 | { | 32 | { |
14 | QPEApplication a(argc, argv); | 33 | QPEApplication a(argc, argv); |
15 | SSHKeysApp app; | 34 | SSHKeysApp app; |
16 | int fd; | 35 | int fd; |
17 | 36 | ||
18 | /* If we had a controlling TTY, detach from it. | 37 | /* If we had a controlling TTY, detach from it. |
19 | This is to ensure the SSH uses ssh-askpass */ | 38 | This is to ensure that SSH uses ssh-askpass */ |
20 | fd = open("/dev/tty", O_RDONLY); | 39 | fd = open("/dev/tty", O_RDONLY); |
21 | if (fd != -1) { | 40 | if (fd != -1) { |
22 | ioctl(fd, TIOCNOTTY, NULL); | 41 | ioctl(fd, TIOCNOTTY, NULL); |
23 | close(fd); | 42 | close(fd); |
24 | } | 43 | } |
25 | 44 | ||
26 | a.showMainWidget(&app); | 45 | a.showMainWidget(&app); |
27 | 46 | ||
28 | return a.exec(); | 47 | return a.exec(); |
29 | } | 48 | } |
30 | 49 | ||
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index 3b4dce6..88acf94 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp | |||
@@ -1,128 +1,148 @@ | |||
1 | /* | ||
2 | * ssh-agent key manipulation utility | ||
3 | * | ||
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
1 | #include "sshkeys.h" | 21 | #include "sshkeys.h" |
2 | 22 | ||
3 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
4 | #include <opie/oprocess.h> | 24 | #include <opie/oprocess.h> |
5 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
6 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
7 | #include <qlistview.h> | 27 | #include <qlistview.h> |
8 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
9 | 29 | ||
10 | #include <sys/types.h> | 30 | #include <sys/types.h> |
11 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
12 | #include <stdlib.h> | 32 | #include <stdlib.h> |
13 | #include <unistd.h> | 33 | #include <unistd.h> |
14 | #include <stdio.h> | 34 | #include <stdio.h> |
15 | #include <ctype.h> | 35 | #include <ctype.h> |
16 | 36 | ||
17 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; | 37 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; |
18 | 38 | ||
19 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) | 39 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) |
20 | : SSHKeysBase( parent, name, fl ) | 40 | : SSHKeysBase( parent, name, fl ) |
21 | { | 41 | { |
22 | char *home = getenv("HOME"); | 42 | char *home = getenv("HOME"); |
23 | unsigned i; | 43 | unsigned i; |
24 | 44 | ||
25 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); | 45 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); |
26 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); | 46 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); |
27 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); | 47 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); |
28 | 48 | ||
29 | connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 49 | connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
30 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); | 50 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); |
31 | connect(&addprocess, SIGNAL(processExited(OProcess*)), | 51 | connect(&addprocess, SIGNAL(processExited(OProcess*)), |
32 | this, SLOT(ssh_add_exited(OProcess*))); | 52 | this, SLOT(ssh_add_exited(OProcess*))); |
33 | 53 | ||
34 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), | 54 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), |
35 | this, SLOT(add_text_changed(const QString&))); | 55 | this, SLOT(add_text_changed(const QString&))); |
36 | 56 | ||
37 | if (home) { | 57 | if (home) { |
38 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { | 58 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { |
39 | char thiskeyname[32]; | 59 | char thiskeyname[32]; |
40 | 60 | ||
41 | thiskeyname[31] = 0; | 61 | thiskeyname[31] = 0; |
42 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); | 62 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); |
43 | if (!access(thiskeyname, R_OK)) { | 63 | if (!access(thiskeyname, R_OK)) { |
44 | KeyFileName->insertItem(thiskeyname); | 64 | KeyFileName->insertItem(thiskeyname); |
45 | } | 65 | } |
46 | } | 66 | } |
47 | } | 67 | } |
48 | 68 | ||
49 | doRefreshListButton(); | 69 | doRefreshListButton(); |
50 | } | 70 | } |
51 | 71 | ||
52 | SSHKeysApp::~SSHKeysApp() | 72 | SSHKeysApp::~SSHKeysApp() |
53 | { | 73 | { |
54 | } | 74 | } |
55 | 75 | ||
56 | void SSHKeysApp::doRefreshListButton() | 76 | void SSHKeysApp::doRefreshListButton() |
57 | { | 77 | { |
58 | OProcess sshadd_process; | 78 | OProcess sshadd_process; |
59 | QListViewItem *t = KeyList->firstChild(); | 79 | QListViewItem *t = KeyList->firstChild(); |
60 | 80 | ||
61 | while(t) { | 81 | while(t) { |
62 | QListViewItem *next = t->nextSibling(); | 82 | QListViewItem *next = t->nextSibling(); |
63 | KeyList->takeItem(t); | 83 | KeyList->takeItem(t); |
64 | delete(t); | 84 | delete(t); |
65 | t = next; | 85 | t = next; |
66 | } | 86 | } |
67 | 87 | ||
68 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), | 88 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), |
69 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); | 89 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); |
70 | 90 | ||
71 | keystate = KeySize; | 91 | keystate = KeySize; |
72 | incoming_keyname=""; | 92 | incoming_keyname=""; |
73 | incoming_keysize=""; | 93 | incoming_keysize=""; |
74 | incoming_keyfingerprint=""; | 94 | incoming_keyfingerprint=""; |
75 | 95 | ||
76 | //log_text("Running ssh-add -l"); | 96 | //log_text("Running ssh-add -l"); |
77 | sshadd_process << "ssh-add" << "-l"; | 97 | sshadd_process << "ssh-add" << "-l"; |
78 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 98 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
79 | if (!ret) { | 99 | if (!ret) { |
80 | log_text(tr("Error running ssh-add")); | 100 | log_text(tr("Error running ssh-add")); |
81 | return; | 101 | return; |
82 | } | 102 | } |
83 | if (sshadd_process.exitStatus() == 2) { | 103 | if (sshadd_process.exitStatus() == 2) { |
84 | log_text(tr("Connection to ssh-agent failed")); | 104 | log_text(tr("Connection to ssh-agent failed")); |
85 | setEnabled(FALSE); | 105 | setEnabled(FALSE); |
86 | } | 106 | } |
87 | } | 107 | } |
88 | 108 | ||
89 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) | 109 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) |
90 | { | 110 | { |
91 | int i; | 111 | int i; |
92 | (void) proc; | 112 | (void) proc; |
93 | 113 | ||
94 | for (i=0; i<buflen; i++) { | 114 | for (i=0; i<buflen; i++) { |
95 | switch(keystate) { | 115 | switch(keystate) { |
96 | case Noise: | 116 | case Noise: |
97 | noise: | 117 | noise: |
98 | if (buffer[i] == '\n') { | 118 | if (buffer[i] == '\n') { |
99 | log_text(incoming_noise.local8Bit()); | 119 | log_text(incoming_noise.local8Bit()); |
100 | incoming_noise = ""; | 120 | incoming_noise = ""; |
101 | keystate = KeySize; | 121 | keystate = KeySize; |
102 | } else { | 122 | } else { |
103 | incoming_noise += buffer[i]; | 123 | incoming_noise += buffer[i]; |
104 | } | 124 | } |
105 | break; | 125 | break; |
106 | 126 | ||
107 | case KeySize: | 127 | case KeySize: |
108 | if (isdigit(buffer[i])) { | 128 | if (isdigit(buffer[i])) { |
109 | incoming_keysize += buffer[i]; | 129 | incoming_keysize += buffer[i]; |
110 | } else if (buffer[i] == ' ') { | 130 | } else if (buffer[i] == ' ') { |
111 | keystate = KeyFingerprint; | 131 | keystate = KeyFingerprint; |
112 | } else { | 132 | } else { |
113 | incoming_keysize = ""; | 133 | incoming_keysize = ""; |
114 | incoming_noise = ""; | 134 | incoming_noise = ""; |
115 | keystate = Noise; | 135 | keystate = Noise; |
116 | goto noise; | 136 | goto noise; |
117 | } | 137 | } |
118 | break; | 138 | break; |
119 | 139 | ||
120 | case KeyFingerprint: | 140 | case KeyFingerprint: |
121 | if (isxdigit(buffer[i]) || buffer[i] == ':') { | 141 | if (isxdigit(buffer[i]) || buffer[i] == ':') { |
122 | incoming_keyfingerprint += buffer[i]; | 142 | incoming_keyfingerprint += buffer[i]; |
123 | } else if (buffer[i] == ' ') { | 143 | } else if (buffer[i] == ' ') { |
124 | keystate = KeyName; | 144 | keystate = KeyName; |
125 | } else { | 145 | } else { |
126 | incoming_keysize = ""; | 146 | incoming_keysize = ""; |
127 | incoming_keyfingerprint = ""; | 147 | incoming_keyfingerprint = ""; |
128 | incoming_noise = ""; | 148 | incoming_noise = ""; |
diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h index 9a39a2c..5e306d1 100644 --- a/noncore/settings/sshkeys/sshkeys.h +++ b/noncore/settings/sshkeys/sshkeys.h | |||
@@ -1,35 +1,55 @@ | |||
1 | /* | ||
2 | * ssh-agent key manipulation utility | ||
3 | * | ||
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
1 | 21 | ||
2 | #ifndef SSHKEYSAPP_H | 22 | #ifndef SSHKEYSAPP_H |
3 | #define SSHKEYSAPP_H | 23 | #define SSHKEYSAPP_H |
4 | 24 | ||
5 | #include "sshkeysbase.h" | 25 | #include "sshkeysbase.h" |
6 | #include <opie/oprocess.h> | 26 | #include <opie/oprocess.h> |
7 | 27 | ||
8 | class SSHKeysApp : public SSHKeysBase | 28 | class SSHKeysApp : public SSHKeysBase |
9 | { | 29 | { |
10 | Q_OBJECT | 30 | Q_OBJECT |
11 | 31 | ||
12 | public: | 32 | public: |
13 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 33 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
14 | ~SSHKeysApp(); | 34 | ~SSHKeysApp(); |
15 | 35 | ||
16 | private: | 36 | private: |
17 | void log_text(const char *text); | 37 | void log_text(const char *text); |
18 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; | 38 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; |
19 | QString incoming_keyname; | 39 | QString incoming_keyname; |
20 | QString incoming_keysize; | 40 | QString incoming_keysize; |
21 | QString incoming_keyfingerprint; | 41 | QString incoming_keyfingerprint; |
22 | QString incoming_noise; | 42 | QString incoming_noise; |
23 | OProcess addprocess; | 43 | OProcess addprocess; |
24 | 44 | ||
25 | private slots: | 45 | private slots: |
26 | void doAddButton(); | 46 | void doAddButton(); |
27 | void doRefreshListButton(); | 47 | void doRefreshListButton(); |
28 | void doRemoveAllButton(); | 48 | void doRemoveAllButton(); |
29 | void get_list_keys_output(OProcess *proc, char *buffer, int buflen); | 49 | void get_list_keys_output(OProcess *proc, char *buffer, int buflen); |
30 | void log_sshadd_output(OProcess *proc, char *buffer, int buflen); | 50 | void log_sshadd_output(OProcess *proc, char *buffer, int buflen); |
31 | void ssh_add_exited(OProcess *proc); | 51 | void ssh_add_exited(OProcess *proc); |
32 | void add_text_changed(const QString &text); | 52 | void add_text_changed(const QString &text); |
33 | }; | 53 | }; |
34 | #endif | 54 | #endif |
35 | 55 | ||