Back to index

glibc  2.9
Functions | Variables
nislib.h File Reference
#include <features.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nis_result * nis_lookup (const_nis_name name, unsigned int flags) __THROW
nis_result * nis_add (const_nis_name name, const nis_object *obj) __THROW
nis_result * nis_remove (const_nis_name name, const nis_object *obj) __THROW
nis_result * nis_modify (const_nis_name name, const nis_object *obj) __THROW
nis_result * nis_list (const_nis_name name, unsigned int flags, int(*callback)(const_nis_name table_name, const nis_object *obj, const void *userdata), const void *userdata) __THROW
nis_result * nis_add_entry (const_nis_name table_name, const nis_object *obj, unsigned int flags) __THROW
nis_result * nis_modify_entry (const_nis_name name, const nis_object *obj, unsigned int flags) __THROW
nis_result * nis_remove_entry (const_nis_name table_name, const nis_object *obj, unsigned int flags) __THROW
nis_result * nis_first_entry (const_nis_name table_name) __THROW
nis_result * nis_next_entry (const_nis_name table_name, const netobj *cookie) __THROW
nis_error nis_mkdir (const_nis_name dirname, const nis_server *machine) __THROW
nis_error nis_rmdir (const_nis_name dirname, const nis_server *machine) __THROW
nis_error nis_servstate (const nis_server *machine, const nis_tag *tags, int numtags, nis_tag **result) __THROW
nis_error nis_stats (const nis_server *machine, const nis_tag *tags, int numtags, nis_tag **result) __THROW
void nis_freetags (nis_tag *tags, int numtags) __THROW
nis_server ** nis_getservlist (const_nis_name dirname) __THROW
void nis_freeservlist (nis_server **machines) __THROW
nis_name nis_leaf_of (const_nis_name name) __THROW
nis_name nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen) __THROW
nis_name nis_name_of (const_nis_name name) __THROW
nis_name nis_name_of_r (const_nis_name name, char *buffer, size_t buflen) __THROW
nis_name nis_domain_of (const_nis_name name) __THROW
nis_name nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen) __THROW
nis_namenis_getnames (const_nis_name name) __THROW
void nis_freenames (nis_name *namelist) __THROW
name_pos nis_dir_cmp (const_nis_name n1, const_nis_name n2) __THROW
nis_object * nis_clone_object (const nis_object *src, nis_object *dest) __THROW
void nis_destroy_object (nis_object *obj) __THROW
void nis_print_object (const nis_object *obj) __THROW
nis_name nis_local_group (void) __THROW
nis_name nis_local_directory (void) __THROW
nis_name nis_local_principal (void) __THROW
nis_name nis_local_host (void) __THROW
const char * nis_sperrno (const nis_error status) __THROW
void nis_perror (const nis_error status, const char *label) __THROW
void nis_lerror (const nis_error status, const char *label) __THROW
char * nis_sperror (const nis_error status, const char *label) __THROW
char * nis_sperror_r (const nis_error status, const char *label, char *buffer, size_t buflen) __THROW
bool_t nis_ismember (const_nis_name principal, const_nis_name group) __THROW
nis_error nis_addmember (const_nis_name member, const_nis_name group) __THROW
nis_error nis_removemember (const_nis_name member, const_nis_name group) __THROW
nis_error nis_creategroup (const_nis_name group, unsigned int flags) __THROW
nis_error nis_destroygroup (const_nis_name group) __THROW
void nis_print_group_entry (const_nis_name group) __THROW
nis_error nis_verifygroup (const_nis_name group) __THROW
void nis_ping (const_nis_name dirname, uint32_t utime, const nis_object *dirobj) __THROW
nis_result * nis_checkpoint (const_nis_name dirname) __THROW
void nis_print_result (const nis_result *result) __THROW
void nis_print_rights (unsigned int rights) __THROW
void nis_print_directory (const directory_obj *dirobj) __THROW
void nis_print_group (const group_obj *grpobj) __THROW
void nis_print_table (const table_obj *tblobj) __THROW
void nis_print_link (const link_obj *lnkobj) __THROW
void nis_print_entry (const entry_obj *enobj) __THROW
directory_obj * readColdStartFile (void) __THROW
bool_t writeColdStartFile (const directory_obj *dirobj) __THROW
nis_object * nis_read_obj (const char *obj) __THROW
bool_t nis_write_obj (const char *file, const nis_object *obj) __THROW
directory_obj * nis_clone_directory (const directory_obj *src, directory_obj *dest) __THROW
nis_result * nis_clone_result (const nis_result *src, nis_result *dest) __THROW
void nis_freeresult (nis_result *result) __THROW
void nis_free_request (ib_request *req) __THROW
void nis_free_directory (directory_obj *dirobj) __THROW
void nis_free_object (nis_object *obj) __THROW
nis_name __nis_default_owner (char *) __THROW
nis_name __nis_default_group (char *) __THROW
uint32_t __nis_default_ttl (char *) __THROW
unsigned int __nis_default_access (char *, unsigned int) __THROW
fd_result * __nis_finddirectory (directory_obj *, const_nis_name) __THROW
void __free_fdresult (fd_result *) __THROW
uint32_t __nis_hash (const void *keyarg, register size_t len) __THROW
int __nis_lock_cache (void) __THROW
int __nis_unlock_cache (void) __THROW

Variables

__BEGIN_DECLS typedef const char * const_nis_name

Function Documentation

void __free_fdresult ( fd_result *  )

Definition at line 24 of file nis_free.c.

{
  if (res != NULL)
    {
      xdr_free ((xdrproc_t)_xdr_fd_result, (char *)res);
      free (res);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int __nis_default_access ( char *  ,
unsigned  int 
)

Definition at line 434 of file nis_defaults.c.

{
  unsigned int result;
  char *cptr;

  if (defaults == 0)
    result = 0 | OWNER_DEFAULT | GROUP_DEFAULT | WORLD_DEFAULT;
  else
    result = defaults;

  if (param != NULL && strstr (param, "access=") != NULL)
    result = searchaccess (param, result);
  else
    {
      cptr = getenv ("NIS_DEFAULTS");
      if (cptr != NULL && strstr (cptr, "access=") != NULL)
       result = searchaccess (cptr, result);
    }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 355 of file nis_defaults.c.

{
  char *default_owner = NULL;

  char *cptr = defaults;
  if (cptr == NULL)
    cptr = getenv ("NIS_DEFAULTS");

  if (cptr != NULL)
    {
      char *dptr = strstr (cptr, "owner=");
      if (dptr != NULL)
       {
         char *p = searchowner (dptr);
         if (p == NULL)
           return NULL;
         default_owner = strdupa (p);
         free (p);
       }
    }

  return strdup (default_owner ?: nis_local_principal ());
}

Here is the call graph for this function:

Here is the caller graph for this function:

fd_result* __nis_finddirectory ( directory_obj *  ,
const_nis_name   
)

Definition at line 27 of file nis_util.c.

{
  nis_error status;
  fd_args fd_args;
  fd_result *fd_res;

  fd_args.dir_name = (char *)name;
  fd_args.requester = nis_local_host();
  fd_res = calloc (1, sizeof (fd_result));
  if (fd_res == NULL)
    return NULL;

  status = __do_niscall2 (dir->do_servers.do_servers_val,
                       dir->do_servers.do_servers_len,
                       NIS_FINDDIRECTORY, (xdrproc_t) _xdr_fd_args,
                       (caddr_t) &fd_args, (xdrproc_t) _xdr_fd_result,
                       (caddr_t) fd_res, NO_AUTHINFO|USE_DGRAM, NULL);
  if (status != NIS_SUCCESS)
    fd_res->status = status;

  return fd_res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t __nis_hash ( const void *  keyarg,
register size_t  len 
)

Definition at line 33 of file nis_hash.c.

{
  register const u_char *key;
  register size_t loop;
  register uint32_t h;

#define HASHC   h = *key++ + 65599 * h

  h = 0;
  key = keyarg;
  if (len > 0)
    {
      loop = (len + 8 - 1) >> 3;
      switch (len & (8 - 1))
       {
       case 0:
         do {
           HASHC;
           /* FALLTHROUGH */
         case 7:
           HASHC;
           /* FALLTHROUGH */
         case 6:
           HASHC;
           /* FALLTHROUGH */
         case 5:
           HASHC;
           /* FALLTHROUGH */
         case 4:
           HASHC;
           /* FALLTHROUGH */
         case 3:
           HASHC;
           /* FALLTHROUGH */
         case 2:
           HASHC;
           /* FALLTHROUGH */
         case 1:
           HASHC;
         } while (--loop);
       }
    }
  return h;
}

Here is the caller graph for this function:

int __nis_lock_cache ( void  )
int __nis_unlock_cache ( void  )
nis_result* nis_add ( const_nis_name  name,
const nis_object *  obj 
)

Definition at line 27 of file nis_add.c.

{
  nis_object obj;
  nis_result *res;
  nis_error status;
  struct ns_request req;
  size_t namelen = strlen (name);
  char buf1 [namelen + 20];
  char buf4 [namelen + 20];

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  req.ns_name = (char *)name;

  memcpy (&obj, obj2, sizeof (nis_object));

  if (obj.zo_name == NULL || obj.zo_name[0] == '\0')
    obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));

  if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0')
    obj.zo_owner = nis_local_principal ();

  if (obj.zo_group == NULL || obj.zo_group[0] == '\0')
    obj.zo_group = nis_local_group ();

  obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));

  req.ns_object.ns_object_val = nis_clone_object (&obj, NULL);
  if (req.ns_object.ns_object_val == NULL)
    {
      NIS_RES_STATUS (res) = NIS_NOMEMORY;
      return res;
    }
  req.ns_object.ns_object_len = 1;

  status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
                      NIS_ADD, (xdrproc_t) _xdr_ns_request,
                      (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
                      (caddr_t) res, MASTER_ONLY, NULL);
  if (status != RPC_SUCCESS)
    NIS_RES_STATUS (res) = status;

  nis_destroy_object (req.ns_object.ns_object_val);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_add_entry ( const_nis_name  table_name,
const nis_object *  obj,
unsigned int  flags 
)
nis_error nis_addmember ( const_nis_name  member,
const_nis_name  group 
)

Definition at line 25 of file nis_addmember.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 14 + NIS_MAXNAMELEN];
      char domainbuf[grouplen + 2];
      nis_result *res, *res2;
      nis_error status;
      char *cp, *cp2;

      cp = rawmemchr (nis_leaf_of_r (group, buf, sizeof (buf) - 1), '\0');
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
        {
         *cp++ = '.';
          stpcpy (cp, cp2);
        }
      res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME);
      if (NIS_RES_STATUS (res) != NIS_SUCCESS)
       {
         status = NIS_RES_STATUS (res);
         nis_freeresult (res);
         return status;
       }
      if (NIS_RES_NUMOBJ (res) != 1
         || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)
       {
         nis_freeresult (res);
         return NIS_INVALIDOBJ;
       }

      u_int gr_members_len
       = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len;

      nis_name *new_gr_members_val
       = realloc (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val,
                 (gr_members_len + 1) * sizeof (nis_name));
      if (new_gr_members_val == NULL)
       goto nomem_out;

      NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val
       = new_gr_members_val;

      new_gr_members_val[gr_members_len] = strdup (member);
      if (new_gr_members_val[gr_members_len] == NULL)
       {
       nomem_out:
         nis_freeresult (res);
         return NIS_NOMEMORY;
       }
      ++NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len;

      /* Check the buffer bounds are not exceeded.  */
      assert (strlen (NIS_RES_OBJECT(res)->zo_name) + 1 < grouplen + 14);
      cp = stpcpy (buf, NIS_RES_OBJECT(res)->zo_name);
      *cp++ = '.';
      strncpy (cp, NIS_RES_OBJECT (res)->zo_domain, NIS_MAXNAMELEN);
      res2 = nis_modify (buf, NIS_RES_OBJECT (res));
      status = NIS_RES_STATUS (res2);
      nis_freeresult (res);
      nis_freeresult (res2);

      return status;
    }
  else
    return NIS_FAIL;
}

Here is the call graph for this function:

nis_result* nis_checkpoint ( const_nis_name  dirname)

Definition at line 27 of file nis_checkpoint.c.

{
  nis_result *res;

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  if (dirname != NULL)
    {
      nis_result *res2;
      u_int i;

      res2 = nis_lookup (dirname, EXPAND_NAME);
      if (NIS_RES_STATUS (res2) != NIS_SUCCESS)
       {
         free (res);
         return res2;
       }

      /* Check if obj is really a diryectory object */
      if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ)
       {
         nis_freeresult (res2);
         NIS_RES_STATUS (res) = NIS_INVALIDOBJ;
         return res;
       }

      for (i = 0;
          i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i)
       {
         cp_result cpres;

         memset (&cpres, '\0', sizeof (cp_result));
         if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i],
                          1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name,
                          (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result,
                          (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS)
           NIS_RES_STATUS (res) = NIS_RPCERROR;
         else
           {
             NIS_RES_STATUS (res) = cpres.cp_status;
             res->zticks += cpres.cp_zticks;
             res->dticks += cpres.cp_dticks;
           }
       }
      nis_freeresult (res2);
    }
  else
    NIS_RES_STATUS (res) = NIS_NOSUCHNAME;

  return res;
}

Here is the call graph for this function:

directory_obj* nis_clone_directory ( const directory_obj *  src,
directory_obj *  dest 
)

Definition at line 27 of file nis_clone_dir.c.

{
  char *addr;
  unsigned int size;
  XDR xdrs;

  if (src == NULL)
    return NULL;

  size = xdr_sizeof ((xdrproc_t)_xdr_directory_obj, (char *)src);
  if ((addr = calloc(1, size)) == NULL)
    return NULL;

  xdrmem_create(&xdrs, addr, size, XDR_ENCODE);
  if (!_xdr_directory_obj (&xdrs, (directory_obj *)src))
    {
      xdr_destroy (&xdrs);
      free (addr);
      return NULL;
    }
  xdr_destroy (&xdrs);

  directory_obj *res;
  if (dest == NULL)
    {
      if ((res = calloc (1, sizeof (directory_obj))) == NULL)
       {
         free (addr);
         return NULL;
       }
    }
  else
    res = dest;

  xdrmem_create (&xdrs, addr, size, XDR_DECODE);
  if (!_xdr_directory_obj (&xdrs, res))
    {
      xdr_destroy (&xdrs);
      if (res != dest)
       free (res);
      free (addr);
      return NULL;
    }
  xdr_destroy (&xdrs);
  free (addr);

  return res;
}

Here is the call graph for this function:

nis_object* nis_clone_object ( const nis_object *  src,
nis_object *  dest 
)

Definition at line 27 of file nis_clone_obj.c.

{
  char *addr;
  unsigned int size;
  XDR xdrs;
  nis_object *res = NULL;

  if (src == NULL)
    return (NULL);

  size = xdr_sizeof ((xdrproc_t)_xdr_nis_object, (char *) src);
  if ((addr = calloc (1, size)) == NULL)
    return NULL;

  if (dest == NULL)
    {
      if ((res = calloc (1, sizeof (nis_object))) == NULL)
       goto out;
    }
  else
    res = dest;

  xdrmem_create (&xdrs, addr, size, XDR_ENCODE);
  if (!_xdr_nis_object (&xdrs, (nis_object *) src))
    goto out2;
  xdr_destroy (&xdrs);
  xdrmem_create (&xdrs, addr, size, XDR_DECODE);
  if (!_xdr_nis_object (&xdrs, res))
    {
    out2:
      if (dest == NULL)
       free (res);
      res = NULL;
    }

  xdr_destroy (&xdrs);
 out:
  free (addr);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_clone_result ( const nis_result *  src,
nis_result *  dest 
)

Definition at line 27 of file nis_clone_res.c.

{
  char *addr;
  unsigned int size;
  XDR xdrs;

  if (src == NULL)
    return (NULL);

  size = xdr_sizeof ((xdrproc_t)_xdr_nis_result, (char *)src);
  if ((addr = calloc(1, size)) == NULL)
    return NULL;

  xdrmem_create (&xdrs, addr, size, XDR_ENCODE);
  if (!_xdr_nis_result (&xdrs, (nis_result *)src))
    {
      xdr_destroy (&xdrs);
      free (addr);
      return NULL;
    }
  xdr_destroy (&xdrs);

  nis_result *res;
  if (dest == NULL)
    {
      if ((res = calloc (1, sizeof (nis_result))) == NULL)
       {
         free (addr);
         return NULL;
       }
    }
  else
    res = dest;

  xdrmem_create (&xdrs, addr, size, XDR_DECODE);
  if (!_xdr_nis_result (&xdrs, res))
    {
      xdr_destroy (&xdrs);
      if (res != dest)
       free (res);
      free (addr);
      return NULL;
    }
  xdr_destroy (&xdrs);
  free (addr);

  return res;
}

Here is the call graph for this function:

nis_error nis_creategroup ( const_nis_name  group,
unsigned int  flags 
)

Definition at line 25 of file nis_creategroup.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 50];
      char leafbuf[grouplen + 2];
      char domainbuf[grouplen + 2];
      nis_error status;
      nis_result *res;
      char *cp, *cp2;
      nis_object *obj;

      cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
        {
         *cp++ = '.';
          stpcpy (cp, cp2);
        }
      else
       return NIS_BADNAME;

      obj = calloc (1, sizeof (nis_object));
      if (__builtin_expect (obj == NULL, 0))
       return NIS_NOMEMORY;

      obj->zo_oid.ctime = obj->zo_oid.mtime = time (NULL);
      obj->zo_name = strdup (leafbuf);
      obj->zo_owner = __nis_default_owner (NULL);
      obj->zo_group = __nis_default_group (NULL);
      obj->zo_domain = strdup (domainbuf);
      if (obj->zo_name == NULL || obj->zo_owner == NULL
         || obj->zo_group == NULL || obj->zo_domain == NULL)
       {
         free (obj->zo_group);
         free (obj->zo_owner);
         free (obj->zo_name);
         free (obj);
         return NIS_NOMEMORY;
       }
      obj->zo_access = __nis_default_access (NULL, 0);
      obj->zo_ttl = 60 * 60;
      obj->zo_data.zo_type = NIS_GROUP_OBJ;
      obj->zo_data.objdata_u.gr_data.gr_flags = flags;
      obj->zo_data.objdata_u.gr_data.gr_members.gr_members_len = 0;
      obj->zo_data.objdata_u.gr_data.gr_members.gr_members_val = NULL;

      res = nis_add (buf, obj);
      nis_free_object (obj);
      if (res == NULL)
       return NIS_NOMEMORY;
      status = NIS_RES_STATUS (res);
      nis_freeresult (res);

      return status;
    }
  return NIS_FAIL;
}

Here is the call graph for this function:

void nis_destroy_object ( nis_object *  obj)

Here is the caller graph for this function:

nis_error nis_destroygroup ( const_nis_name  group)

Definition at line 24 of file nis_destroygroup.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 50];
      char leafbuf[grouplen + 3];
      char domainbuf[grouplen + 3];
      nis_error status;
      nis_result *res;
      char *cp, *cp2;

      cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
       {
         *cp++ = '.';
         stpcpy (cp, cp2);
       }
      res = nis_remove (buf, NULL);
      status = NIS_RES_STATUS (res);
      nis_freeresult (res);
      return status;
    }
  else
    return NIS_FAIL;

}

Here is the call graph for this function:

name_pos nis_dir_cmp ( const_nis_name  n1,
const_nis_name  n2 
)

Here is the caller graph for this function:

Definition at line 23 of file nis_domain_of.c.

{
  static char result[NIS_MAXNAMELEN + 1];

  return nis_domain_of_r (name, result, NIS_MAXNAMELEN);
}

Here is the call graph for this function:

nis_name nis_domain_of_r ( const_nis_name  name,
char *  buffer,
size_t  buflen 
)

Definition at line 25 of file nis_domain_of_r.c.

{
  char *cptr;
  size_t cptr_len;

  if (buffer == NULL)
    {
    erange:
      __set_errno (ERANGE);
      return NULL;
    }

  buffer[0] = '\0';

  cptr = strchr (name, '.');

  if (cptr == NULL)
    return buffer;

  ++cptr;
  cptr_len = strlen (cptr);

  if (cptr_len == 0)
    {
      if (buflen < 2)
       goto erange;
      return strcpy (buffer, ".");
    }

  if (__builtin_expect (cptr_len >= buflen, 0))
    {
      __set_errno (ERANGE);
      return NULL;
    }

  return memcpy (buffer, cptr, cptr_len + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_first_entry ( const_nis_name  table_name)

Definition at line 716 of file nis_table.c.

{
  nis_result *res;
  ib_request *ibreq;
  nis_error status;

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  if (name == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  ibreq = __create_ib_request (name, 0);
  if (ibreq == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  status = __do_niscall (ibreq->ibr_name, NIS_IBFIRST,
                      (xdrproc_t) _xdr_ib_request,
                      (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                      (caddr_t) res, 0, NULL);

  if (__builtin_expect (status != NIS_SUCCESS, 0))
    NIS_RES_STATUS (res) = status;

  nis_free_request (ibreq);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nis_free_directory ( directory_obj *  dirobj)

Here is the caller graph for this function:

void nis_free_object ( nis_object *  obj)

Here is the caller graph for this function:

void nis_free_request ( ib_request *  req)

Here is the caller graph for this function:

void nis_freenames ( nis_name namelist)

Here is the caller graph for this function:

void nis_freeresult ( nis_result *  result)
void nis_freeservlist ( nis_server **  machines)

Definition at line 154 of file nis_getservlist.c.

{
  int i;

  if (serv == NULL)
    return;

  i = 0;
  while (serv[i] != NULL)
    {
      xdr_free ((xdrproc_t)_xdr_nis_server, (char *)serv[i]);
      free (serv[i]);
      ++i;
    }
  free (serv);
}

Here is the call graph for this function:

void nis_freetags ( nis_tag *  tags,
int  numtags 
)

Definition at line 79 of file nis_server.c.

{
  int i;

  for (i = 0; i < numtags; ++i)
    free (tags[i].tag_val);
  free (tags);
}

Definition at line 108 of file nis_subr.c.

{
  const char *local_domain = nis_local_directory ();
  size_t local_domain_len = strlen (local_domain);
  size_t name_len = strlen (name);
  char *path;
  int pos = 0;
  char *saveptr = NULL;
  int have_point;
  const char *cp;
  const char *cp2;

  int count = 2;
  nis_name *getnames = malloc ((count + 1) * sizeof (char *));
  if (__builtin_expect (getnames == NULL, 0))
      return NULL;

  /* Do we have a fully qualified NIS+ name ? If yes, give it back */
  if (name[name_len - 1] == '.')
    {
      if ((getnames[0] = strdup (name)) == NULL)
       {
       free_null:
         while (pos-- > 0)
           free (getnames[pos]);
         free (getnames);
         return NULL;
       }

      getnames[1] = NULL;

      return getnames;
    }

  /* If the passed NAME is shared a suffix (the latter of course with
     a final dot) with each other we pass back NAME with a final
     dot.  */
  if (local_domain_len > 2)
    {
      have_point = 0;
      cp = &local_domain[local_domain_len - 2];
      cp2 = &name[name_len - 1];

      while (*cp == *cp2)
       {
         if (*cp == '.')
           have_point = 1;
         --cp;
         --cp2;
         if (cp < local_domain)
           {
             have_point = cp2 < name || *cp2 == '.';
             break;
           }
         if (cp2 < name)
           {
             have_point = *cp == '.';
             break;
           }
       }

      if (have_point)
       {
         getnames[0] = malloc (name_len + 2);
         if (getnames[0] == NULL)
           goto free_null;

         strcpy (stpcpy (getnames[0], name), ".");
         ++pos;
       }
    }

  /* Get the search path, where we have to search "name" */
  path = getenv ("NIS_PATH");
  if (path == NULL)
    path = strdupa ("$");
  else
    path = strdupa (path);

  have_point = strchr (name, '.') != NULL;

  cp = __strtok_r (path, ":", &saveptr);
  while (cp)
    {
      if (strcmp (cp, "$") == 0)
       {
         const char *cptr = local_domain;
         char *tmp;

         while (*cptr != '\0' && count_dots (cptr) >= 2)
           {
             if (pos >= count)
              {
                count += 5;
                nis_name *newp = realloc (getnames,
                                       (count + 1) * sizeof (char *));
                if (__builtin_expect (newp == NULL, 0))
                  goto free_null;
                getnames = newp;
              }
             tmp = malloc (strlen (cptr) + local_domain_len + name_len + 2);
             if (__builtin_expect (tmp == NULL, 0))
              goto free_null;

             getnames[pos] = tmp;
             tmp = stpcpy (tmp, name);
             *tmp++ = '.';
             if (cptr[1] != '\0')
              stpcpy (tmp, cptr);
             else
              ++cptr;

             ++pos;

             while (*cptr != '.' && *cptr != '\0')
              ++cptr;
             if (cptr[0] != '\0' && cptr[1] != '\0')
              /* If we have only ".", don't remove the "." */
              ++cptr;
           }
       }
      else
       {
         char *tmp;
         size_t cplen = strlen (cp);

         if (cp[cplen - 1] == '$')
           {
             char *p;

             tmp = malloc (cplen + local_domain_len + name_len + 2);
             if (__builtin_expect (tmp == NULL, 0))
              goto free_null;

             p = __stpcpy (tmp, name);
             *p++ = '.';
             p = __mempcpy (p, cp, cplen);
             --p;
             if (p[-1] != '.')
              *p++ = '.';
             __stpcpy (p, local_domain);
           }
         else
           {
             char *p;

             tmp = malloc (cplen + name_len + 3);
             if (__builtin_expect (tmp == NULL, 0))
              goto free_null;

             p = __mempcpy (tmp, name, name_len);
             *p++ = '.';
             p = __mempcpy (p, cp, cplen);
             if (p[-1] != '.')
              *p++ = '.';
             *p = '\0';
           }

         if (pos >= count)
           {
             count += 5;
             nis_name *newp = realloc (getnames,
                                   (count + 1) * sizeof (char *));
             if (__builtin_expect (newp == NULL, 0))
              goto free_null;
             getnames = newp;
           }
         getnames[pos] = tmp;
         ++pos;
       }
      cp = __strtok_r (NULL, ":", &saveptr);
    }

  if (pos == 0
      && __asprintf (&getnames[pos++], "%s%s%s%s",
                   name, name[name_len - 1] == '.' ? "" : ".",
                   local_domain,
                   local_domain[local_domain_len - 1] == '.' ? "" : ".") < 0)
    goto free_null;

  getnames[pos] = NULL;

  return getnames;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_server** nis_getservlist ( const_nis_name  dirname)

Definition at line 27 of file nis_getservlist.c.

{
  nis_result *res;
  nis_server **serv;

  res = nis_lookup (dir, FOLLOW_LINKS);

  if (res != NULL && NIS_RES_STATUS (res) == NIS_SUCCESS)
    {
      unsigned long i;
      nis_server *server;

      serv =
       malloc (sizeof (nis_server *) *
              (NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
      if (__builtin_expect (serv == NULL, 0))
       {
         nis_freeresult (res);
         return NULL;
       }

      for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len;
          ++i)
       {
         server =
           &NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i];
         serv[i] = calloc (1, sizeof (nis_server));
         if (__builtin_expect (serv[i] == NULL, 0))
           {
           free_all:
             while (i-- > 0)
              {
                free (serv[i]->pkey.n_bytes);
                if (serv[i]->ep.ep_val != NULL)
                  {
                    unsigned long int j;
                    for (j = 0; j < serv[i]->ep.ep_len; ++j)
                     {
                       free (serv[i]->ep.ep_val[j].proto);
                       free (serv[i]->ep.ep_val[j].family);
                       free (serv[i]->ep.ep_val[j].uaddr);
                     }
                    free (serv[i]->ep.ep_val);
                  }
                free (serv[i]->name);
                free (serv[i]);
              }

             free (serv);

             nis_freeresult (res);

             return NULL;
           }

         if (server->name != NULL)
           {
             serv[i]->name = strdup (server->name);
             if (__builtin_expect (serv[i]->name == NULL, 0))
              {
                ++i;
                goto free_all;
              }
           }

          serv[i]->ep.ep_len = server->ep.ep_len;
          if (serv[i]->ep.ep_len > 0)
            {
              unsigned long int j;

              serv[i]->ep.ep_val =
              malloc (server->ep.ep_len * sizeof (endpoint));
             if (__builtin_expect (serv[i]->ep.ep_val == NULL, 0))
              {
                ++i;
                goto free_all;
              }

              for (j = 0; j < serv[i]->ep.ep_len; ++j)
                {
                  if (server->ep.ep_val[j].uaddr)
                    serv[i]->ep.ep_val[j].uaddr =
                    strdup (server->ep.ep_val[j].uaddr);
                  else
                    serv[i]->ep.ep_val[j].uaddr = NULL;
                  if (server->ep.ep_val[j].family)
                  serv[i]->ep.ep_val[j].family =
                    strdup (server->ep.ep_val[j].family);
                  else
                    serv[i]->ep.ep_val[j].family = NULL;
                  if (server->ep.ep_val[j].proto)
                  serv[i]->ep.ep_val[j].proto =
                    strdup (server->ep.ep_val[j].proto);
                  else
                  serv[i]->ep.ep_val[j].proto = NULL;
                }
            }

          serv[i]->key_type = server->key_type;
          serv[i]->pkey.n_len = server->pkey.n_len;
          if (server->pkey.n_len > 0)
            {
              serv[i]->pkey.n_bytes = malloc (server->pkey.n_len);
              if (__builtin_expect (serv[i]->pkey.n_bytes == NULL, 0))
              {
                ++i;
                goto free_all;
              }
              memcpy (serv[i]->pkey.n_bytes, server->pkey.n_bytes,
                      server->pkey.n_len);
            }
        }
      serv[i] = NULL;
    }
  else
    {
      serv = malloc (sizeof (nis_server *));
      if (__builtin_expect (serv != NULL, 0))
       serv[0] = NULL;
    }

  nis_freeresult (res);

  return serv;
}

Here is the call graph for this function:

bool_t nis_ismember ( const_nis_name  principal,
const_nis_name  group 
)

Definition at line 143 of file nis_ismember.c.

{
  if (group != NULL && group[0] != '\0' && principal != NULL)
    return internal_ismember (principal, group) == 1 ? TRUE : FALSE;
  else
    return FALSE;
}

Here is the call graph for this function:

Definition at line 25 of file nis_subr.c.

{
  static char result[NIS_MAXNAMELEN + 1];

  return nis_leaf_of_r (name, result, NIS_MAXNAMELEN);
}

Here is the call graph for this function:

nis_name nis_leaf_of_r ( const_nis_name  name,
char *  buffer,
size_t  buflen 
)

Definition at line 33 of file nis_subr.c.

{
  size_t i = 0;

  buffer[0] = '\0';

  while (name[i] != '.' && name[i] != '\0')
    i++;

  if (__builtin_expect (i >= buflen, 0))
    {
      __set_errno (ERANGE);
      return NULL;
    }

  *((char *) __mempcpy (buffer, name, i)) = '\0';

  return buffer;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nis_lerror ( const nis_error  status,
const char *  label 
)

Definition at line 72 of file nis_error.c.

{
  syslog (LOG_ERR, "%s: %s", label, nis_sperrno (status));
}

Here is the call graph for this function:

nis_result* nis_list ( const_nis_name  name,
unsigned int  flags,
int(*)(const_nis_name table_name, const nis_object *obj, const void *userdata)  callback,
const void *  userdata 
)

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 27 of file nis_local_names.c.

{
  static char __nisgroup[NIS_MAXNAMELEN + 1];

  char *cptr;
  if (__nisgroup[0] == '\0'
      && (cptr = getenv ("NIS_GROUP")) != NULL
      && strlen (cptr) < NIS_MAXNAMELEN)
    {
      char *cp = stpcpy (__nisgroup, cptr);

      if (cp[-1] != '.')
       {
         cptr = nis_local_directory ();
         if ((cp - __nisgroup) + strlen (cptr) + 1 < NIS_MAXNAMELEN)
           {
             *cp++ = '.';
             strcpy (cp, cptr);
           }
         else
           __nisgroup[0] = '\0';
       }
    }

  return __nisgroup;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

nis_result* nis_lookup ( const_nis_name  name,
unsigned int  flags 
)

Definition at line 29 of file nis_lookup.c.

{
  nis_result *res = calloc (1, sizeof (nis_result));
  struct ns_request req;
  nis_name *names;
  nis_error status;
  int link_first_try = 0;
  int count_links = 0;       /* We will follow only 16 links in the deep */
  int done = 0;
  int name_nr = 0;
  nis_name namebuf[2] = {NULL, NULL};

  if (res == NULL)
    return NULL;

  if ((flags & EXPAND_NAME) && (name[strlen (name) - 1] != '.'))
    {
      names = nis_getnames (name);
      if (names == NULL)
       {
         NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
         return res;
       }
    }
  else
    {
      names = namebuf;
      names[0] = (nis_name)name;
    }

  req.ns_name = names[0];
  while (!done)
    {
      dir_binding bptr;
      directory_obj *dir = NULL;
      req.ns_object.ns_object_len = 0;
      req.ns_object.ns_object_val = NULL;

      status = __prepare_niscall (req.ns_name, &dir, &bptr, flags);
      if (__builtin_expect (status != NIS_SUCCESS, 0))
       {
         NIS_RES_STATUS (res) = status;
         goto out;
       }

      do
       {
         static const struct timeval RPCTIMEOUT = {10, 0};
         enum clnt_stat result;

       again:
         result = clnt_call (bptr.clnt, NIS_LOOKUP,
                           (xdrproc_t) _xdr_ns_request,
                           (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
                           (caddr_t) res, RPCTIMEOUT);

         if (result != RPC_SUCCESS)
           status = NIS_RPCERROR;
         else
           {
             status = NIS_SUCCESS;

             if (NIS_RES_STATUS (res) == NIS_SUCCESS)
              {
                  if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ
                     && (flags & FOLLOW_LINKS)) /* We are following links */
                    {
                     /* if we hit the link limit, bail */
                     if (count_links > NIS_MAXLINKS)
                       {
                         NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
                         break;
                       }
                     ++count_links;
                     req.ns_name =
                       strdupa (NIS_RES_OBJECT (res)->LI_data.li_name);

                     /* The following is a non-obvious optimization.  A
                        nis_freeresult call would call xdr_free as the
                        following code.  But it also would unnecessarily
                        free the result structure.  We avoid this here
                        along with the necessary tests.  */
                     xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res);
                     memset (res, '\0', sizeof (*res));

                     link_first_try = 1; /* Try at first the old binding */
                     goto again;
                    }
              }
             else
              if (NIS_RES_STATUS (res) == NIS_SYSTEMERROR
                  || NIS_RES_STATUS (res) == NIS_NOSUCHNAME
                  || NIS_RES_STATUS (res) == NIS_NOT_ME)
                {
                  if (link_first_try)
                    {
                     __nisbind_destroy (&bptr);
                     nis_free_directory (dir);
                     /* Otherwise __nisfind_server will not do anything.  */
                     dir = NULL;

                     if (__nisfind_server (req.ns_name, 1, &dir, &bptr,
                                         flags & ~MASTER_ONLY)
                         != NIS_SUCCESS)
                       goto out;
                    }
                  else
                    if (__nisbind_next (&bptr) != NIS_SUCCESS)
                     {
                       /* No more servers to search.  Try parent.  */
                       const char *ndomain = __nis_domain_of (req.ns_name);
                       req.ns_name = strdupa (ndomain);
                       if (strcmp (req.ns_name, ".") == 0)
                         {
                           NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
                           goto out;
                         }

                       __nisbind_destroy (&bptr);
                       nis_free_directory (dir);
                       dir = NULL;
                       status = __prepare_niscall (req.ns_name, &dir,
                                                &bptr, flags);
                       if (__builtin_expect (status != NIS_SUCCESS, 0))
                         {
                           NIS_RES_STATUS (res) = status;
                           goto out;
                         }
                       goto again;
                     }

                  while (__nisbind_connect (&bptr) != NIS_SUCCESS)
                    {
                     if (__nisbind_next (&bptr) != NIS_SUCCESS)
                       {
                         nis_free_directory (dir);
                         goto out;
                       }
                    }
                  goto again;
                }
             break;
           }
         link_first_try = 0; /* Set it back */
       }
      while ((flags & HARD_LOOKUP) && status == NIS_RPCERROR);

      __nisbind_destroy (&bptr);
      nis_free_directory (dir);

      if (status != NIS_SUCCESS)
       {
         NIS_RES_STATUS (res) = status;
         goto out;
       }

      switch (NIS_RES_STATUS (res))
       {
       case NIS_PARTIAL:
       case NIS_SUCCESS:
       case NIS_S_SUCCESS:
       case NIS_LINKNAMEERROR: /* We follow to max links */
       case NIS_UNAVAIL: /* NIS+ is not installed, or all servers are down */
         ++done;
         break;
       default:
         /* Try the next domainname if we don't follow a link */
         if (count_links)
           {
             free (req.ns_name);
             NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
             ++done;
             break;
           }
         ++name_nr;
         if (names[name_nr] == NULL)
           {
             ++done;
             break;
           }
         req.ns_name = names[name_nr];
         break;
       }
    }

 out:
  if (names != namebuf)
    nis_freenames (names);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_error nis_mkdir ( const_nis_name  dirname,
const nis_server *  machine 
)

Definition at line 26 of file nis_mkdir.c.

{
  nis_error res, res2;

  if (server == NULL)
    res2 = __do_niscall (dir, NIS_MKDIR, (xdrproc_t) _xdr_nis_name,
                      (caddr_t) &dir, (xdrproc_t) _xdr_nis_error,
                      (caddr_t) &res, 0, NULL);
  else
    res2 = __do_niscall2 (server, 1, NIS_MKDIR,
                       (xdrproc_t) _xdr_nis_name,
                       (caddr_t) &dir, (xdrproc_t) _xdr_nis_error,
                       (caddr_t) &res, 0, NULL);
  if (res2 != NIS_SUCCESS)
    return res2;

  return res;
}

Here is the call graph for this function:

nis_result* nis_modify ( const_nis_name  name,
const nis_object *  obj 
)

Definition at line 27 of file nis_modify.c.

{
  nis_object obj;
  nis_result *res;
  nis_error status;
  struct ns_request req;
  size_t namelen = strlen (name);
  char buf1[namelen + 20];
  char buf4[namelen + 20];

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  req.ns_name = (char *) name;

  memcpy (&obj, obj2, sizeof (nis_object));

  if (obj.zo_name == NULL || obj.zo_name[0] == '\0')
    obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));

  if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0')
    obj.zo_owner = nis_local_principal ();

  if (obj.zo_group == NULL || obj.zo_group[0] == '\0')
    obj.zo_group = nis_local_group ();

  obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));

  req.ns_object.ns_object_val = nis_clone_object (&obj, NULL);
  if (req.ns_object.ns_object_val == NULL)
    {
      NIS_RES_STATUS (res) = NIS_NOMEMORY;
      return res;
    }
  req.ns_object.ns_object_len = 1;

  status = __do_niscall (name, NIS_MODIFY, (xdrproc_t) _xdr_ns_request,
                      (caddr_t) & req, (xdrproc_t) _xdr_nis_result,
                      (caddr_t) res, MASTER_ONLY,
                      NULL);
  if (status != RPC_SUCCESS)
    NIS_RES_STATUS (res) = status;

  nis_destroy_object (req.ns_object.ns_object_val);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_modify_entry ( const_nis_name  name,
const nis_object *  obj,
unsigned int  flags 
)

Definition at line 611 of file nis_table.c.

{
  nis_object obj;
  nis_result *res;
  nis_error status;
  ib_request *ibreq;
  size_t namelen = strlen (name);
  char buf1[namelen + 20];
  char buf4[namelen + 20];

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  ibreq = __create_ib_request (name, flags);
  if (ibreq == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  memcpy (&obj, obj2, sizeof (nis_object));

  if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
    obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));

  if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
    obj.zo_owner = nis_local_principal ();

  if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
    obj.zo_group = nis_local_group ();

  obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));

  ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL);
  if (ibreq->ibr_obj.ibr_obj_val == NULL)
    {
      nis_free_request (ibreq);
      NIS_RES_STATUS (res) = NIS_NOMEMORY;
      return res;
    }
  ibreq->ibr_obj.ibr_obj_len = 1;

  status = __do_niscall (ibreq->ibr_name, NIS_IBMODIFY,
                      (xdrproc_t) _xdr_ib_request,
                      (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                      (caddr_t) res, 0, NULL);
  if (__builtin_expect (status != NIS_SUCCESS, 0))
    NIS_RES_STATUS (res) = status;

  nis_free_request (ibreq);

  return res;
}

Here is the call graph for this function:

nis_name nis_name_of_r ( const_nis_name  name,
char *  buffer,
size_t  buflen 
)

Definition at line 63 of file nis_subr.c.

{
  char *local_domain;
  int diff;

  local_domain = nis_local_directory ();

  diff = strlen (name) - strlen (local_domain);
  if (diff <= 0)
    return NULL;

  if (strcmp (&name[diff], local_domain) != 0)
    return NULL;

  if ((size_t) diff >= buflen)
    {
      __set_errno (ERANGE);
      return NULL;
    }

  *((char *) __mempcpy (buffer, name, diff - 1)) = '\0';

  if (diff - 1 == 0)
    return NULL;

  return buffer;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_next_entry ( const_nis_name  table_name,
const netobj cookie 
)

Definition at line 753 of file nis_table.c.

{
  nis_result *res;
  ib_request *ibreq;
  nis_error status;

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  if (name == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  ibreq = __create_ib_request (name, 0);
  if (ibreq == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  if (cookie != NULL)
    {
      ibreq->ibr_cookie.n_bytes = cookie->n_bytes;
      ibreq->ibr_cookie.n_len = cookie->n_len;
    }

  status = __do_niscall (ibreq->ibr_name, NIS_IBNEXT,
                      (xdrproc_t) _xdr_ib_request,
                      (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                      (caddr_t) res, 0, NULL);

  if (__builtin_expect (status != NIS_SUCCESS, 0))
    NIS_RES_STATUS (res) = status;

  if (cookie != NULL)
    {
      /* Don't give cookie free, it is not from us */
      ibreq->ibr_cookie.n_bytes = NULL;
      ibreq->ibr_cookie.n_len = 0;
    }

  nis_free_request (ibreq);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nis_perror ( const nis_error  status,
const char *  label 
)
void nis_ping ( const_nis_name  dirname,
uint32_t  utime,
const nis_object *  dirobj 
)

Definition at line 26 of file nis_ping.c.

{
  nis_result *res = NULL;
  nis_object *obj;
  ping_args args;
  unsigned int i;

  if (dirname == NULL && dirobj == NULL)
    abort ();

  if (dirobj == NULL)
    {
      res = nis_lookup (dirname, MASTER_ONLY);
      if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
       {
         nis_freeresult (res);
         return;
       }
      obj = res->objects.objects_val;
    }
  else
    obj = (nis_object *) dirobj;

  /* Check if obj is really a diryectory object */
  if (__type_of (obj) != NIS_DIRECTORY_OBJ)
    {
      nis_freeresult (res);
      return;
    }

  if (dirname == NULL)
    args.dir = obj->DI_data.do_name;
  else
    args.dir = (char *) dirname;
  args.stamp = utime;

  /* Send the ping only to replicas */
  for (i = 1; i < obj->DI_data.do_servers.do_servers_len; ++i)
    __do_niscall2 (&obj->DI_data.do_servers.do_servers_val[i], 1,
                 NIS_PING, (xdrproc_t) _xdr_ping_args,
                 (caddr_t) &args, (xdrproc_t) xdr_void,
                 (caddr_t) NULL, 0, NULL);
  nis_freeresult (res);
}

Here is the call graph for this function:

void nis_print_directory ( const directory_obj *  dirobj)

Here is the caller graph for this function:

void nis_print_entry ( const entry_obj *  enobj)

Here is the caller graph for this function:

void nis_print_group ( const group_obj *  grpobj)

Here is the caller graph for this function:

Definition at line 26 of file nis_print_group_entry.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 50];
      char leafbuf[grouplen + 3];
      char domainbuf[grouplen + 3];
      nis_result *res;
      char *cp, *cp2;
      u_int i;

      cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
       {
         *cp++ = '.';
         stpcpy (cp, cp2);
       }
      res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME);

      if (res == NULL)
       return;

      if (NIS_RES_STATUS (res) != NIS_SUCCESS
         || NIS_RES_NUMOBJ (res) != 1
         || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)
       {
         nis_freeresult (res);
         return;
       }

      char *mem_exp[NIS_RES_NUMOBJ (res)];
      char *mem_imp[NIS_RES_NUMOBJ (res)];
      char *mem_rec[NIS_RES_NUMOBJ (res)];
      char *nomem_exp[NIS_RES_NUMOBJ (res)];
      char *nomem_imp[NIS_RES_NUMOBJ (res)];
      char *nomem_rec[NIS_RES_NUMOBJ (res)];
      unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0;
      unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0;

      for (i = 0;
          i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i)
       {
         char *grmem =
           NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i];
         int neg = grmem[0] == '-';

         switch (grmem[neg])
           {
           case '*':
             if (neg)
              {
                nomem_imp[nomem_imp_cnt] = grmem;
                ++nomem_imp_cnt;
              }
             else
              {
                mem_imp[mem_imp_cnt] = grmem;
                ++mem_imp_cnt;
              }
             break;
           case '@':
             if (neg)
              {
                nomem_rec[nomem_rec_cnt] = grmem;
                ++nomem_rec_cnt;
              }
             else
              {
                mem_rec[mem_rec_cnt] = grmem;
                ++mem_rec_cnt;
              }
             break;
           default:
             if (neg)
              {
                nomem_exp[nomem_exp_cnt] = grmem;
                ++nomem_exp_cnt;
              }
             else
              {
                mem_exp[mem_exp_cnt] = grmem;
                ++mem_exp_cnt;
              }
             break;
           }
       }
      {
       char buf[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10];
       printf (_("Group entry for \"%s.%s\" group:\n"),
              NIS_RES_OBJECT (res)->zo_name,
              nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain,
                             buf, strlen (NIS_RES_OBJECT (res)->zo_domain)
                             + 10));
      }
      if (mem_exp_cnt)
       {
         fputs (_("    Explicit members:\n"), stdout);
         for (i = 0; i < mem_exp_cnt; ++i)
           printf ("\t%s\n", mem_exp[i]);
       }
      else
       fputs (_("    No explicit members\n"), stdout);
      if (mem_imp_cnt)
       {
         fputs (_("    Implicit members:\n"), stdout);
         for (i = 0; i < mem_imp_cnt; ++i)
           printf ("\t%s\n", &mem_imp[i][2]);
       }
      else
       fputs (_("    No implicit members\n"), stdout);
      if (mem_rec_cnt)
       {
         fputs (_("    Recursive members:\n"), stdout);
         for (i = 0; i < mem_rec_cnt; ++i)
           printf ("\t%s\n", &mem_rec[i][1]);
       }
      else
        fputs (_("    No recursive members\n"), stdout);
      if (nomem_exp_cnt)
       {
         fputs (_("    Explicit nonmembers:\n"), stdout);
         for (i = 0; i < nomem_exp_cnt; ++i)
           printf ("\t%s\n", &nomem_exp[i][1]);
       }
      else
       fputs (_("    No explicit nonmembers\n"), stdout);
      if (nomem_imp_cnt)
       {
         fputs (_("    Implicit nonmembers:\n"), stdout);
         for (i = 0; i < nomem_imp_cnt; ++i)
           printf ("\t%s\n", &mem_imp[i][3]);
       }
      else
       fputs (_("    No implicit nonmembers\n"), stdout);
      if (nomem_rec_cnt)
       {
         fputs (_("    Recursive nonmembers:\n"), stdout);
         for (i = 0; i < nomem_rec_cnt; ++i)
           printf ("\t%s=n", &nomem_rec[i][2]);
       }
      else
        fputs (_("    No recursive nonmembers\n"), stdout);

      nis_freeresult (res);
    }
}

Here is the call graph for this function:

void nis_print_link ( const link_obj *  lnkobj)

Here is the caller graph for this function:

void nis_print_object ( const nis_object *  obj)

Here is the caller graph for this function:

void nis_print_result ( const nis_result *  result)
void nis_print_rights ( unsigned int  rights)

Definition at line 139 of file nis_print.c.

{
  char result[17];
  unsigned int acc;
  int i;

  acc = access;                    /* Parameter is const ! */
  result[i = 16] = '\0';
  while (i > 0)
    {
      i -= 4;
      result[i + 0] = (acc & NIS_READ_ACC) ? 'r' : '-';
      result[i + 1] = (acc & NIS_MODIFY_ACC) ? 'm' : '-';
      result[i + 2] = (acc & NIS_CREATE_ACC) ? 'c' : '-';
      result[i + 3] = (acc & NIS_DESTROY_ACC) ? 'd' : '-';

      acc >>= 8;
    }
  fputs (result, stdout);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nis_print_table ( const table_obj *  tblobj)

Here is the caller graph for this function:

nis_object* nis_read_obj ( const char *  obj)

Definition at line 93 of file nis_file.c.

{
  return read_nis_obj (name, (iofct_t) _xdr_nis_object,
                     (freefct_t) nis_free_object, sizeof (nis_object));
}

Here is the call graph for this function:

nis_result* nis_remove ( const_nis_name  name,
const nis_object *  obj 
)

Definition at line 26 of file nis_remove.c.

{
  nis_result *res;
  nis_error status;
  struct ns_request req;

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  req.ns_name = (char *)name;

  if (obj != NULL)
    {
      req.ns_object.ns_object_len = 1;
      req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
    }
  else
    {
      req.ns_object.ns_object_len = 0;
      req.ns_object.ns_object_val = NULL;
    }

  if ((status = __do_niscall (name, NIS_REMOVE, (xdrproc_t) _xdr_ns_request,
                           (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
                           (caddr_t) res, MASTER_ONLY,
                           NULL)) != RPC_SUCCESS)
    NIS_RES_STATUS (res) = status;

  nis_destroy_object (req.ns_object.ns_object_val);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_result* nis_remove_entry ( const_nis_name  table_name,
const nis_object *  obj,
unsigned int  flags 
)

Definition at line 668 of file nis_table.c.

{
  nis_result *res;
  ib_request *ibreq;
  nis_error status;

  res = calloc (1, sizeof (nis_result));
  if (res == NULL)
    return NULL;

  if (name == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  ibreq = __create_ib_request (name, flags);
  if (ibreq == NULL)
    {
      NIS_RES_STATUS (res) = NIS_BADNAME;
      return res;
    }

  if (obj != NULL)
    {
      ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
      if (ibreq->ibr_obj.ibr_obj_val == NULL)
       {
         nis_free_request (ibreq);
         NIS_RES_STATUS (res) = NIS_NOMEMORY;
         return res;
       }
      ibreq->ibr_obj.ibr_obj_len = 1;
    }

  if ((status = __do_niscall (ibreq->ibr_name, NIS_IBREMOVE,
                           (xdrproc_t) _xdr_ib_request,
                           (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                           (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
    NIS_RES_STATUS (res) = status;

  nis_free_request (ibreq);

  return res;
}

Here is the call graph for this function:

nis_error nis_removemember ( const_nis_name  member,
const_nis_name  group 
)

Definition at line 25 of file nis_removemember.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 14 + NIS_MAXNAMELEN];
      char domainbuf[grouplen + 2];
      nis_result *res, *res2;
      nis_error status;
      char *cp, *cp2;

      cp = rawmemchr (nis_leaf_of_r (group, buf, sizeof (buf) - 1), '\0');
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
        {
          cp = stpcpy (cp, ".");
          stpcpy (cp, cp2);
        }
      res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME);
      if (res == NULL)
       return NIS_NOMEMORY;
      if (NIS_RES_STATUS (res) != NIS_SUCCESS)
        {
         status = NIS_RES_STATUS (res);
         nis_freeresult (res);
          return status;
        }

      if (NIS_RES_NUMOBJ (res) != 1
         || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)
       {
         nis_freeresult (res);
         return NIS_INVALIDOBJ;
       }

      nis_name *gr_members_val
       = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_val;
      u_int gr_members_len
       = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len;

      u_int j = 0;
      for (u_int i = 0; i < gr_members_len; ++i)
       if (strcmp (gr_members_val[i], member) != 0)
         gr_members_val[j++] = gr_members_val[i];
       else
         free (gr_members_val[i]);

      /* There is no need to reallocate the gr_members_val array.  We
        just adjust the size to match the number of strings still in
        it.  Yes, xdr_array will use mem_free with a size parameter
        but this is mapped to a simple free call which determines the
        size of the block by itself.  */
      NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len = j;

      cp = stpcpy (buf, NIS_RES_OBJECT (res)->zo_name);
      *cp++ = '.';
      strncpy (cp, NIS_RES_OBJECT (res)->zo_domain, NIS_MAXNAMELEN);
      res2 = nis_modify (buf, NIS_RES_OBJECT (res));
      status = NIS_RES_STATUS (res2);
      nis_freeresult (res);
      nis_freeresult (res2);

      return status;
    }
  else
    return NIS_FAIL;
}

Here is the call graph for this function:

nis_error nis_rmdir ( const_nis_name  dirname,
const nis_server *  machine 
)

Definition at line 26 of file nis_rmdir.c.

{
  nis_error res, res2;

  if (server == NULL)
    return NIS_SYSTEMERROR;

  res2 = __do_niscall2 (server, 1, NIS_RMDIR,
                     (xdrproc_t) _xdr_nis_name,
                     (caddr_t) &dir, (xdrproc_t) _xdr_nis_error,
                     (caddr_t) &res, 0, NULL);
  if (res2 != NIS_SUCCESS)
    return res2;

  return res;
}

Here is the call graph for this function:

nis_error nis_servstate ( const nis_server *  machine,
const nis_tag *  tags,
int  numtags,
nis_tag **  result 
)

Definition at line 27 of file nis_server.c.

{
  nis_taglist taglist;
  nis_taglist tagres;

  *result = 0;
  tagres.tags.tags_len = 0;
  tagres.tags.tags_val = NULL;
  taglist.tags.tags_len = numtags;
  taglist.tags.tags_val = (nis_tag *) tags;

  if (serv == NULL)
    return NIS_BADOBJECT;

  if (__do_niscall2 (serv, 1, NIS_SERVSTATE, (xdrproc_t) _xdr_nis_taglist,
                   (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist,
                   (caddr_t) &tagres, 0, NULL) != RPC_SUCCESS)
    return NIS_RPCERROR;

  *result = tagres.tags.tags_val;

  return NIS_SUCCESS;
}

Here is the call graph for this function:

const char* nis_sperrno ( const nis_error  status)

Definition at line 56 of file nis_error.c.

{
  if (status >= sizeof (msgidx) / sizeof (msgidx[0]))
    return "???";
  else
    return gettext (msgstr.str + msgidx[status]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* nis_sperror ( const nis_error  status,
const char *  label 
)
char* nis_sperror_r ( const nis_error  status,
const char *  label,
char *  buffer,
size_t  buflen 
)

Definition at line 78 of file nis_error.c.

{
  if (snprintf (buffer, buflen, "%s: %s", label, nis_sperrno (status))
      >= buflen)
    {
      __set_errno (ERANGE);
      return NULL;
    }

  return buffer;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nis_error nis_stats ( const nis_server *  machine,
const nis_tag *  tags,
int  numtags,
nis_tag **  result 
)

Definition at line 53 of file nis_server.c.

{
  nis_taglist taglist;
  nis_taglist tagres;

  *result = NULL;
  tagres.tags.tags_len = 0;
  tagres.tags.tags_val = NULL;
  taglist.tags.tags_len = numtags;
  taglist.tags.tags_val = (nis_tag *) tags;

  if (serv == NULL)
    return NIS_BADOBJECT;

  if (__do_niscall2 (serv, 1, NIS_STATUS, (xdrproc_t) _xdr_nis_taglist,
                   (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist,
                   (caddr_t) &tagres, 0, NULL) != RPC_SUCCESS)
    return NIS_RPCERROR;

  *result = tagres.tags.tags_val;

  return NIS_SUCCESS;
}

Here is the call graph for this function:

nis_error nis_verifygroup ( const_nis_name  group)

Definition at line 24 of file nis_verifygroup.c.

{
  if (group != NULL && group[0] != '\0')
    {
      size_t grouplen = strlen (group);
      char buf[grouplen + 50];
      char leafbuf[grouplen + 2];
      char domainbuf[grouplen + 2];
      nis_result *res;
      nis_error status;
      char *cp, *cp2;

      cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
      cp = stpcpy (cp, ".groups_dir");
      cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
      if (cp2 != NULL && cp2[0] != '\0')
       {
         *cp++ = '.';
         stpcpy (cp, cp2);
       }
      res = nis_lookup (buf, 0);
      status = NIS_RES_STATUS (res);
      nis_freeresult (res);
      return status;
    }
  else
    return NIS_FAIL;
}

Here is the call graph for this function:

bool_t nis_write_obj ( const char *  file,
const nis_object *  obj 
)

Definition at line 100 of file nis_file.c.

Here is the call graph for this function:

directory_obj* readColdStartFile ( void  )

Definition at line 79 of file nis_file.c.

Here is the call graph for this function:

Here is the caller graph for this function:

bool_t writeColdStartFile ( const directory_obj *  dirobj)

Variable Documentation

Definition at line 27 of file nislib.h.