Diffstat (limited to 'noncore/settings/sshkeys/sshkeys.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index cebc845..d8b1014 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp | |||
@@ -1,88 +1,100 @@ | |||
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> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 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 | 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 | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 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 | 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 | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | #include "sshkeys.h" | 21 | #include "sshkeys.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qdir.h> | ||
25 | #include <qfile.h> | ||
24 | #include <qmultilineedit.h> | 26 | #include <qmultilineedit.h> |
25 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
26 | #include <qlistview.h> | 28 | #include <qlistview.h> |
27 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
28 | 30 | ||
29 | #include <sys/types.h> | 31 | #include <sys/types.h> |
30 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <fcntl.h> | ||
34 | #include <sys/ioctl.h> | ||
31 | #include <stdlib.h> | 35 | #include <stdlib.h> |
32 | #include <unistd.h> | 36 | #include <unistd.h> |
33 | #include <stdio.h> | 37 | #include <stdio.h> |
34 | #include <ctype.h> | 38 | #include <ctype.h> |
35 | 39 | ||
36 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
37 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; | 41 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; |
38 | 42 | ||
39 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) | 43 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) |
40 | : SSHKeysBase( parent, name, fl ) | 44 | : SSHKeysBase( parent, name, fl ) |
41 | { | 45 | { |
42 | char *home = getenv("HOME"); | 46 | /* If we had a controlling TTY, detach from it. |
47 | This is to ensure that SSH uses ssh-askpass */ | ||
48 | int fd = open("/dev/tty", O_RDONLY); | ||
49 | if (fd != -1) { | ||
50 | ioctl(fd, TIOCNOTTY, NULL); | ||
51 | close(fd); | ||
52 | } | ||
53 | |||
54 | QCString home = QFile::encodeName( QDir::homeDirPath() ); | ||
43 | unsigned i; | 55 | unsigned i; |
44 | 56 | ||
45 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); | 57 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); |
46 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); | 58 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); |
47 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); | 59 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); |
48 | 60 | ||
49 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 61 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
50 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); | 62 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); |
51 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 63 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
52 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); | 64 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); |
53 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), | 65 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), |
54 | this, SLOT(ssh_add_exited(Opie::Core::OProcess*))); | 66 | this, SLOT(ssh_add_exited(Opie::Core::OProcess*))); |
55 | 67 | ||
56 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), | 68 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), |
57 | this, SLOT(add_text_changed(const QString&))); | 69 | this, SLOT(add_text_changed(const QString&))); |
58 | 70 | ||
59 | if (home) { | 71 | if (home) { |
60 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { | 72 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { |
61 | char thiskeyname[32]; | 73 | char thiskeyname[32]; |
62 | 74 | ||
63 | thiskeyname[31] = 0; | 75 | thiskeyname[31] = 0; |
64 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); | 76 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home.data(), keynames[i]); |
65 | if (!access(thiskeyname, R_OK)) { | 77 | if (!access(thiskeyname, R_OK)) { |
66 | KeyFileName->insertItem(thiskeyname); | 78 | KeyFileName->insertItem(thiskeyname); |
67 | } | 79 | } |
68 | } | 80 | } |
69 | } | 81 | } |
70 | 82 | ||
71 | doRefreshListButton(); | 83 | doRefreshListButton(); |
72 | } | 84 | } |
73 | 85 | ||
74 | SSHKeysApp::~SSHKeysApp() | 86 | SSHKeysApp::~SSHKeysApp() |
75 | { | 87 | { |
76 | } | 88 | } |
77 | 89 | ||
78 | void SSHKeysApp::doRefreshListButton() | 90 | void SSHKeysApp::doRefreshListButton() |
79 | { | 91 | { |
80 | OProcess sshadd_process; | 92 | OProcess sshadd_process; |
81 | QListViewItem *t = KeyList->firstChild(); | 93 | QListViewItem *t = KeyList->firstChild(); |
82 | 94 | ||
83 | while(t) { | 95 | while(t) { |
84 | QListViewItem *next = t->nextSibling(); | 96 | QListViewItem *next = t->nextSibling(); |
85 | KeyList->takeItem(t); | 97 | KeyList->takeItem(t); |
86 | delete(t); | 98 | delete(t); |
87 | t = next; | 99 | t = next; |
88 | } | 100 | } |