shim_ancil.c revision a87701e9837f8a9ee9e4c4d3186295c0e29f743f
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Gary Mills
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#include <stdlib.h>
#include <dirent.h>
#include <strings.h>
#include "ypsym.h"
#include "ypdefs.h"
#include "shim.h"
#include "../ldap_util.h"
/*
* This constructs a file name from a passed domain name, a passed map name,
* and a globally known YP data base path prefix.
*
* Has to be in shim because it needs the N2L prefix
*
* RETURNS : TRUE = A name was successfully created
* FALSE = A name could not be created
*/
char *domain;
char *map;
char *path;
{
int length;
/* Do not allow any path as a domain name. */
return (FALSE);
if (yptol_mode)
return (FALSE);
}
/* If in N2L mode add N2L prefix */
if (yptol_mode)
return (TRUE);
}
/*
*
* RETURNS: TRUE if yes
* FALSE if not
*/
int i = 0;
return (FALSE);
}
return (TRUE);
}
}
return (FALSE);
}
/*
*
* list_len: if -1, we do not know list length
*
* RETURNS: TRUE if map was added
* FALSE if not
*/
int i = 0;
char **list_tmp;
return (FALSE);
}
*list_len = 0;
} else {
/* find 1st free element */
/*
* increment in loop so that
* list_tmp[i] == NULL
* when exiting
*/
i++;
}
}
/* if we don't know list length, assume we reach its end */
if (*list_len == -1) {
*list_len = i;
}
/* do we need to reallocate ? */
if (i+1 >= *list_len) {
(*list_len + ARRAY_CHUNK) *
sizeof (char *));
return (FALSE);
}
*list_len += ARRAY_CHUNK;
}
/* add in list */
/* strdup() failed */
return (FALSE);
}
return (TRUE);
}
/*
* This checks to see whether a domain name is present at the local node as a
* subdirectory of ypdbpath
*
* Now ypcheck_domain(domain) calls this function.
*/
bool
ypcheck_domain_yptol(char *domain)
{
return (present);
}
return (present);
}
/*
* This performs an existence check on the dbm data base files <name>.pag and
* <name>.dir. pname is a ptr to the filename. This should be an absolute
* path.
* Returns TRUE if the map exists and is accessible; else FALSE.
*
* Note: The file name should be a "base" form, without a file "extension" of
* .dir or .pag appended. See ypmkfilename for a function which will generate
* the name correctly. Errors in the stat call will be reported at this level,
* however, the non-existence of a file is not considered an error, and so will
* not be reported.
*
* Now ypcheck_map_existence() calls this function.
*/
bool
ypcheck_map_existence_yptol(char *pname)
{
int len;
sizeof (dbfile)) {
return (FALSE);
}
errno = 0;
/* Check for existance of .dir file */
"ypserv: Stat error on map file %s.\n",
dbfile);
}
return (FALSE);
}
/* Check for existance of .pag file */
"ypserv: Stat error on map file %s.\n",
dbfile);
}
return (FALSE);
}
if (yptol_mode) {
/* Check for existance of TTL .dir file */
"ypserv: Stat error on map file %s.\n",
dbfile);
}
return (FALSE);
}
/* Check for existance of TTL .pag file */
"ypserv: Stat error on map file %s.\n",
dbfile);
}
return (FALSE);
}
}
return (TRUE);
}
/*
* This adds maps in a domain to a given list,
* Inspired from yplist_maps() in cmd/ypcmd/ypserv_ancil.c
*
* domain is the relevant domain name
* map_list is the list of maps in an array of map names,
* which may or may not be empty
*
* RETURNS : TRUE = everything went fine
* FALSE = an error occured
*/
{
int domdir_len = sizeof (domdir);
int name_len;
int dbm_pag_len = sizeof (dbm_pag);
char *ext;
char *mapname;
int map_list_len = -1;
return (FALSE);
}
/* no domain, not a problem */
return (TRUE);
}
/* not a valid domain, not a problem */
if (!ypcheck_domain_yptol(domain)) {
return (TRUE);
}
> domdir_len) {
return (FALSE);
}
return (FALSE);
}
/*
* If it's possible that the file name is one of the two files
* implementing a map, remove the extension (dbm_pag or dbm_dir)
*/
continue; /* Too Short */
}
continue; /* No dbm file extension */
}
*ext = '\0';
/*
* In yptol mode look at LDAP_ prefixed maps. In non yptol mode
* ignore them.
*/
if (yptol_mode) {
strlen(NTOL_PREFIX))) {
continue;
}
/*
* Already have an LDAP_ prefix. Don't want to add it
* twice.
*/
} else {
strlen(NTOL_PREFIX))) {
continue;
}
}
return (FALSE);
}
/*
* At this point, path holds the map file base name (no dbm
* file extension), and mapname holds the map name.
*/
if (ypcheck_map_existence_yptol(path) &&
FALSE) {
return (FALSE);
}
}
}
return (TRUE);
}