mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: change identity class attribute names
Remove the "UNIX" tag from the names for user name, group name, process ID and process time, since these attributes are all usable for non-UNIX platforms like Windows. User ID and group ID are left with a "UNIX" tag, since there's no equivalent on Windows. The closest equivalent concept on Windows, SID, is a struct containing a number of integer fields, which is commonly represented in string format instead. This would require a separate attribute, and is left for a future exercise, since the daemons are not currently built on Windows anyway. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
305cdc37f0
commit
4597a23f50
@ -88,14 +88,14 @@ virAccessDriverPolkitGetCaller(const char *actionid,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virIdentityGetUNIXProcessID(identity, pid) < 0) {
|
||||
if (virIdentityGetProcessID(identity, pid) < 0) {
|
||||
virAccessError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("No UNIX process ID available"));
|
||||
_("No process ID available"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virIdentityGetUNIXProcessTime(identity, startTime) < 0) {
|
||||
if (virIdentityGetProcessTime(identity, startTime) < 0) {
|
||||
virAccessError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("No UNIX process start time available"));
|
||||
_("No process start time available"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virIdentityGetUNIXUserID(identity, uid) < 0) {
|
||||
|
@ -262,7 +262,7 @@ adminClientGetInfo(virNetServerClientPtr client,
|
||||
VIR_CLIENT_INFO_UNIX_USER_ID, uid) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virIdentityGetUNIXUserName(identity, &attr) < 0 ||
|
||||
if (virIdentityGetUserName(identity, &attr) < 0 ||
|
||||
virTypedParamsAddString(&tmpparams, nparams, &maxparams,
|
||||
VIR_CLIENT_INFO_UNIX_USER_NAME,
|
||||
attr) < 0)
|
||||
@ -273,13 +273,13 @@ adminClientGetInfo(virNetServerClientPtr client,
|
||||
VIR_CLIENT_INFO_UNIX_GROUP_ID, gid) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virIdentityGetUNIXGroupName(identity, &attr) < 0 ||
|
||||
if (virIdentityGetGroupName(identity, &attr) < 0 ||
|
||||
virTypedParamsAddString(&tmpparams, nparams, &maxparams,
|
||||
VIR_CLIENT_INFO_UNIX_GROUP_NAME,
|
||||
attr) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virIdentityGetUNIXProcessID(identity, &pid) < 0 ||
|
||||
if (virIdentityGetProcessID(identity, &pid) < 0 ||
|
||||
virTypedParamsAddInt(&tmpparams, nparams, &maxparams,
|
||||
VIR_CLIENT_INFO_UNIX_PROCESS_ID, pid) < 0)
|
||||
goto cleanup;
|
||||
|
@ -2144,28 +2144,28 @@ virHostGetBootTime;
|
||||
# util/viridentity.h
|
||||
virIdentityGetAttr;
|
||||
virIdentityGetCurrent;
|
||||
virIdentityGetGroupName;
|
||||
virIdentityGetProcessID;
|
||||
virIdentityGetProcessTime;
|
||||
virIdentityGetSASLUserName;
|
||||
virIdentityGetSELinuxContext;
|
||||
virIdentityGetSystem;
|
||||
virIdentityGetUNIXGroupID;
|
||||
virIdentityGetUNIXGroupName;
|
||||
virIdentityGetUNIXProcessID;
|
||||
virIdentityGetUNIXProcessTime;
|
||||
virIdentityGetUNIXUserID;
|
||||
virIdentityGetUNIXUserName;
|
||||
virIdentityGetUserName;
|
||||
virIdentityGetX509DName;
|
||||
virIdentityIsEqual;
|
||||
virIdentityNew;
|
||||
virIdentitySetAttr;
|
||||
virIdentitySetCurrent;
|
||||
virIdentitySetGroupName;
|
||||
virIdentitySetProcessID;
|
||||
virIdentitySetProcessTime;
|
||||
virIdentitySetSASLUserName;
|
||||
virIdentitySetSELinuxContext;
|
||||
virIdentitySetUNIXGroupID;
|
||||
virIdentitySetUNIXGroupName;
|
||||
virIdentitySetUNIXProcessID;
|
||||
virIdentitySetUNIXProcessTime;
|
||||
virIdentitySetUNIXUserID;
|
||||
virIdentitySetUNIXUserName;
|
||||
virIdentitySetUserName;
|
||||
virIdentitySetX509DName;
|
||||
|
||||
|
||||
|
@ -779,21 +779,21 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client)
|
||||
|
||||
if (!(username = virGetUserName(uid)))
|
||||
goto error;
|
||||
if (virIdentitySetUNIXUserName(ret, username) < 0)
|
||||
if (virIdentitySetUserName(ret, username) < 0)
|
||||
goto error;
|
||||
if (virIdentitySetUNIXUserID(ret, uid) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(groupname = virGetGroupName(gid)))
|
||||
goto error;
|
||||
if (virIdentitySetUNIXGroupName(ret, groupname) < 0)
|
||||
if (virIdentitySetGroupName(ret, groupname) < 0)
|
||||
goto error;
|
||||
if (virIdentitySetUNIXGroupID(ret, gid) < 0)
|
||||
goto error;
|
||||
|
||||
if (virIdentitySetUNIXProcessID(ret, pid) < 0)
|
||||
if (virIdentitySetProcessID(ret, pid) < 0)
|
||||
goto error;
|
||||
if (virIdentitySetUNIXProcessTime(ret, timestamp) < 0)
|
||||
if (virIdentitySetProcessTime(ret, timestamp) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -144,25 +144,25 @@ virIdentityPtr virIdentityGetSystem(void)
|
||||
if (!(ret = virIdentityNew()))
|
||||
goto error;
|
||||
|
||||
if (virIdentitySetUNIXProcessID(ret, getpid()) < 0)
|
||||
if (virIdentitySetProcessID(ret, getpid()) < 0)
|
||||
goto error;
|
||||
|
||||
if (virProcessGetStartTime(getpid(), &startTime) < 0)
|
||||
goto error;
|
||||
if (startTime != 0 &&
|
||||
virIdentitySetUNIXProcessTime(ret, startTime) < 0)
|
||||
virIdentitySetProcessTime(ret, startTime) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(username = virGetUserName(geteuid())))
|
||||
return ret;
|
||||
if (virIdentitySetUNIXUserName(ret, username) < 0)
|
||||
if (virIdentitySetUserName(ret, username) < 0)
|
||||
goto error;
|
||||
if (virIdentitySetUNIXUserID(ret, getuid()) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(groupname = virGetGroupName(getegid())))
|
||||
return ret;
|
||||
if (virIdentitySetUNIXGroupName(ret, groupname) < 0)
|
||||
if (virIdentitySetGroupName(ret, groupname) < 0)
|
||||
goto error;
|
||||
if (virIdentitySetUNIXGroupID(ret, getgid()) < 0)
|
||||
goto error;
|
||||
@ -310,11 +310,11 @@ bool virIdentityIsEqual(virIdentityPtr identA,
|
||||
}
|
||||
|
||||
|
||||
int virIdentityGetUNIXUserName(virIdentityPtr ident,
|
||||
const char **username)
|
||||
int virIdentityGetUserName(virIdentityPtr ident,
|
||||
const char **username)
|
||||
{
|
||||
return virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
username);
|
||||
}
|
||||
|
||||
@ -342,11 +342,11 @@ int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int virIdentityGetUNIXGroupName(virIdentityPtr ident,
|
||||
const char **groupname)
|
||||
int virIdentityGetGroupName(virIdentityPtr ident,
|
||||
const char **groupname)
|
||||
{
|
||||
return virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
groupname);
|
||||
}
|
||||
|
||||
@ -375,15 +375,15 @@ int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
||||
}
|
||||
|
||||
|
||||
int virIdentityGetUNIXProcessID(virIdentityPtr ident,
|
||||
pid_t *pid)
|
||||
int virIdentityGetProcessID(virIdentityPtr ident,
|
||||
pid_t *pid)
|
||||
{
|
||||
unsigned long long val;
|
||||
const char *processid;
|
||||
|
||||
*pid = 0;
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
|
||||
VIR_IDENTITY_ATTR_PROCESS_ID,
|
||||
&processid) < 0)
|
||||
return -1;
|
||||
|
||||
@ -399,12 +399,12 @@ int virIdentityGetUNIXProcessID(virIdentityPtr ident,
|
||||
}
|
||||
|
||||
|
||||
int virIdentityGetUNIXProcessTime(virIdentityPtr ident,
|
||||
unsigned long long *timestamp)
|
||||
int virIdentityGetProcessTime(virIdentityPtr ident,
|
||||
unsigned long long *timestamp)
|
||||
{
|
||||
const char *processtime;
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
|
||||
VIR_IDENTITY_ATTR_PROCESS_TIME,
|
||||
&processtime) < 0)
|
||||
return -1;
|
||||
|
||||
@ -445,11 +445,11 @@ int virIdentityGetSELinuxContext(virIdentityPtr ident,
|
||||
}
|
||||
|
||||
|
||||
int virIdentitySetUNIXUserName(virIdentityPtr ident,
|
||||
const char *username)
|
||||
int virIdentitySetUserName(virIdentityPtr ident,
|
||||
const char *username)
|
||||
{
|
||||
return virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
username);
|
||||
}
|
||||
|
||||
@ -468,11 +468,11 @@ int virIdentitySetUNIXUserID(virIdentityPtr ident,
|
||||
}
|
||||
|
||||
|
||||
int virIdentitySetUNIXGroupName(virIdentityPtr ident,
|
||||
const char *groupname)
|
||||
int virIdentitySetGroupName(virIdentityPtr ident,
|
||||
const char *groupname)
|
||||
{
|
||||
return virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
groupname);
|
||||
}
|
||||
|
||||
@ -491,8 +491,8 @@ int virIdentitySetUNIXGroupID(virIdentityPtr ident,
|
||||
}
|
||||
|
||||
|
||||
int virIdentitySetUNIXProcessID(virIdentityPtr ident,
|
||||
pid_t pid)
|
||||
int virIdentitySetProcessID(virIdentityPtr ident,
|
||||
pid_t pid)
|
||||
{
|
||||
VIR_AUTOFREE(char *) val = NULL;
|
||||
|
||||
@ -500,13 +500,13 @@ int virIdentitySetUNIXProcessID(virIdentityPtr ident,
|
||||
return -1;
|
||||
|
||||
return virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
|
||||
VIR_IDENTITY_ATTR_PROCESS_ID,
|
||||
val);
|
||||
}
|
||||
|
||||
|
||||
int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
|
||||
unsigned long long timestamp)
|
||||
int virIdentitySetProcessTime(virIdentityPtr ident,
|
||||
unsigned long long timestamp)
|
||||
{
|
||||
VIR_AUTOFREE(char *) val = NULL;
|
||||
|
||||
@ -514,7 +514,7 @@ int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
|
||||
return -1;
|
||||
|
||||
return virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
|
||||
VIR_IDENTITY_ATTR_PROCESS_TIME,
|
||||
val);
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,12 @@ typedef struct _virIdentity virIdentity;
|
||||
typedef virIdentity *virIdentityPtr;
|
||||
|
||||
typedef enum {
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_ID,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
|
||||
VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
|
||||
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,
|
||||
@ -64,18 +64,18 @@ bool virIdentityIsEqual(virIdentityPtr identA,
|
||||
ATTRIBUTE_NONNULL(1)
|
||||
ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int virIdentityGetUNIXUserName(virIdentityPtr ident,
|
||||
const char **username);
|
||||
int virIdentityGetUserName(virIdentityPtr ident,
|
||||
const char **username);
|
||||
int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
||||
uid_t *uid);
|
||||
int virIdentityGetUNIXGroupName(virIdentityPtr ident,
|
||||
const char **groupname);
|
||||
int virIdentityGetGroupName(virIdentityPtr ident,
|
||||
const char **groupname);
|
||||
int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
||||
gid_t *gid);
|
||||
int virIdentityGetUNIXProcessID(virIdentityPtr ident,
|
||||
pid_t *pid);
|
||||
int virIdentityGetUNIXProcessTime(virIdentityPtr ident,
|
||||
unsigned long long *timestamp);
|
||||
int virIdentityGetProcessID(virIdentityPtr ident,
|
||||
pid_t *pid);
|
||||
int virIdentityGetProcessTime(virIdentityPtr ident,
|
||||
unsigned long long *timestamp);
|
||||
int virIdentityGetSASLUserName(virIdentityPtr ident,
|
||||
const char **username);
|
||||
int virIdentityGetX509DName(virIdentityPtr ident,
|
||||
@ -84,18 +84,18 @@ int virIdentityGetSELinuxContext(virIdentityPtr ident,
|
||||
const char **context);
|
||||
|
||||
|
||||
int virIdentitySetUNIXUserName(virIdentityPtr ident,
|
||||
const char *username);
|
||||
int virIdentitySetUserName(virIdentityPtr ident,
|
||||
const char *username);
|
||||
int virIdentitySetUNIXUserID(virIdentityPtr ident,
|
||||
uid_t uid);
|
||||
int virIdentitySetUNIXGroupName(virIdentityPtr ident,
|
||||
const char *groupname);
|
||||
int virIdentitySetGroupName(virIdentityPtr ident,
|
||||
const char *groupname);
|
||||
int virIdentitySetUNIXGroupID(virIdentityPtr ident,
|
||||
gid_t gid);
|
||||
int virIdentitySetUNIXProcessID(virIdentityPtr ident,
|
||||
pid_t pid);
|
||||
int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
|
||||
unsigned long long timestamp);
|
||||
int virIdentitySetProcessID(virIdentityPtr ident,
|
||||
pid_t pid);
|
||||
int virIdentitySetProcessTime(virIdentityPtr ident,
|
||||
unsigned long long timestamp);
|
||||
int virIdentitySetSASLUserName(virIdentityPtr ident,
|
||||
const char *username);
|
||||
int virIdentitySetX509DName(virIdentityPtr ident,
|
||||
|
@ -46,12 +46,12 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
|
||||
goto cleanup;
|
||||
|
||||
if (virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
"fred") < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
&val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -61,7 +61,7 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
&val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -71,14 +71,14 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentitySetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
"joe") != -1) {
|
||||
VIR_DEBUG("Unexpectedly overwrote attribute");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
&val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -111,7 +111,7 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentitySetAttr(identa,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
"fred") < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -121,7 +121,7 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentitySetAttr(identb,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
"fred") < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -131,11 +131,11 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentitySetAttr(identa,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
"flintstone") < 0)
|
||||
goto cleanup;
|
||||
if (virIdentitySetAttr(identb,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
"flintstone") < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
@ -86,7 +86,7 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_USER_NAME,
|
||||
VIR_IDENTITY_ATTR_USER_NAME,
|
||||
&gotUsername) < 0) {
|
||||
fprintf(stderr, "Missing username in identity\n");
|
||||
goto cleanup;
|
||||
@ -110,7 +110,7 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
if (virIdentityGetAttr(ident,
|
||||
VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
|
||||
VIR_IDENTITY_ATTR_GROUP_NAME,
|
||||
&gotGroupname) < 0) {
|
||||
fprintf(stderr, "Missing groupname in identity\n");
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user