mirror of
https://github.com/clearml/dropbear
synced 2025-02-12 07:25:30 +00:00
allow specifying dropbearmulti command as an argument
This commit is contained in:
parent
73bc3a9853
commit
26a1a0a3bc
30
dbmulti.c
30
dbmulti.c
@ -26,17 +26,13 @@
|
|||||||
|
|
||||||
/* definitions are cleanest if we just put them here */
|
/* definitions are cleanest if we just put them here */
|
||||||
int dropbear_main(int argc, char ** argv);
|
int dropbear_main(int argc, char ** argv);
|
||||||
|
int cli_main(int argc, char ** argv);
|
||||||
int dropbearkey_main(int argc, char ** argv);
|
int dropbearkey_main(int argc, char ** argv);
|
||||||
int dropbearconvert_main(int argc, char ** argv);
|
int dropbearconvert_main(int argc, char ** argv);
|
||||||
int scp_main(int argc, char ** argv);
|
int scp_main(int argc, char ** argv);
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
static int runprog(const char *progname, int argc, char ** argv, int *match) {
|
||||||
|
*match = DROPBEAR_SUCCESS;
|
||||||
char * progname;
|
|
||||||
|
|
||||||
if (argc > 0) {
|
|
||||||
/* figure which form we're being called as */
|
|
||||||
progname = basename(argv[0]);
|
|
||||||
|
|
||||||
#ifdef DBMULTI_dropbear
|
#ifdef DBMULTI_dropbear
|
||||||
if (strcmp(progname, "dropbear") == 0) {
|
if (strcmp(progname, "dropbear") == 0) {
|
||||||
@ -64,10 +60,28 @@ int main(int argc, char ** argv) {
|
|||||||
return scp_main(argc, argv);
|
return scp_main(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*match = DROPBEAR_FAILURE;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char ** argv) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
/* Try symlink first, then try as an argument eg "dropbearmulti dbclient host ..." */
|
||||||
|
if (argc > i) {
|
||||||
|
int match, res;
|
||||||
|
/* figure which form we're being called as */
|
||||||
|
const char* progname = basename(argv[i]);
|
||||||
|
res = runprog(progname, argc-i, &argv[i], &match);
|
||||||
|
if (match == DROPBEAR_SUCCESS) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Dropbear SSH multi-purpose v%s\n"
|
fprintf(stderr, "Dropbear SSH multi-purpose v%s\n"
|
||||||
"Make a symlink pointing at this binary with one of the following names:\n"
|
"Make a symlink pointing at this binary with one of the\n"
|
||||||
|
"following names or run 'dropbearmulti <command>'.\n"
|
||||||
#ifdef DBMULTI_dropbear
|
#ifdef DBMULTI_dropbear
|
||||||
"'dropbear' - the Dropbear server\n"
|
"'dropbear' - the Dropbear server\n"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user