| 698 | } |
| 699 | |
| 700 | std::string IPCServerPrivate::getNameFromUID(uid_t uid) |
| 701 | { |
| 702 | std::string buffer(1024, 0); |
| 703 | struct passwd pw = { }; |
| 704 | struct passwd* pwptr = nullptr; |
| 705 | |
| 706 | if (getpwuid_r(uid, &pw, &buffer[0], buffer.capacity(), &pwptr) != 0) { |
| 707 | USBGUARD_LOG(Warning) << "Unable to lookup username for uid=" << uid << ": errno=" << errno; |
| 708 | return std::string(); |
| 709 | } |
| 710 | |
| 711 | if (pwptr == nullptr || pw.pw_name == nullptr) { |
| 712 | USBGUARD_LOG(Info) << "No username associated with uid=" << uid; |
| 713 | return std::string(); |
| 714 | } |
| 715 | |
| 716 | return std::string(pw.pw_name); |
| 717 | } |
| 718 | |
| 719 | std::string IPCServerPrivate::getNameFromGID(gid_t gid) |
| 720 | { |
nothing calls this directly
no outgoing calls
no test coverage detected