scp linking problem on solaris 2.6 (x86)

Wayne Davison wayne at blorf.net
Sat May 19 18:43:52 EST 2001


I'm seeing a linking problem with scp on Solaris 2.6 that I'm not seeing
on Linux (Mandrake 8).  It boils down to Solaris not having mkdtemp(),
and the mkdtemp() compatibility function referencing arc4random(), which
calls seed_rng().  Since that function is back in libssh.a, we get a
function-not-found link error.  I added -lssh after -lopenbsd_compat on
scp's build rule (so it is listed twice):

scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o
	$(LD) -o $@ scp.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)

Another solution might be to call seed_rng() from inside scp.c (so the
function gets picked up the first time around).

While I was looking into this, I noticed something that looks odd to me
in bsd-arc4random.c.  Do we really want to seed the r.n.g. every time we
call arc4random() *except* the first time?  Or did we want to seed the
r.n.g. only on the first time?  If the latter, we need this patch:

Index: openbsd-compat/bsd-arc4random.c
@@ -48,9 +48,10 @@
 	static int first_time = 1;

 	if (rc4_ready <= 0) {
-		if (!first_time)
+		if (first_time) {
 			seed_rng();
-		first_time = 0;
+			first_time = 0;
+		}
 		arc4random_stir();
 	}

If the code was really correct, I suggest rewriting it to be a little
more explicit.  Like this:

		if (first_time)
			first_time = 0;
		else
			seed_rng();

..wayne..




More information about the openssh-unix-dev mailing list