Skip to content

Commit d7b1a36

Browse files
committed
add a kludge for systems like MacOS or OpenBSD
where self_exe() does not work reliably
1 parent 232774e commit d7b1a36

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ static void run(const char *name, int ac, char **av){
4949
}
5050
int main(int ac, char **av){
5151
struct prog *p;
52-
run(av[0], ac, av);
53-
if(ac > 1) run(av[1], ac - 1, av + 1);
52+
if(ac > 1 && av[1][0] == '/'){
53+
run(av[1], ac - 1, av + 1);
54+
}else{
55+
run(av[0], ac, av);
56+
if(ac > 1) run(av[1], ac - 1, av + 1);
57+
}
5458
fprintf(stderr, "Dropbear SSH multi-purpose v%s\n"
5559
"Make a symlink pointing at this binary with one of the\n",
5660
DROPBEAR_VERSION);

src/svr-chansession.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
700700
if (chansess->cmd && strncmp(chansess->cmd, "scp ", 4) == 0 &&
701701
find_multi("scp") && (self = self_exe(NULL))) {
702702
char *ocmd = chansess->cmd;
703-
chansess->cmd = m_asprintf("%s %s", self, ocmd);
703+
chansess->cmd = m_asprintf("%s /%s", self, ocmd);
704704
m_free(ocmd);
705705
}
706706

util/simple-test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ if ! [ "$recursive" ]; then
4444
trap 'set +e; rm -fr "$tmpdir"' EXIT INT TERM
4545
fi
4646

47-
this=$(realpath "$0")
47+
case $0 in
48+
/*) this=$0;;
49+
*) this=$(pwd)/$0;;
50+
esac
4851
cd "$tmpdir"
4952
init_keys
5053
"$D/dbclient" -t -i key -o UserKnownHostsFile=known_hosts \

0 commit comments

Comments
 (0)