libnm: use nm_getpwuid() in _permissions_user_allowed()

No need to clone the string again. Use nm_getpwuid() directly and avoid
an additional clone.
This commit is contained in:
Thomas Haller 2023-10-23 13:19:26 +02:00
parent 5a7d1ec208
commit a7de74018e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -358,7 +358,7 @@ invalid:
static gboolean
_permissions_user_allowed(NMSettingConnection *setting, const char *uname, gulong uid)
{
gs_free char *uname_free = NULL;
gs_free struct passwd *pw = NULL;
NMSettingConnectionPrivate *priv;
guint i;
@ -379,11 +379,12 @@ _permissions_user_allowed(NMSettingConnection *setting, const char *uname, gulon
continue;
if (!uname) {
if (uid != G_MAXULONG)
uname_free = nm_utils_uid_to_name(uid);
if (!uname_free)
if (uid != G_MAXULONG) {
pw = nm_getpwuid(uid);
uname = nm_passwd_name(pw);
}
if (!uname)
return FALSE;
uname = uname_free;
}
if (nm_streq(permission->item, uname))