cold_start.cc revision 7b1b42816975f5b0069dff7932115ba672ad125c
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Ported from SCCS version :
* "@(#)cold_start.cc 1.16 91/03/14 Copyr 1988 Sun Micro";
*
*
* This file contains all the procedures that operate on the NIS
* cold start file.
* The NIS cold start file contains one directory object of the home
* domain that we trust. This file is created out of band, by the
* program nisinit or some other such facility. This trusted directory
* object is used to bootstrap the whole chain of trust that the
* authentication in NIS is based upon.
* This file is read in by the cachemgr when it starts up, and if
* the cache manager is not running, then by the LocaClientCache
* in each process.
* The cachemgr also updates this file when it gets a new directory
* object for this entry.
*/
#include "mt.h"
#include "../gen/nis_local.h"
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <fcntl.h>
#include "cache.h"
#include "nis_cache.h"
/*
* Routine to read from the cold start file.
* Reads in a directory object into *dobj.
* The cold start file contains an XDR'ed directory object
* that is the "home" directory object and is used to establish
* trust.
* The file is normally created by the program nisinit.
* It is read by the cachemgr on startup and by the local cache if
* it needs to create a local, per-process cache.
*/
static
{
return (FALSE);
}
}
// change the absolute time in the stored directory object
// back into a ttl that is the field in the directory object.
if (ret_val) {
if (prime)
}
return (ret_val);
}
/*
* Read coldstart file and prime public key cache.
*/
{
}
/*
* Read coldstart file, but don't prime cache. This avoids
* any possibility of recursion.
*/
static
{
}
/*
* Writes out the directory object in dobj into the cold start file
* in XDR form.
* Converts the ttl field into absolute time that is converted back
* into ttl whenever this entry is read.
*/
{
int fd;
// We do the standard create-a-temp-file-and-rename-it thing so
// that writers and readers coexist happily. This means that
// we have to have write permission on the directory; so be it.
// Symbolic links may also cause grief.
if (fd < 0) {
"NIS+: writeColdStartFile cannot open file '%s' for writing: %m",
tempName);
return (FALSE);
}
// get a stream for xdr
"NIS+: writeColdStartFile: fdopen() failed for '%s': %m",
tempName);
return (FALSE);
}
// make sure the file has the right permissions
// writable by root, and readable by everybody else
"NIS+: writeColdStartFile: could not chmod cold_start file: %m");
goto err;
}
// change time to live in the directory object into absolute time.
// this has to be reconverted back into a ttl when the directory
// object is read
"NIS+: writeColdStartFile: xdr_directory_obj failed");
goto err;
}
// rename the temporary file to the actual cold start file file
"NIS+: writeColdStartFile: error while renaming '%s' to '%s': (%m)",
return (FALSE);
}
return (TRUE);
err:
return (FALSE);
}
/*
* C interface to write Coldstart file
* This routine is called to write the cold start file
* called by the program nisinit
*/
extern "C" bool_t
{
}
extern "C" bool_t
{
return (rc);
}
extern "C" bool_t
{
}
extern "C" bool_t
{
return (rc);
}