Mercurial > dropbear
annotate dbmulti.c @ 1884:75d6a9faf919
Merge pull request #151 from HansH111/pubkeyinfo
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 16 Mar 2022 10:43:24 +0800 |
parents | 6b25cdad4783 |
children |
rev | line source |
---|---|
74
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
1 /* |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
2 * Dropbear SSH |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
3 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
4 * Copyright (c) 2002,2003 Matt Johnston |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
5 * All rights reserved. |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
6 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
7 * Permission is hereby granted, free of charge, to any person obtaining a copy |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
8 * of this software and associated documentation files (the "Software"), to deal |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
9 * in the Software without restriction, including without limitation the rights |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
11 * copies of the Software, and to permit persons to whom the Software is |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
12 * furnished to do so, subject to the following conditions: |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
13 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
14 * The above copyright notice and this permission notice shall be included in |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
15 * all copies or substantial portions of the Software. |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
16 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
23 * SOFTWARE. */ |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
24 |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 #include "includes.h" |
1870
0dcc5b0d93fa
Make re-exec work with "dropbearmulti dropbear"
Matt Johnston <matt@ucc.asn.au>
parents:
1235
diff
changeset
|
26 #include "dbutil.h" |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 |
1870
0dcc5b0d93fa
Make re-exec work with "dropbearmulti dropbear"
Matt Johnston <matt@ucc.asn.au>
parents:
1235
diff
changeset
|
28 static int runprog(const char *multipath, |
0dcc5b0d93fa
Make re-exec work with "dropbearmulti dropbear"
Matt Johnston <matt@ucc.asn.au>
parents:
1235
diff
changeset
|
29 const char *progname, int argc, char ** argv, int *match) { |
1235
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
30 *match = DROPBEAR_SUCCESS; |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
32 #ifdef DBMULTI_dropbear |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 if (strcmp(progname, "dropbear") == 0) { |
1870
0dcc5b0d93fa
Make re-exec work with "dropbearmulti dropbear"
Matt Johnston <matt@ucc.asn.au>
parents:
1235
diff
changeset
|
34 return dropbear_main(argc, argv, multipath); |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 } |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 #endif |
33 | 37 #ifdef DBMULTI_dbclient |
86 | 38 if (strcmp(progname, "dbclient") == 0 |
39 || strcmp(progname, "ssh") == 0) { | |
33 | 40 return cli_main(argc, argv); |
41 } | |
42 #endif | |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
43 #ifdef DBMULTI_dropbearkey |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 if (strcmp(progname, "dropbearkey") == 0) { |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 return dropbearkey_main(argc, argv); |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 } |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 #endif |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
48 #ifdef DBMULTI_dropbearconvert |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 if (strcmp(progname, "dropbearconvert") == 0) { |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 return dropbearconvert_main(argc, argv); |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 } |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 #endif |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
53 #ifdef DBMULTI_scp |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
54 if (strcmp(progname, "scp") == 0) { |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
55 return scp_main(argc, argv); |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
56 } |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
57 #endif |
1235
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
58 *match = DROPBEAR_FAILURE; |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
59 return 1; |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
60 } |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
61 |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
62 int main(int argc, char ** argv) { |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
63 int i; |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
64 for (i = 0; i < 2; i++) { |
1872
6b25cdad4783
Fix regression in non-symlink dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1870
diff
changeset
|
65 const char* multipath = NULL; |
6b25cdad4783
Fix regression in non-symlink dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1870
diff
changeset
|
66 if (i == 1) { |
6b25cdad4783
Fix regression in non-symlink dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1870
diff
changeset
|
67 multipath = argv[0]; |
6b25cdad4783
Fix regression in non-symlink dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1870
diff
changeset
|
68 } |
1235
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
69 /* Try symlink first, then try as an argument eg "dropbearmulti dbclient host ..." */ |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
70 if (argc > i) { |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
71 int match, res; |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
72 /* figure which form we're being called as */ |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
73 const char* progname = basename(argv[i]); |
1872
6b25cdad4783
Fix regression in non-symlink dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1870
diff
changeset
|
74 res = runprog(multipath, progname, argc-i, &argv[i], &match); |
1235
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
75 if (match == DROPBEAR_SUCCESS) { |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
76 return res; |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
77 } |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
78 } |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 } |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 |
716 | 81 fprintf(stderr, "Dropbear SSH multi-purpose v%s\n" |
1235
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
82 "Make a symlink pointing at this binary with one of the\n" |
11f645c3715b
allow specifying dropbearmulti command as an argument
Matt Johnston <matt@ucc.asn.au>
parents:
716
diff
changeset
|
83 "following names or run 'dropbearmulti <command>'.\n" |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
84 #ifdef DBMULTI_dropbear |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 "'dropbear' - the Dropbear server\n" |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 #endif |
33 | 87 #ifdef DBMULTI_dbclient |
110
9b7fc71039cd
Add help text that a symlink to "ssh" works
Matt Johnston <matt@ucc.asn.au>
parents:
86
diff
changeset
|
88 "'dbclient' or 'ssh' - the Dropbear client\n" |
33 | 89 #endif |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
90 #ifdef DBMULTI_dropbearkey |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 "'dropbearkey' - the key generator\n" |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 #endif |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
93 #ifdef DBMULTI_dropbearconvert |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 "'dropbearconvert' - the key converter\n" |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 #endif |
30
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
96 #ifdef DBMULTI_scp |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
97 "'scp' - secure copy\n" |
223b0f5f8dce
Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
4
diff
changeset
|
98 #endif |
4
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 , |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 DROPBEAR_VERSION); |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 exit(1); |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 |
fe6bca95afa7
Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 } |