2014-03-26 20:09:46 +00:00
|
|
|
/*
|
|
|
|
* virseclabel.c: security label utility functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2014 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "virseclabel.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityLabelDefFree(virSecurityLabelDef *def)
|
2014-03-26 20:09:46 +00:00
|
|
|
{
|
|
|
|
if (!def)
|
|
|
|
return;
|
2021-02-03 19:32:34 +00:00
|
|
|
g_free(def->model);
|
|
|
|
g_free(def->label);
|
|
|
|
g_free(def->imagelabel);
|
|
|
|
g_free(def->baselabel);
|
|
|
|
g_free(def);
|
2014-03-26 20:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDef *def)
|
2014-03-26 20:09:46 +00:00
|
|
|
{
|
|
|
|
if (!def)
|
|
|
|
return;
|
2021-02-03 19:32:34 +00:00
|
|
|
g_free(def->model);
|
|
|
|
g_free(def->label);
|
|
|
|
g_free(def);
|
2014-03-26 20:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityLabelDef *
|
2014-03-26 20:09:46 +00:00
|
|
|
virSecurityLabelDefNew(const char *model)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityLabelDef *seclabel = NULL;
|
2014-03-26 20:09:46 +00:00
|
|
|
|
2020-10-05 17:13:12 +00:00
|
|
|
seclabel = g_new0(virSecurityLabelDef, 1);
|
2014-03-26 20:09:46 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
seclabel->model = g_strdup(model);
|
|
|
|
|
2014-07-09 11:23:58 +00:00
|
|
|
seclabel->relabel = true;
|
|
|
|
|
2014-03-26 20:09:46 +00:00
|
|
|
return seclabel;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityDeviceLabelDef *
|
2014-03-26 20:09:46 +00:00
|
|
|
virSecurityDeviceLabelDefNew(const char *model)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityDeviceLabelDef *seclabel = NULL;
|
2014-03-26 20:09:46 +00:00
|
|
|
|
2020-10-05 17:13:12 +00:00
|
|
|
seclabel = g_new0(virSecurityDeviceLabelDef, 1);
|
2014-03-26 20:09:46 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
seclabel->model = g_strdup(model);
|
|
|
|
|
2014-03-26 20:09:46 +00:00
|
|
|
return seclabel;
|
|
|
|
}
|
2014-06-12 14:03:06 +00:00
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityDeviceLabelDef *
|
2014-06-12 14:03:06 +00:00
|
|
|
virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virSecurityDeviceLabelDef *ret;
|
2014-06-12 14:03:06 +00:00
|
|
|
|
2020-10-05 17:13:12 +00:00
|
|
|
ret = g_new0(virSecurityDeviceLabelDef, 1);
|
2014-06-12 14:03:06 +00:00
|
|
|
|
2014-07-09 12:11:49 +00:00
|
|
|
ret->relabel = src->relabel;
|
2014-06-12 14:03:06 +00:00
|
|
|
ret->labelskip = src->labelskip;
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
ret->model = g_strdup(src->model);
|
|
|
|
ret->label = g_strdup(src->label);
|
2014-06-12 14:03:06 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|