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