[PATCH] dropbear-051: uClinux vfork

Mike Frysinger vapier at gentoo.org
Tue Oct 21 13:01:56 WST 2008


On Saturday 20 September 2008, Jamie Lokier wrote:
> Farrell Aultman wrote:
> > Between dropbear-047 and dropbear-051 changes were made that
> > accounted for the fact that uClinux needs to use vfork instead of
> > fork.  However, fork was not replaced with vfork in all places.  I
> > moved the conditional preproccessor check for uClinux into the
> > includes.h file, so that fork is always replaced with vfork in all
> > of the dropbear code when compiling for uClinux.  A side effect is
> > that the code is cleaner since you just call fork without wrapping
> > it every time with a conditional preprocessor check.
>
> Have you checked that it's safe to call vfork in all those places?
>
> vfork is not always a safe replacement for fork, even on uClinux where
> fork doesn't work.

it istn safe.  the exit() calls need to be updated too.  the patch i wrote is 
here (i could have sworn i posted it already):
--- dropbear-0.51/scp.c
+++ dropbear-0.51/scp.c
@@ -130,13 +130,22 @@
 			fprintf(stderr, " %s", a->list[i]);
 		fprintf(stderr, "\n");
 	}
-	if ((pid = fork()) == -1)
+#ifdef __uClinux__
+	pid = vfork();
+#else
+	pid = fork();
+#endif /* __uClinux__ */
+	if (pid == -1)
 		fatal("do_local_cmd: fork: %s", strerror(errno));
 
 	if (pid == 0) {
 		execvp(a->list[0], a->list);
 		perror(a->list[0]);
+#ifdef __uClinux__
+		_exit(1);
+#else
 		exit(1);
+#endif /* __uClinux__ */
 	}
 
 	do_cmd_pid = pid;
@@ -225,7 +234,11 @@
 
 		execvp(ssh_program, args.list);
 		perror(ssh_program);
+#ifndef __uClinux__
 		exit(1);
+#else
+		_exit(1);
+#endif /* __uClinux__ */
 	} else if (do_cmd_pid == -1) {
 		fatal("fork: %s", strerror(errno));
 	}
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.ucc.gu.uwa.edu.au/pipermail/dropbear/attachments/20081021/2a9ceb33/attachment-0001.pgp 


More information about the Dropbear mailing list