qnx v4.25G: porting vsftpd, help to find the missing library

I’m porting vsftpd to QNX v4.25G, I managed to hack the sources (mostly
removing any IPv6 references) so they do compile with Watcom v10.6 patch B

  • Security patch.

I’m stuck on linking.
I cannot figure out what the library I’ve forgot to include - these are
the undefined symbols:
dirfd_
setgroups_
initgroups_
getusershell_
endusershell_

Please help!

Tony.

(PS While I was hacking it vsftps has got to v1.2.2)

I think you need login3r.lib

Tony wrote:

I’m porting vsftpd to QNX v4.25G, I managed to hack the sources (mostly
removing any IPv6 references) so they do compile with Watcom v10.6 patch
B + Security patch.

I’m stuck on linking.
I cannot figure out what the library I’ve forgot to include - these are
the undefined symbols:
dirfd_
setgroups_
initgroups_
getusershell_
endusershell_

Please help!

Tony.

(PS While I was hacking it vsftps has got to v1.2.2)


cburgess@qnx.com

On Thu, 29 Apr 2004 08:13:53 -0400, Colin Burgess <cburgess@qnx.com> wrote:

I think you need login3r.lib
Where do I get it?

There is no such library neither in /usr/lib nor in
/usr/watcom/10.6/usr/lib on my system.

Tony.

On Thu, 29 Apr 2004 08:13:53 -0400, Colin Burgess <cburgess@qnx.com> wrote:

I think you need login3r.lib

Thank you, I’ve found it here:
ftp://ftp.qnx.com/usr/free/qnx4/os/utils/misc/login3r.lib

Will try to use it at once!

Tony.

On Thu, 29 Apr 2004 08:13:53 -0400, Colin Burgess <cburgess@qnx.com> wrote:

I think you need login3r.lib

No, this library did not resolve the symbols.

And even more - I’m afraid it’s more likely to introduce various errors
while managing the passwords - seems it is not “QNX Security
patch”-compatible.

Will it ever be updated and where to find the documentation on the modules
in it?

Looking closer, I don’t think you will find the functions mentioned.

QNX4 doesn’t support supplemental groups, so setgroups should just be
stubbed out, and initgroups should probably just call setgid()

As for getusershell() and endusershell(), you can get the users shell by
call getpwent() and looking at the pw->pw_shell entry.

I hope this helps…

Colin

Tony wrote:

On Thu, 29 Apr 2004 08:13:53 -0400, Colin Burgess <> cburgess@qnx.com> > wrote:

I think you need login3r.lib


No, this library did not resolve the symbols.

And even more - I’m afraid it’s more likely to introduce various errors
while managing the passwords - seems it is not “QNX Security
patch”-compatible.

Will it ever be updated and where to find the documentation on the
modules in it?


cburgess@qnx.com

On Thu, 29 Apr 2004 12:21:12 -0400, Colin Burgess <cburgess@qnx.com>
wrote:

Looking closer, I don’t think you will find the functions mentioned.

QNX4 doesn’t support supplemental groups, so setgroups should just be
stubbed out, and initgroups should probably just call setgid()

As for getusershell() and endusershell(), you can get the users shell by
call getpwent() and looking at the pw->pw_shell entry.

I hope this helps…

Colin
By this minute I’ve found all the *.c sources but setgroups.c and

initgroups.c, so only these two symbols left unresolved.

Thank you for the advice, I’ll try not to plug but rather stub the code
now.
:slight_smile:

Tony.

This is a snip from dirent.h file:

/*

  • dirent.h Portable directory entry definitions
  • Copyright by QNX Software Systems Limited 1990-1993. All rights
    reserved.
  • Copyright by WATCOM International Corp. 1988-1993. All rights
    reserved.
    */

typedef struct _dir {
short dd_fd, /* file descriptor /
dd_loc, /
index into array /
dd_size; /
num array elements /
struct dirent dd_buf[_DIRBUF]; /
_dir_entry array /
char dd_prefixes[PATH_MAX + 1]; /
qnx_prefix_query */
} DIR;

extern DIR *opendir( const char *__dirname );
extern struct dirent *readdir( DIR *__dirp );
extern void rewinddir( DIR *__dirp );
extern int closedir( DIR *__dirp );

The question is:
short dd_fd - is it a directory file descriptor?

The dirfd.c I’ve plugged in looks this way:
#include <sys/types.h>
#include “dietdirent.h”
#define _BSD_SOURCE
#include <dirent.h>

int dirfd(DIR* dirp) {
return dirp->fd;
}

I had to change “return dirp->fd;” with “return dirp->dd_fd;” (and comment
out #include “dietdirent.h”).
Was I wrong?

Be careful of struct dir vs struct dirent

I believe that the qnx4 readdir returned the ‘other’ one to what a lot
of unix code expects…

Tony wrote:

This is a snip from dirent.h file:

/*

  • dirent.h Portable directory entry definitions
  • Copyright by QNX Software Systems Limited 1990-1993. All rights
    reserved.
  • Copyright by WATCOM International Corp. 1988-1993. All rights
    reserved.
    */

typedef struct _dir {
short dd_fd, /* file descriptor /
dd_loc, /
index into array /
dd_size; /
num array elements /
struct dirent dd_buf[_DIRBUF]; /
_dir_entry array /
char dd_prefixes[PATH_MAX + 1]; /
qnx_prefix_query */
} DIR;

extern DIR *opendir( const char *__dirname );
extern struct dirent *readdir( DIR *__dirp );
extern void rewinddir( DIR *__dirp );
extern int closedir( DIR *__dirp );

The question is:
short dd_fd - is it a directory file descriptor?

The dirfd.c I’ve plugged in looks this way:
#include <sys/types.h
#include “dietdirent.h”
#define _BSD_SOURCE
#include <dirent.h

int dirfd(DIR* dirp) {
return dirp->fd;
}

I had to change “return dirp->fd;” with “return dirp->dd_fd;” (and
comment out #include “dietdirent.h”).
Was I wrong?


cburgess@qnx.com

I’m currently reading this:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=dirfd
What’s the difference between opendir() and dirfd() ?

Chris Evans, the author of vsftpd has provided “dirdf_extras.h” file to be
included on HPUX, AIX, IRIX:
#ifndef VSF_DIRFD_EXTRAS_H
#define VSF_DIRFD_EXTRAS_H

#define dirfd(x) ((x)->dd_fd)

#endif /* VSF_DIRFD_EXTRAS_H */

Here is the code in sysutil.c file to be ported:
void
vsf_sysutil_dir_stat(const struct vsf_sysutil_dir* p_dir,
struct vsf_sysutil_statbuf** p_ptr)
{
int fd = dirfd((DIR*) p_dir);
vsf_sysutil_fstat(fd, p_ptr);
}

If I just include “dirfd_extras.h”, I get “undefined symbol dirfd_”
warning.
If I put this dirfd.c source:
#include <sys/types.h>
#define _BSD_SOURCE
#include <dirent.h>

int dirfd(DIR* dirp) {
return dirp->fd;
}
I get “Name ‘fd’ not found in struct/union _dir” error, no matter if
“dirdf_extras.h” is included or not.

Please comment.
Tony.

I’m currently reading this:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=dirfd
What’s the difference between opendir() and dirfd() ?

Chris Evans, the author of vsftpd has provided “dirdf_extras.h” file to be
included on HPUX, AIX, IRIX:
#ifndef VSF_DIRFD_EXTRAS_H
#define VSF_DIRFD_EXTRAS_H

#define dirfd(x) ((x)->dd_fd)

#endif /* VSF_DIRFD_EXTRAS_H */

Here is the code in sysutil.c file to be ported:
void
vsf_sysutil_dir_stat(const struct vsf_sysutil_dir* p_dir,
struct vsf_sysutil_statbuf** p_ptr)
{
int fd = dirfd((DIR*) p_dir);
vsf_sysutil_fstat(fd, p_ptr);
}

If I just include “dirfd_extras.h”, I get “undefined symbol dirfd_”
warning.
If I put this dirfd.c source:
#include <sys/types.h>
#define _BSD_SOURCE
#include <dirent.h>

int dirfd(DIR* dirp) {
return dirp->fd;
}
I get “Name ‘fd’ not found in struct/union _dir” error, no matter if
“dirdf_extras.h” is included or not.

Please comment.
Tony.

I’m currently reading this:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=dirfd
What’s the difference between opendir() and dirfd() ?

Chris Evans, the author of vsftpd has provided “dirdf_extras.h” file to be
included on HPUX, AIX, IRIX:
#ifndef VSF_DIRFD_EXTRAS_H
#define VSF_DIRFD_EXTRAS_H

#define dirfd(x) ((x)->dd_fd)

#endif /* VSF_DIRFD_EXTRAS_H */

Here is the code in sysutil.c file to be ported:
void
vsf_sysutil_dir_stat(const struct vsf_sysutil_dir* p_dir,
struct vsf_sysutil_statbuf** p_ptr)
{
int fd = dirfd((DIR*) p_dir);
vsf_sysutil_fstat(fd, p_ptr);
}

If I just include “dirfd_extras.h”, I get “undefined symbol dirfd_”
warning.
If I put this dirfd.c source:
#include <sys/types.h>
#define _BSD_SOURCE
#include <dirent.h>

int dirfd(DIR* dirp) {
return dirp->fd;
}
I get “Name ‘fd’ not found in struct/union _dir” error, no matter if
“dirdf_extras.h” is included or not.

By the way, snip from fnctl.h, note that F_SETOWN and F_GETOWN are
commented out:
/*

  • fcntl.h File control options used by open
  • Copyright by WATCOM International Corp. 1988-1996. All rights
    reserved.
  • Copyright by QNX Software Systems Limited 1990-1996. All rights
    reserved.
    */

/*

  • fcntl() requests
    */

#define F_GETFL 3 /* Get file status flags /
#define F_SETFL 4 /
Set file status flags */

/#define F_GETOWN 35/ /* get SIGIO/SIGURG proc/pgrp /
/
#define F_SETOWN 36*/ /* set SIGIO/SIGURG proc/pgrp */

#define F_SETLK 6 /* Set record locking info /
#define F_SETLKW 7 /
Set record locking info; */

Here is the code that needs them:
void
vsf_sysutil_activate_sigurg(int fd)
{
int retval = fcntl(fd, F_SETOWN, getpid());
if (retval != 0)
{
die(“fcntl”);
}
}

My I uncomment F_GETOWN and F_SETOWN? If not - what should I do?

Please comment.
Tony.

Tony wrote:

I’m currently reading this:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=dirfd
What’s the difference between opendir() and dirfd() ?

opendir returns a DIR *

a DIR contains a dd_fd

these are defined in /usr/include/dirent.h

Chris Evans, the author of vsftpd has provided “dirdf_extras.h” file to
be included on HPUX, AIX, IRIX:
#ifndef VSF_DIRFD_EXTRAS_H
#define VSF_DIRFD_EXTRAS_H

#define dirfd(x) ((x)->dd_fd)

#endif /* VSF_DIRFD_EXTRAS_H */

Here is the code in sysutil.c file to be ported:
void
vsf_sysutil_dir_stat(const struct vsf_sysutil_dir* p_dir,
struct vsf_sysutil_statbuf** p_ptr)
{
int fd = dirfd((DIR*) p_dir);
vsf_sysutil_fstat(fd, p_ptr);
}

I believe this code should work.

If I just include “dirfd_extras.h”, I get “undefined symbol dirfd_”
warning.
If I put this dirfd.c source:
#include <sys/types.h
#define _BSD_SOURCE
#include <dirent.h

int dirfd(DIR* dirp) {
return dirp->fd;
}
I get “Name ‘fd’ not found in struct/union _dir” error, no matter if
“dirdf_extras.h” is included or not.

By the way, snip from fnctl.h, note that F_SETOWN and F_GETOWN are
commented out:
/*

  • fcntl.h File control options used by open
  • Copyright by WATCOM International Corp. 1988-1996. All rights
    reserved.
  • Copyright by QNX Software Systems Limited 1990-1996. All rights
    reserved.
    */

/*

  • fcntl() requests
    */

#define F_GETFL 3 /* Get file status flags /
#define F_SETFL 4 /
Set file status flags */

/#define F_GETOWN 35/ /* get SIGIO/SIGURG proc/pgrp /
/
#define F_SETOWN 36*/ /* set SIGIO/SIGURG proc/pgrp */

#define F_SETLK 6 /* Set record locking info /
#define F_SETLKW 7 /
Set record locking info; */

Here is the code that needs them:
void
vsf_sysutil_activate_sigurg(int fd)
{
int retval = fcntl(fd, F_SETOWN, getpid());
if (retval != 0)
{
die(“fcntl”);
}
}

My I uncomment F_GETOWN and F_SETOWN? If not - what should I do?

I don’t think QNX4 supported O_ASYNC, so you would have to rewrite to
use dev_read() or select() to handle asychronous notification.

I might also mention that it’s been about 6-7 years since I’ve done any
QNX4 porting work.

Ah, the good ol’ days! ;v)

Of course with QNX6, things generally just work… :vD

cburgess@qnx.com

By the way, snip from fnctl.h, note that F_SETOWN and F_GETOWN are
commented out:
/*

  • fcntl.h File control options used by open
  • Copyright by WATCOM International Corp. 1988-1996. All rights
    reserved.
  • Copyright by QNX Software Systems Limited 1990-1996. All rights
    reserved.
    */

/*

  • fcntl() requests
    */

/#define F_GETOWN 35/ /* get SIGIO/SIGURG proc/pgrp /
/
#define F_SETOWN 36*/ /* set SIGIO/SIGURG proc/pgrp */

Here is the code that needs them:
void
vsf_sysutil_activate_sigurg(int fd)
{
int retval = fcntl(fd, F_SETOWN, getpid());
if (retval != 0)
{
die(“fcntl”);
}
}

May I uncomment F_GETOWN and F_SETOWN? If not - what should I do?

I don’t think QNX4 supported O_ASYNC, so you would have to rewrite to
use dev_read() or select() to handle asychronous notification.

Hm…
Who among the UNIXes is the closest relative (sister, cousine,
mother-in-law) to QNX4? I need to read more on the topic…

T > Hm…
T > Who among the UNIXes is the closest relative (sister, cousine,
T > mother-in-law) to QNX4? I need to read more on the topic…


From the OS point of view, QNX4 is pretty much it’s own beast.

There are two good books for QNX4. One is by Frank Kolnick and the
other is by Robert Krten. Since QNX4 is now getting old I doubt you’ll
still find these in bookstores. But you can order the Krten book from
his web site at www.parse.com.

Good luck.

Bill Caroselli <qtps@earthlink.net> wrote:

T > Hm…
T > Who among the UNIXes is the closest relative (sister, cousine,
T > mother-in-law) to QNX4? I need to read more on the topic…


From the OS point of view, QNX4 is pretty much it’s own beast.

There are two good books for QNX4. One is by Frank Kolnick and the
other is by Robert Krten. Since QNX4 is now getting old I doubt you’ll
still find these in bookstores.

Both books are still available from amazon:
Frank’s book:
http://www.amazon.com/exec/obidos/ASIN/0921960018/openqntheqnxc-20
Robert’s book:
http://www.amazon.com/exec/obidos/ASIN/0968250106/openqntheqnxc-20

Good luck!

Frank Liu <fliu@usdjmp1.eng.vodafone-us.com> wrote:

Bill Caroselli <> qtps@earthlink.net> > wrote:
T > Hm…
T > Who among the UNIXes is the closest relative (sister, cousine,
T > mother-in-law) to QNX4? I need to read more on the topic…


From the OS point of view, QNX4 is pretty much it’s own beast.

There are two good books for QNX4. One is by Frank Kolnick and the
other is by Robert Krten. Since QNX4 is now getting old I doubt you’ll
still find these in bookstores.

Both books are still available from amazon:
Frank’s book:
http://www.amazon.com/exec/obidos/ASIN/0921960018/openqntheqnxc-20
Robert’s book:
http://www.amazon.com/exec/obidos/ASIN/0968250106/openqntheqnxc-20

Mine are not available from Amazon. Too much grief. :frowning:

Try www.parse.com/products/ordering.html for a list of distributors.
QSSL carries all three books… or you can order directly from
us +1 877 727 7379 (toll free NA) +1 613 599 8316 international.

Cheers,
-RK


[If replying via email, you’ll need to click on the URL that’s emailed to you
afterwards to forward the email to me – spam filters and all that]
Robert Krten, PDP minicomputer collector http://www.parse.com/~pdp8/