1 /* 2 * virseclabel.c: security label utility functions 3 * 4 * Copyright (C) 2006-2014 Red Hat, Inc. 5 * Copyright (C) 2006-2008 Daniel P. Berrange 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #include <config.h> 23 24 #include "internal.h" 25 #include "viralloc.h" 26 #include "virseclabel.h" 27 #include "virstring.h" 28 29 #define VIR_FROM_THIS VIR_FROM_NONE 30 31 32 void virSecurityLabelDefFree(virSecurityLabelDef * def)33virSecurityLabelDefFree(virSecurityLabelDef *def) 34 { 35 if (!def) 36 return; 37 g_free(def->model); 38 g_free(def->label); 39 g_free(def->imagelabel); 40 g_free(def->baselabel); 41 g_free(def); 42 } 43 44 45 void virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDef * def)46virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDef *def) 47 { 48 if (!def) 49 return; 50 g_free(def->model); 51 g_free(def->label); 52 g_free(def); 53 } 54 55 56 virSecurityLabelDef * virSecurityLabelDefNew(const char * model)57virSecurityLabelDefNew(const char *model) 58 { 59 virSecurityLabelDef *seclabel = NULL; 60 61 seclabel = g_new0(virSecurityLabelDef, 1); 62 63 seclabel->model = g_strdup(model); 64 65 seclabel->relabel = true; 66 67 return seclabel; 68 } 69 70 virSecurityDeviceLabelDef * virSecurityDeviceLabelDefNew(const char * model)71virSecurityDeviceLabelDefNew(const char *model) 72 { 73 virSecurityDeviceLabelDef *seclabel = NULL; 74 75 seclabel = g_new0(virSecurityDeviceLabelDef, 1); 76 77 seclabel->model = g_strdup(model); 78 79 return seclabel; 80 } 81 82 83 virSecurityDeviceLabelDef * virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef * src)84virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src) 85 { 86 virSecurityDeviceLabelDef *ret; 87 88 ret = g_new0(virSecurityDeviceLabelDef, 1); 89 90 ret->relabel = src->relabel; 91 ret->labelskip = src->labelskip; 92 93 ret->model = g_strdup(src->model); 94 ret->label = g_strdup(src->label); 95 96 return ret; 97 } 98