mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
util: store identity attrs as virTypedParameter internally
We'll shortly be exposing the identity as virTypedParameter in the public header, so it simplifies life to use that as the internal representation too. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
45b273d981
commit
b1aa312185
@ -41,24 +41,12 @@
|
|||||||
|
|
||||||
VIR_LOG_INIT("util.identity");
|
VIR_LOG_INIT("util.identity");
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
VIR_IDENTITY_ATTR_USER_NAME,
|
|
||||||
VIR_IDENTITY_ATTR_UNIX_USER_ID,
|
|
||||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
|
||||||
VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
|
|
||||||
VIR_IDENTITY_ATTR_PROCESS_ID,
|
|
||||||
VIR_IDENTITY_ATTR_PROCESS_TIME,
|
|
||||||
VIR_IDENTITY_ATTR_SASL_USER_NAME,
|
|
||||||
VIR_IDENTITY_ATTR_X509_DISTINGUISHED_NAME,
|
|
||||||
VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
|
|
||||||
|
|
||||||
VIR_IDENTITY_ATTR_LAST,
|
|
||||||
} virIdentityAttrType;
|
|
||||||
|
|
||||||
struct _virIdentity {
|
struct _virIdentity {
|
||||||
virObject parent;
|
virObject parent;
|
||||||
|
|
||||||
char *attrs[VIR_IDENTITY_ATTR_LAST];
|
int nparams;
|
||||||
|
int maxparams;
|
||||||
|
virTypedParameterPtr params;
|
||||||
};
|
};
|
||||||
|
|
||||||
static virClassPtr virIdentityClass;
|
static virClassPtr virIdentityClass;
|
||||||
@ -229,67 +217,8 @@ virIdentityPtr virIdentityNew(void)
|
|||||||
static void virIdentityDispose(void *object)
|
static void virIdentityDispose(void *object)
|
||||||
{
|
{
|
||||||
virIdentityPtr ident = object;
|
virIdentityPtr ident = object;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < VIR_IDENTITY_ATTR_LAST; i++)
|
virTypedParamsFree(ident->params, ident->nparams);
|
||||||
VIR_FREE(ident->attrs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virIdentitySetAttr:
|
|
||||||
* @ident: the identity to modify
|
|
||||||
* @attr: the attribute type to set
|
|
||||||
* @value: the identifying value to associate with @attr
|
|
||||||
*
|
|
||||||
* Sets an identifying attribute @attr on @ident. Each
|
|
||||||
* @attr type can only be set once.
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, or -1 on error
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virIdentitySetAttr(virIdentityPtr ident,
|
|
||||||
unsigned int attr,
|
|
||||||
const char *value)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
VIR_DEBUG("ident=%p attribute=%u value=%s", ident, attr, value);
|
|
||||||
|
|
||||||
if (ident->attrs[attr]) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
||||||
_("Identity attribute is already set"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(ident->attrs[attr], value) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virIdentityGetAttr:
|
|
||||||
* @ident: the identity to query
|
|
||||||
* @attr: the attribute to read
|
|
||||||
* @value: filled with the attribute value
|
|
||||||
*
|
|
||||||
* Fills @value with a pointer to the value associated
|
|
||||||
* with the identifying attribute @attr in @ident. If
|
|
||||||
* @attr is not set, then it will simply be initialized
|
|
||||||
* to NULL and considered as a successful read
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
virIdentityGetAttr(virIdentityPtr ident,
|
|
||||||
unsigned int attr,
|
|
||||||
const char **value)
|
|
||||||
{
|
|
||||||
VIR_DEBUG("ident=%p attribute=%d value=%p", ident, attr, value);
|
|
||||||
|
|
||||||
*value = ident->attrs[attr];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,14 +228,11 @@ virIdentityGetAttr(virIdentityPtr ident,
|
|||||||
int virIdentityGetUserName(virIdentityPtr ident,
|
int virIdentityGetUserName(virIdentityPtr ident,
|
||||||
const char **username)
|
const char **username)
|
||||||
{
|
{
|
||||||
virIdentityGetAttr(ident,
|
*username = NULL;
|
||||||
VIR_IDENTITY_ATTR_USER_NAME,
|
return virTypedParamsGetString(ident->params,
|
||||||
username);
|
ident->nparams,
|
||||||
|
VIR_CONNECT_IDENTITY_USER_NAME,
|
||||||
if (!*username)
|
username);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -316,21 +242,16 @@ int virIdentityGetUserName(virIdentityPtr ident,
|
|||||||
int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
||||||
uid_t *uid)
|
uid_t *uid)
|
||||||
{
|
{
|
||||||
int val;
|
unsigned long long val;
|
||||||
const char *userid;
|
int rc;
|
||||||
|
|
||||||
*uid = -1;
|
*uid = -1;
|
||||||
virIdentityGetAttr(ident,
|
rc = virTypedParamsGetULLong(ident->params,
|
||||||
VIR_IDENTITY_ATTR_UNIX_USER_ID,
|
ident->nparams,
|
||||||
&userid);
|
VIR_CONNECT_IDENTITY_UNIX_USER_ID,
|
||||||
if (!userid)
|
&val);
|
||||||
return 0;
|
if (rc <= 0)
|
||||||
|
return rc;
|
||||||
if (virStrToLong_i(userid, NULL, 10, &val) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot parse user ID '%s'"), userid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*uid = (uid_t)val;
|
*uid = (uid_t)val;
|
||||||
|
|
||||||
@ -344,14 +265,11 @@ int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
|||||||
int virIdentityGetGroupName(virIdentityPtr ident,
|
int virIdentityGetGroupName(virIdentityPtr ident,
|
||||||
const char **groupname)
|
const char **groupname)
|
||||||
{
|
{
|
||||||
virIdentityGetAttr(ident,
|
*groupname = NULL;
|
||||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
return virTypedParamsGetString(ident->params,
|
||||||
groupname);
|
ident->nparams,
|
||||||
|
VIR_CONNECT_IDENTITY_GROUP_NAME,
|
||||||
if (!*groupname)
|
groupname);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -361,22 +279,16 @@ int virIdentityGetGroupName(virIdentityPtr ident,
|
|||||||
int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
||||||
gid_t *gid)
|
gid_t *gid)
|
||||||
{
|
{
|
||||||
int val;
|
unsigned long long val;
|
||||||
const char *groupid;
|
int rc;
|
||||||
|
|
||||||
*gid = -1;
|
*gid = -1;
|
||||||
virIdentityGetAttr(ident,
|
rc = virTypedParamsGetULLong(ident->params,
|
||||||
VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
|
ident->nparams,
|
||||||
&groupid);
|
VIR_CONNECT_IDENTITY_UNIX_GROUP_ID,
|
||||||
|
&val);
|
||||||
if (!groupid)
|
if (rc <= 0)
|
||||||
return 0;
|
return rc;
|
||||||
|
|
||||||
if (virStrToLong_i(groupid, NULL, 10, &val) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot parse group ID '%s'"), groupid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*gid = (gid_t)val;
|
*gid = (gid_t)val;
|
||||||
|
|
||||||
@ -390,22 +302,16 @@ int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
|||||||
int virIdentityGetProcessID(virIdentityPtr ident,
|
int virIdentityGetProcessID(virIdentityPtr ident,
|
||||||
pid_t *pid)
|
pid_t *pid)
|
||||||
{
|
{
|
||||||
unsigned long long val;
|
long long val;
|
||||||
const char *processid;
|
int rc;
|
||||||
|
|
||||||
*pid = 0;
|
*pid = 0;
|
||||||
virIdentityGetAttr(ident,
|
rc = virTypedParamsGetLLong(ident->params,
|
||||||
VIR_IDENTITY_ATTR_PROCESS_ID,
|
ident->nparams,
|
||||||
&processid);
|
VIR_CONNECT_IDENTITY_PROCESS_ID,
|
||||||
|
&val);
|
||||||
if (!processid)
|
if (rc <= 0)
|
||||||
return 0;
|
return rc;
|
||||||
|
|
||||||
if (virStrToLong_ull(processid, NULL, 10, &val) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot parse process ID '%s'"), processid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pid = (pid_t)val;
|
*pid = (pid_t)val;
|
||||||
|
|
||||||
@ -419,23 +325,11 @@ int virIdentityGetProcessID(virIdentityPtr ident,
|
|||||||
int virIdentityGetProcessTime(virIdentityPtr ident,
|
int virIdentityGetProcessTime(virIdentityPtr ident,
|
||||||
unsigned long long *timestamp)
|
unsigned long long *timestamp)
|
||||||
{
|
{
|
||||||
const char *processtime;
|
|
||||||
|
|
||||||
*timestamp = 0;
|
*timestamp = 0;
|
||||||
virIdentityGetAttr(ident,
|
return virTypedParamsGetULLong(ident->params,
|
||||||
VIR_IDENTITY_ATTR_PROCESS_TIME,
|
ident->nparams,
|
||||||
&processtime);
|
VIR_CONNECT_IDENTITY_PROCESS_TIME,
|
||||||
|
timestamp);
|
||||||
if (!processtime)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (virStrToLong_ull(processtime, NULL, 10, timestamp) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot parse process time '%s'"), processtime);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,14 +339,11 @@ int virIdentityGetProcessTime(virIdentityPtr ident,
|
|||||||
int virIdentityGetSASLUserName(virIdentityPtr ident,
|
int virIdentityGetSASLUserName(virIdentityPtr ident,
|
||||||
const char **username)
|
const char **username)
|
||||||
{
|
{
|
||||||
virIdentityGetAttr(ident,
|
*username = NULL;
|
||||||
VIR_IDENTITY_ATTR_SASL_USER_NAME,
|
return virTypedParamsGetString(ident->params,
|
||||||
username);
|
ident->nparams,
|
||||||
|
VIR_CONNECT_IDENTITY_SASL_USER_NAME,
|
||||||
if (!*username)
|
username);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -462,14 +353,11 @@ int virIdentityGetSASLUserName(virIdentityPtr ident,
|
|||||||
int virIdentityGetX509DName(virIdentityPtr ident,
|
int virIdentityGetX509DName(virIdentityPtr ident,
|
||||||
const char **dname)
|
const char **dname)
|
||||||
{
|
{
|
||||||
virIdentityGetAttr(ident,
|
*dname = NULL;
|
||||||
VIR_IDENTITY_ATTR_X509_DISTINGUISHED_NAME,
|
return virTypedParamsGetString(ident->params,
|
||||||
dname);
|
ident->nparams,
|
||||||
|
VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME,
|
||||||
if (!*dname)
|
dname);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -479,88 +367,125 @@ int virIdentityGetX509DName(virIdentityPtr ident,
|
|||||||
int virIdentityGetSELinuxContext(virIdentityPtr ident,
|
int virIdentityGetSELinuxContext(virIdentityPtr ident,
|
||||||
const char **context)
|
const char **context)
|
||||||
{
|
{
|
||||||
virIdentityGetAttr(ident,
|
*context = NULL;
|
||||||
VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
|
return virTypedParamsGetString(ident->params,
|
||||||
context);
|
ident->nparams,
|
||||||
|
VIR_CONNECT_IDENTITY_SELINUX_CONTEXT,
|
||||||
if (!*context)
|
context);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetUserName(virIdentityPtr ident,
|
int virIdentitySetUserName(virIdentityPtr ident,
|
||||||
const char *username)
|
const char *username)
|
||||||
{
|
{
|
||||||
return virIdentitySetAttr(ident,
|
if (virTypedParamsGet(ident->params,
|
||||||
VIR_IDENTITY_ATTR_USER_NAME,
|
ident->nparams,
|
||||||
username);
|
VIR_CONNECT_IDENTITY_USER_NAME)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virTypedParamsAddString(&ident->params,
|
||||||
|
&ident->nparams,
|
||||||
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_USER_NAME,
|
||||||
|
username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetUNIXUserID(virIdentityPtr ident,
|
int virIdentitySetUNIXUserID(virIdentityPtr ident,
|
||||||
uid_t uid)
|
uid_t uid)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) val = NULL;
|
if (virTypedParamsGet(ident->params,
|
||||||
|
ident->nparams,
|
||||||
if (virAsprintf(&val, "%d", (int)uid) < 0)
|
VIR_CONNECT_IDENTITY_UNIX_USER_ID)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return virIdentitySetAttr(ident,
|
return virTypedParamsAddULLong(&ident->params,
|
||||||
VIR_IDENTITY_ATTR_UNIX_USER_ID,
|
&ident->nparams,
|
||||||
val);
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_UNIX_USER_ID,
|
||||||
|
uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetGroupName(virIdentityPtr ident,
|
int virIdentitySetGroupName(virIdentityPtr ident,
|
||||||
const char *groupname)
|
const char *groupname)
|
||||||
{
|
{
|
||||||
return virIdentitySetAttr(ident,
|
if (virTypedParamsGet(ident->params,
|
||||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
ident->nparams,
|
||||||
groupname);
|
VIR_CONNECT_IDENTITY_GROUP_NAME)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virTypedParamsAddString(&ident->params,
|
||||||
|
&ident->nparams,
|
||||||
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_GROUP_NAME,
|
||||||
|
groupname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetUNIXGroupID(virIdentityPtr ident,
|
int virIdentitySetUNIXGroupID(virIdentityPtr ident,
|
||||||
gid_t gid)
|
gid_t gid)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) val = NULL;
|
if (virTypedParamsGet(ident->params,
|
||||||
|
ident->nparams,
|
||||||
if (virAsprintf(&val, "%d", (int)gid) < 0)
|
VIR_CONNECT_IDENTITY_UNIX_GROUP_ID)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return virIdentitySetAttr(ident,
|
return virTypedParamsAddULLong(&ident->params,
|
||||||
VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
|
&ident->nparams,
|
||||||
val);
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_UNIX_GROUP_ID,
|
||||||
|
gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetProcessID(virIdentityPtr ident,
|
int virIdentitySetProcessID(virIdentityPtr ident,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) val = NULL;
|
if (virTypedParamsGet(ident->params,
|
||||||
|
ident->nparams,
|
||||||
if (virAsprintf(&val, "%lld", (long long) pid) < 0)
|
VIR_CONNECT_IDENTITY_PROCESS_ID)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return virIdentitySetAttr(ident,
|
return virTypedParamsAddLLong(&ident->params,
|
||||||
VIR_IDENTITY_ATTR_PROCESS_ID,
|
&ident->nparams,
|
||||||
val);
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_PROCESS_ID,
|
||||||
|
pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetProcessTime(virIdentityPtr ident,
|
int virIdentitySetProcessTime(virIdentityPtr ident,
|
||||||
unsigned long long timestamp)
|
unsigned long long timestamp)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) val = NULL;
|
if (virTypedParamsGet(ident->params,
|
||||||
|
ident->nparams,
|
||||||
if (virAsprintf(&val, "%llu", timestamp) < 0)
|
VIR_CONNECT_IDENTITY_PROCESS_TIME)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return virIdentitySetAttr(ident,
|
return virTypedParamsAddULLong(&ident->params,
|
||||||
VIR_IDENTITY_ATTR_PROCESS_TIME,
|
&ident->nparams,
|
||||||
val);
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_PROCESS_TIME,
|
||||||
|
timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -568,25 +493,55 @@ int virIdentitySetProcessTime(virIdentityPtr ident,
|
|||||||
int virIdentitySetSASLUserName(virIdentityPtr ident,
|
int virIdentitySetSASLUserName(virIdentityPtr ident,
|
||||||
const char *username)
|
const char *username)
|
||||||
{
|
{
|
||||||
return virIdentitySetAttr(ident,
|
if (virTypedParamsGet(ident->params,
|
||||||
VIR_IDENTITY_ATTR_SASL_USER_NAME,
|
ident->nparams,
|
||||||
username);
|
VIR_CONNECT_IDENTITY_SASL_USER_NAME)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virTypedParamsAddString(&ident->params,
|
||||||
|
&ident->nparams,
|
||||||
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_SASL_USER_NAME,
|
||||||
|
username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetX509DName(virIdentityPtr ident,
|
int virIdentitySetX509DName(virIdentityPtr ident,
|
||||||
const char *dname)
|
const char *dname)
|
||||||
{
|
{
|
||||||
return virIdentitySetAttr(ident,
|
if (virTypedParamsGet(ident->params,
|
||||||
VIR_IDENTITY_ATTR_X509_DISTINGUISHED_NAME,
|
ident->nparams,
|
||||||
dname);
|
VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virTypedParamsAddString(&ident->params,
|
||||||
|
&ident->nparams,
|
||||||
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME,
|
||||||
|
dname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virIdentitySetSELinuxContext(virIdentityPtr ident,
|
int virIdentitySetSELinuxContext(virIdentityPtr ident,
|
||||||
const char *context)
|
const char *context)
|
||||||
{
|
{
|
||||||
return virIdentitySetAttr(ident,
|
if (virTypedParamsGet(ident->params,
|
||||||
VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
|
ident->nparams,
|
||||||
context);
|
VIR_CONNECT_IDENTITY_SELINUX_CONTEXT)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
|
_("Identity attribute is already set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virTypedParamsAddString(&ident->params,
|
||||||
|
&ident->nparams,
|
||||||
|
&ident->maxparams,
|
||||||
|
VIR_CONNECT_IDENTITY_SELINUX_CONTEXT,
|
||||||
|
context);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user