[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Simon Josefsson
Subject: iruserok
Date: Wed, 09 Dec 2009 11:55:39 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

InetUtils rshd failed to build on Mac OS X for another reason:

rshd.c:178: error: conflicting types for 'iruserok'
/usr/include/unistd.h:514: error: previous declaration of 'iruserok' was here

The rshd.c line 178 is:

extern int iruserok (uint32_t raddr, int superuser,
                     const char *ruser, const char *luser);

This conflicts with the Mac OS X unistd.h:

int      iruserok(unsigned long, int, const char *, const char *);

What is interesting here is that glibc do provide a iruserok function
(using the first prototype above) but does not provide a prototype for
it in any header file.  This situation appears to be quite old, the
'iruserok' man page on my debian system says:

       iruserok() is not declared in glibc headers.

The iruserok function is relatively easy to re-implement, if the system
already has 'ruserok', see inetd/rcmd.c from glibc below.  Glibc
provides a prototype for 'ruserok' in its netdb.h.

I think we have some options:

1) Consider iruserok a glibc function, and provide a prototype in our
   netdb.h replacement to work around the bug that the prototype is
   missing.  To solve the ABI compatibility problem (generally uint32_t
   != unsigned long), we need to replace the iruserok function on some
   systems.  (We should also report this as a glibc bug so the prototype
   is added, but we still have to provide a solution for existing
   systems out there without it.)

2) Consider iruserok a broken interface that nobody should be using.
   Then InetUtils will likely just copy the iruserok implementation
   below, so that it is using the more available 'ruserok' interface.

I don't have enough arguments for 2) thus my preference is 1).  Any
objections to this?  Other options?


/* This is the exported version.  */
iruserok_af (raddr, superuser, ruser, luser, af)
     const void *raddr;
     int superuser;
     const char *ruser, *luser;
     sa_family_t af;
  struct sockaddr_storage ra;
  size_t ralen;

  memset (&ra, '\0', sizeof(ra));
  switch (af){
  case AF_INET:
    ((struct sockaddr_in *)&ra)->sin_family = AF_INET;
    memcpy (&(((struct sockaddr_in *)&ra)->sin_addr), raddr,
            sizeof(struct in_addr));
    ralen = sizeof(struct sockaddr_in);
  case AF_INET6:
    ((struct sockaddr_in6 *)&ra)->sin6_family = AF_INET6;
    memcpy (&(((struct sockaddr_in6 *)&ra)->sin6_addr), raddr,
            sizeof(struct in6_addr));
    ralen = sizeof(struct sockaddr_in6);
    return 0;
  return ruserok_sa ((struct sockaddr *)&ra, ralen, superuser, ruser, luser);
libc_hidden_def (iruserok_af)

iruserok (raddr, superuser, ruser, luser)
     u_int32_t raddr;
     int superuser;
     const char *ruser, *luser;
  return iruserok_af (&raddr, superuser, ruser, luser, AF_INET);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]