Mercurial > dropbear
comparison dbmulti.c @ 1870:0dcc5b0d93fa
Make re-exec work with "dropbearmulti dropbear"
The re-exec needs to know to use the dropbearmulti binary instead.
Add a test for this case.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 01 Feb 2022 22:18:23 +0800 |
parents | 11f645c3715b |
children | 6b25cdad4783 |
comparison
equal
deleted
inserted
replaced
1869:d7247462fa0d | 1870:0dcc5b0d93fa |
---|---|
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23 * SOFTWARE. */ | 23 * SOFTWARE. */ |
24 | 24 |
25 #include "includes.h" | 25 #include "includes.h" |
26 #include "dbutil.h" | |
26 | 27 |
27 /* definitions are cleanest if we just put them here */ | 28 static int runprog(const char *multipath, |
28 int dropbear_main(int argc, char ** argv); | 29 const char *progname, int argc, char ** argv, int *match) { |
29 int cli_main(int argc, char ** argv); | |
30 int dropbearkey_main(int argc, char ** argv); | |
31 int dropbearconvert_main(int argc, char ** argv); | |
32 int scp_main(int argc, char ** argv); | |
33 | |
34 static int runprog(const char *progname, int argc, char ** argv, int *match) { | |
35 *match = DROPBEAR_SUCCESS; | 30 *match = DROPBEAR_SUCCESS; |
36 | 31 |
37 #ifdef DBMULTI_dropbear | 32 #ifdef DBMULTI_dropbear |
38 if (strcmp(progname, "dropbear") == 0) { | 33 if (strcmp(progname, "dropbear") == 0) { |
39 return dropbear_main(argc, argv); | 34 return dropbear_main(argc, argv, multipath); |
40 } | 35 } |
41 #endif | 36 #endif |
42 #ifdef DBMULTI_dbclient | 37 #ifdef DBMULTI_dbclient |
43 if (strcmp(progname, "dbclient") == 0 | 38 if (strcmp(progname, "dbclient") == 0 |
44 || strcmp(progname, "ssh") == 0) { | 39 || strcmp(progname, "ssh") == 0) { |
70 /* Try symlink first, then try as an argument eg "dropbearmulti dbclient host ..." */ | 65 /* Try symlink first, then try as an argument eg "dropbearmulti dbclient host ..." */ |
71 if (argc > i) { | 66 if (argc > i) { |
72 int match, res; | 67 int match, res; |
73 /* figure which form we're being called as */ | 68 /* figure which form we're being called as */ |
74 const char* progname = basename(argv[i]); | 69 const char* progname = basename(argv[i]); |
75 res = runprog(progname, argc-i, &argv[i], &match); | 70 res = runprog(argv[0], progname, argc-i, &argv[i], &match); |
76 if (match == DROPBEAR_SUCCESS) { | 71 if (match == DROPBEAR_SUCCESS) { |
77 return res; | 72 return res; |
78 } | 73 } |
79 } | 74 } |
80 } | 75 } |