/*
* 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
*/
/*
*/
#include <sys/pathname.h>
#include <sys/dsl_prop.h>
#include <nfs/nfs_clnt.h>
/*
* Initialize labels infrastructure.
* This is called during startup() time (before vfs_mntroot) by thread_init().
* It has to be called early so that the is_system_labeled() function returns
* the right value when called by the networking code on a diskless boot.
*/
void
label_init(void)
{
/*
* sys_labeling will default to "off" unless it is overridden
*/
}
/*
* Allocate new ts_label_t.
*/
{
else
}
return (lab);
}
/*
* Duplicate an existing ts_label_t to a new one, with only
* the current reference.
*/
{
}
return (lab);
}
/*
* Put a hold on a label structure.
*/
void
{
}
/*
* Release previous hold on a label structure. Free it if refcnt == 0.
*/
void
{
}
{
}
{
}
/*
* Compare labels. Return 1 if equal, 0 otherwise.
*/
{
}
/*
* There's no protocol today to obtain the label from the server.
* So we rely on conventions: zones, zone names, and zone paths
* must match across TX servers and their TX clients. Now use
* the exported name to find the equivalent local zone and its
* label. Caller is responsible for doing a label_rele of the
* returned ts_label.
*/
{
return (NULL); /* error */
if (respath)
respath++; /* skip over ":" */
if (*respath != '/') {
/* treat path as absolute but it doesn't have leading '/' */
}
if (reszone == global_zone) {
return (l_admin_low);
}
/*
*/
if (treat_abs)
respath--; /* no leading '/' to skip */
if (new_reszone != global_zone) {
} else {
}
}
return (reszone->zone_slabel);
}
/*
* Get the label if any of a zfs filesystem. Get the dataset, then
* get its mlslabel property, convert as needed, and return it. If
* there's no mlslabel or it is the default one, return NULL.
*/
static ts_label_t *
{
int error;
const char *osname;
return (NULL);
return (NULL);
return (tsl);
}
static ts_label_t *
{
int addr_type;
void *ipaddr;
/* LINTED: following cast to ipaddr is OK */
/* LINTED: following cast to ipaddr is OK */
} else {
goto errout;
}
goto errout;
return (getflabel_cipso(vfsp));
}
goto errout;
return (srv_label);
return (NULL);
}
/*
* getflabel -
*
* Return pointer to the ts_label associated with the specified file,
* or returns NULL if error occurs. Caller is responsible for doing
* a label_rele of the ts_label.
*/
{
int err;
return (NULL);
/*
* Traverse lofs mounts and fattach'es to get the real vnode
*/
/* Go elsewhere to handle all nfs files. */
return (getflabel_nfs(rvfsp));
/*
* Fast path, for objects in a labeled zone: everything except
*/
"lofs") != 0)) {
goto zone_out; /* return this label */
}
}
/*
* Get the vnode path -- it may be missing or weird for some
* cases, like devices. In those cases use the label of the
* current zone.
*/
goto zone_out;
}
/*
* For zfs filesystem, return the explicit label property if a
* meaningful one exists.
*/
/* if label found, return it, otherwise continue... */
return (tsl);
}
/*
* If a mountpoint exists, hold the vfs while we reference it.
* Otherwise if mountpoint is NULL it should not be held (e.g.,
* and panic.)
*/
}
/*
* If the vnode source zone is properly set to a non-global zone, or
* any zone if the mount is R/W, then use the label of that zone.
*/
goto zone_out; /* return this label */
/*
* Otherwise, if we're not in the global zone, use the label of
* our zone.
*/
goto zone_out; /* return this label */
}
/*
* We're in the global zone and the mount is R/W ... so the file
* may actually be in the global zone -- or in the root of any zone.
* Always build our own path for the file, to be sure it's simplified
* (i.e., no ".", "..", "//", and so on).
*/
char *mntpt;
/*
* File is in the global zone - check whether it's admin_high.
* If it's in a filesys that was exported from the global zone,
* it's admin_low by definition. Otherwise, if it's in a
* filesys that's NOT exported to any zone, it's admin_high.
*
* And for these files if there wasn't a valid mount resource,
* the file must be admin_high (not exported, probably a global
* zone device).
*/
if (!vfs_is_held)
goto out_high;
if (to_zone != global_zone) {
/* force admin_low */
}
}
if (mntpt_ref)
if (!exported) {
const char *rstr;
/*
* Skip checking this vfs if it's not lofs
* (the only way to export from the global
* zone to a zone).
*/
"lofs", 4) != 0) {
continue;
}
/*
* Check for a match: does this vfs correspond
* to our global zone file path? I.e., check
* if the resource string of this vfs is a
* prefix of our path.
*/
/* force admin_low */
break;
}
}
}
if (!exported)
goto out_high;
}
if (vfs_is_held)
/*
* Now that we have the "home" zone for the file, return the slabel
* of that zone.
*/
label_hold(zl);
return (zl);
if (vfs_is_held)
return (l_admin_high);
}
static int
{
int error = 0;
return (EIO);
sizeof (*(label_p))) != 0)
return (error);
}
/*
* fgetlabel(2TSOL) - get file label
* getlabel(2TSOL) - get file label
*/
int
{
char *spath;
int error;
/* Sanity check arguments */
}
}
if (error != 0)
else
return (0);
}
int
{
int error;
if (error != 0)
else
return (0);
}