Bug 146 - OpenSSH 3.1p1 will not build on BSD/OS 4.2/4.1/4.01
Summary: OpenSSH 3.1p1 will not build on BSD/OS 4.2/4.1/4.01
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: -current
Hardware: ix86 BSDI
: P2 major
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
: 155 174 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-08 07:22 AEDT by Spike Ilacqua
Modified: 2004-04-14 12:24 AEST (History)
3 users (show)

See Also:


Attachments
sftp-int.c: cmds[] to sftp_cmds[] (879 bytes, patch)
2002-03-15 05:17 AEDT, Melvyn Sopacua
no flags Details | Diff
Workaround for fake-queue (711 bytes, patch)
2002-03-18 12:54 AEDT, Melvyn Sopacua
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Spike Ilacqua 2002-03-08 07:22:47 AEDT
OpenSSH 3.1p1 will not build on BSD/OS 4.2  Two files fail:

ssh-agent.c: In function `lookup_identity':
ssh-agent.c:135: warning: implicit declaration of function `TAILQ_FOREACH'
ssh-agent.c:135: `next' undeclared (first use in this function)
ssh-agent.c:135: (Each undeclared identifier is reported only once
ssh-agent.c:135: for each function it appears in.)
ssh-agent.c:135: syntax error before `{'
ssh-agent.c:138: warning: control reaches end of non-void function
ssh-agent.c: At top level:
ssh-agent.c:111: warning: `idtab_init' defined but not used
ssh-agent.c:131: warning: `lookup_identity' defined but not used
*** Error code 1

BSDI's <sys/queue.h> lacks TAILQ_FOREACH.  While openbsd-compat/fake-queue.h 
can provide TAILQ_FOREACH, defining HAVE_BOGUS_SYS_QUEUE_H does not work.  
<sys/queue.h> is included by a number of system includes, causing 
_SYS_QUEUE_H_ to be defined by the time fake-queue.h is included which in turn 
ifdefs out all of fake-queue.h.

ssh-rand-helper.c: In function `get_random_bytes_prngd':
ssh-rand-helper.c:154: `ulong' undeclared (first use in this function)
ssh-rand-helper.c:154: (Each undeclared identifier is reported only once
ssh-rand-helper.c:154: for each function it appears in.)
ssh-rand-helper.c:154: syntax error before `0x7f000001'
*** Error code 1 (continuing)

defines.h defines:

#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK ((ulong)0x7f000001)
#endif

It should probably be "u_long".
Comment 1 Ben Lindstrom 2002-03-08 07:38:40 AEDT
I just went through someone with this problem.  And HAVE_BOGUS_SYS_QUEUE_H
worked for them.   However you must have BOTH HAVE_SYS_QUEUE_H and 
HAVE_BOGUS_SYS_QUEUE_H set.

As for INADDR_LOOPBACK.  I'd like to know where on BSD/OS that is defined
so we can check and include it correctly.  Otherwise the correct fix (which
I am verifying with the SCO 3 fokes) is to change it to

#define INADDR_LOOPBACK (0x7f000001L)
Comment 2 Spike Ilacqua 2002-03-08 11:38:26 AEDT
> I just went through someone with this problem.  And HAVE_BOGUS_SYS_QUEUE_H
> worked for them.   However you must have BOTH HAVE_SYS_QUEUE_H and 
> HAVE_BOGUS_SYS_QUEUE_H set.

I tried this, and had no luck.  As a test I even removed the #ifdefs
in ssh-agent.c to force fake-queue.h to be included.  If I'm reading
gcc -E right, and it's been a long time since I have, the problem lies
in <sys/queue.h> getting included before fake-queue.h.  The include
path looks like:

includes.h -> config.h -> defines.h -> <netinet/in.h> ->
<netinet6/in6.h> -> <sys/queue.h>

Then <sys/queue.h> defines _SYS_QUEUE_H_ so that when fake-queue.h,
it's all ifdef'ed out (and of course it would explode if both were
included).

I pasted the define for TAILQ_FOREACH into ssh-agent.c and it compiles
fine.  So it's probably just a case of finding a more graceful way of
doing that.

> As for INADDR_LOOPBACK.  I'd like to know where on BSD/OS that is defined
> so we can check and include it correctly.

It's defined in <rpc/types.h>:

#ifndef INADDR_LOOPBACK
#define       INADDR_LOOPBACK         (u_long)0x7F000001
#endif

I included that in defines.h and it compiled as well.

Having done that I installed 3.1p1.  The server works fine, but the
clients all failed with:

(rand child) setuid: Operation not permitted
ssh-rand-helper child produced insufficient data

Removing the setuid bit from "ssh" solved this problem.  Digging a
little deeper it looks like original_uid and original_euid are never
initialized.

->Spike

Comment 3 Melvyn Sopacua 2002-03-15 05:17:11 AEDT
Created attachment 44 [details]
sftp-int.c: cmds[] to sftp_cmds[]
Comment 4 Melvyn Sopacua 2002-03-15 05:19:33 AEDT
On a 4.1 system I had the same errors and an additional one.

The fake-queue, was fixable by:
CFLAGS=-DHAVE_BOGUS_SYS_QUEUE_H=1

The additional error is in sftp-int.c.
The build fails on:
gcc -o sftp sftp.o sftp-client.o sftp-common.o sftp-int.o sftp-glob.o -L.
-Lopenbsd-compat/ -L/weblib/local/lib -L/usr/lib -Lyes  -lssh -l
openbsd-compat -lutil -lz  -lcrypto
/usr/lib/libc.a(prandom.o)(.data+0x0): multiple definition of `cmds'
sftp-int.o(.rodata+0x48): first defined here
ld: Warning: size of symbol `cmds' changed from 256 to 40 in prandom.o
make: *** [sftp] Error 1

I renamed cmds to sftp_cmds and all is well. See uploaded patch.
Comment 5 Ben Lindstrom 2002-03-15 06:52:58 AEDT
Why are we renaming things without any reasoning behind it?
Comment 6 Melvyn Sopacua 2002-03-15 18:22:02 AEDT
The reasoning is, that this bug is similar to:
http://www.openldap.org/lists/openldap-bugs/200005/msg00032.html

And that prandom.o is in libc.
Another reason is, that 'cmds' is likely to conflict unless you protect it,
since it's quite a common name.
I don't know the reason for using sftp's own structure, instead of using the
libc provided structure, so if it can be modified to use libc's.

The only reference to cmds I found in /usr/include was:
/usr/include/arpa/telnet.h
Which also uses it's own name:
#ifdef TELCMDS
char *telcmds[] = {
        "EOF", "SUSP", "ABORT", "EOR",
        "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
        "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
};
#else
extern char *telcmds[];
#endif

So it seemed the logical thing to do.
Comment 7 Markus Friedl 2002-03-18 07:22:53 AEDT
why not have the array static?
Comment 8 Melvyn Sopacua 2002-03-18 12:54:09 AEDT
Created attachment 47 [details]
Workaround for fake-queue
Comment 9 Melvyn Sopacua 2002-03-18 13:03:16 AEDT
The patch for fake-queue.h works, but just looks ugly.
Since <sys/param.h> is the one <sys/queue.h>, and the full path becomes:
"includes.h" -> "config.h" -> "defines.h" -> <sys/param.h>

I wasn't able to come up with a better solution.
The #undef's are there to get rid of the 'redefinition' warnings.

That it works on 4.1 is probably, because for some reason somewhere, KERNEL is
defined on 4.2 before including <sys/param.h> while it isn't on 4.1.

As for the static cmds[], that seemed to do the trick quite well.
Comment 10 Melvyn Sopacua 2002-03-18 23:05:55 AEDT
*** Bug 155 has been marked as a duplicate of this bug. ***
Comment 11 Markus Friedl 2002-03-20 07:21:13 AEDT
*** Bug 174 has been marked as a duplicate of this bug. ***
Comment 12 Ben Lindstrom 2002-04-06 06:32:45 AEST
I just commited a patch that does the following:

- Removes all attempt to detect/use system <sys/queue.h>
- #undef all macros in fake-queue.h 
- changes the #ifdef/#define/#endif wrapper from _SYS_QUEUE to _FAKE_QUEUE
- Uses our fake-queue.h always

It should be out on the CVS mirrors within a few hours.

If this does not resolve the issue please reopen before 3.2 release.
- Ben
Comment 13 Damien Miller 2004-04-14 12:24:18 AEST
Mass change of RESOLVED bugs to CLOSED