/*
* 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
*/
/*
*/
/*
* DESCRIPTION: Contains functions relating to movement of entire maps.
*/
#include <unistd.h>
#include <syslog.h>
#include <ndbm.h>
#include <string.h>
#include "ypsym.h"
#include "ypdefs.h"
#include "shim.h"
#include "yptol.h"
#include "../ldap_util.h"
/*
* Switch on parts of ypdefs.h
*/
/*
* Decs
*/
void add_separator(char *);
/*
* FUNCTION : dump_maps_to_dit()
*
* DESCRIPTION: Dump all the OLD STYLE NIS maps into the DIT.
*
* Since the DIT is not yet set up details about which maps and
* domains exist are gathered from the N2L config file and the
* existing map files.
*
* GIVEN : Flag indicating if containers and domains should be set up.
*
* RETURNS : Success code
*/
{
char **dom_list;
int num_doms, i;
/* Dump all domains in list */
for (i = 0; i < num_doms; i++) {
return (FAILURE);
}
return (SUCCESS);
}
/*
* FUNCTION : dump_domain_to_dit()
*
* DESCRIPTION: Dumps all maps in one domain into the DIT
*
* GIVEN : Name of the domain
* Flag indicating if containers and domains should be set up.
*
* RETURNS : SUCCESS = domain completely dumped
* FAILURE = domain not completely dumped
*
*/
{
char **map_list;
int i;
/* Set up nis domain object */
if (init_containers)
"Could not make nisDomain object for %s", dom_name);
else
"Problem detected with nisDomain object for %s",
dom_name);
return (FAILURE);
}
/* Get list of maps from mapping file */
"Could not get map list for %s", dom_name);
return (FAILURE);
}
}
return (SUCCESS);
}
/*
* FUNCTION : dump_map_to_dit()
*
* DESCRIPTION: Dump a OLD STYLE NIS map into the DIT.
*
* GIVEN : Name of map (not fully qualified)
* Name of domain
* Flag indicating if containers should be set up.
*
* RETURNS : SUCCESS = Map copy completed
* FAILURE = Map copy not completed
*/
{
int entry_count;
int next_print;
printf("Copying map \"%s\", domain \"%s\", to LDAP.\n",
/* Create the NIS container */
if (init_containers)
"Could not make container for %s %s",
else
"Problem detected with container for %s %s",
return (FAILURE);
}
/* Make up fully qualified map name */
ypdbpath_sz + 3);
return (FAILURE);
}
/* Open the DBM file. Use real dbm call */
/* Finished with full name */
/*
* This map probably didn't exist. No problem, user may be
* going to populate container using LDAP.
*/
return (SUCCESS);
}
/*
* N2L has no lock for old style maps. No problem ypserv -i is the
* only thing that accesses them.
*/
/* For all entries in file */
/* Don't write zero length keys */
continue;
}
/* Don't write 'special' nis entries */
if (is_special_key(&key))
continue;
/* Get entry */
/* Copy entry to DIT */
/* Syslog will have already been done */
break;
/* If necessary print a progress report */
if (entry_count >= next_print) {
next_print *= 2;
}
}
return (SUCCESS);
}
/*
* FUNCTION : dump_dit_to_maps()
*
* DESCRIPTION: Dumps the contents of the DIT into the NEW STYLE NIS maps. If
* the maps, or their TTL files do not exist creates them.
*
* Since we are now treating the DIT as authoritative details of
* which domains and maps exist are gathered from the DIT.
*
* GIVEN : Nothing
*
* RETURNS : Success code
*/
{
char **dom_list;
int dom_count;
char *dom_path;
char **map_list;
int i, j;
/* For all domain objects in DIT */
if (0 == dom_count) {
/* No problem, maybe no domains */
return (SUCCESS);
}
/* Dump all domains in list */
for (i = 0; i < dom_count; i++) {
/* If necessary create domain directory */
return (FAILURE);
}
/* If dir exists fine. Just use it */
"Could not make create domain directory %s",
dom_path);
}
}
/* Get list of maps for this domain */
/* No problem. Just no maps in this domain */
continue;
}
/* For all maps in domain */
/* A normal map update will initialize it. */
dom_list[i])) {
return (FAILURE);
}
/* If we have a netgroup also generate netgroup.byxxx */
dom_list[i])) {
return (FAILURE);
}
dom_list[i])) {
return (FAILURE);
}
}
}
}
return (SUCCESS);
}
/*
* FUNCTION : dump_dit_to_map()
*
* DESCRIPTION: Dumps the contents of the DIT into one NEW STYLE NIS map. If
* the map, or its TTL file does not exist creates them.
*
* This is the same operation as is carried out when updating a
* map that has timed out. As a result we can call the normal
* update function.
*
*
* GIVEN : Map name (unqualified)
* Domain name.
*
* RETURNS : SUCCESS = Map copy complete
* FAILURE = Problems
*/
{
char *map_path;
printf("Copying LDAP data to map \"%s\", domain \"%s\".\n",
/*
* To call update_map_from_dit() we need an initialized map_ctrl.
* The easiest way to get this is to generate a full path to the new
* map and then call map_ctrl_init().
*/
return (FAILURE);
return (FAILURE);
}
/*
* This is called before anything else is running so don't need to
* do normal update lock.
*/
}
/*
* FUNCTION : add_separator()
*
* DESCRIPTION: Adds a file separator to a string (which must already be big
* enough.)
*
* GIVEN : Pointer to the string
*
* RETURNS : Nothing
*/
void
{
char *p;
*p = SEP_CHAR;
*(p+1) = '\0';
}