On platforms with no way to get peer UID, use getuid(), also fix some failure

checks.
This commit is contained in:
Nicholas Marriott 2022-04-06 16:47:59 +01:00
parent 3a6d82b7c8
commit 8bcd392ee7
3 changed files with 8 additions and 5 deletions

View File

@ -569,7 +569,7 @@ cmdq_add_message(struct cmdq_item *item)
tmp = cmd_print(item->cmd);
if (c != NULL) {
uid = proc_get_peer_uid(c->peer);
if (uid != getuid()) {
if (uid != (uid_t)-1 && uid != getuid()) {
if ((pw = getpwuid(uid)) != NULL)
xasprintf(&user, "[%s]", pw->pw_name);
else

View File

@ -53,7 +53,6 @@ getpeereid(int s, uid_t *uid, gid_t *gid)
return (0);
}
#else
errno = EOPNOTSUPP;
return (-1);
return (getuid());
#endif
}

View File

@ -151,7 +151,7 @@ server_acl_user_deny_write(uid_t uid)
TAILQ_FOREACH(c, &clients, entry) {
uid = proc_get_peer_uid(c->peer);
if (uid == user->uid && uid == user->uid)
if (uid != (uid_t)-1 && uid == user->uid)
c->flags |= CLIENT_READONLY;
}
}
@ -164,7 +164,11 @@ int
server_acl_join(struct client *c)
{
struct server_acl_user *user;
uid_t uid = proc_get_peer_uid(c->peer);
uid_t uid;
uid = proc_get_peer_uid(c->peer);
if (uid == (uid_t)-1)
return (0);
user = server_acl_user_find(uid);
if (user == NULL)