util: define initializer for 'struct ucred' that properly invalidates all fields

i.e. let's make sure to invalid uid/gid to UID_INVAID + GID_INVALID
instead of zero.
This commit is contained in:
Lennart Poettering
2021-10-11 15:37:37 +02:00
parent 599be274c1
commit a995ce4768
6 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -551,7 +551,7 @@ int getpeername_pretty(int fd, bool include_port, char **ret) {
return -errno;
if (sa.sa.sa_family == AF_UNIX) {
struct ucred ucred = {};
struct ucred ucred = UCRED_INVALID;
/* UNIX connection sockets are anonymous, so let's use
* PID/UID as pretty credentials instead */
+3
View File
@@ -327,3 +327,6 @@ static inline int socket_set_recvfragsize(int fd, int af, bool b) {
}
int socket_get_mtu(int fd, int af, size_t *ret);
/* an initializer for struct ucred that initialized all fields to the invalid value appropriate for each */
#define UCRED_INVALID { .pid = 0, .uid = UID_INVALID, .gid = GID_INVALID }