Module Name: src
Committed By: christos
Date: Tue Feb 11 17:45:01 UTC 2025
Modified Files:
src/external/bsd/blocklist/lib: bl.c
Log Message:
- Illumos port
- sys/cdefs.h portability
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/blocklist/lib/bl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/blocklist/lib/bl.c
diff -u src/external/bsd/blocklist/lib/bl.c:1.3 src/external/bsd/blocklist/lib/bl.c:1.4
--- src/external/bsd/blocklist/lib/bl.c:1.3 Fri Aug 2 13:11:55 2024
+++ src/external/bsd/blocklist/lib/bl.c Tue Feb 11 12:45:01 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: bl.c,v 1.3 2024/08/02 17:11:55 christos Exp $ */
+/* $NetBSD: bl.c,v 1.4 2025/02/11 17:45:01 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bl.c,v 1.3 2024/08/02 17:11:55 christos Exp $");
+#endif
+__RCSID("$NetBSD: bl.c,v 1.4 2025/02/11 17:45:01 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -57,21 +59,12 @@ __RCSID("$NetBSD: bl.c,v 1.3 2024/08/02
#include <pthread.h>
#endif
-#include "bl.h"
-
-#ifndef SYSLOG_DATA_INIT
-struct syslog_data {
- int dummy;
-};
-#define SYSLOG_DATA_INIT { 0 }
-
-static void
-vsyslog_r(int priority, struct syslog_data *sd, const char *fmt, va_list ap)
-{
- vsyslog(priority, fmt, ap);
-}
+#if defined(SO_RECVUCRED)
+#include <ucred.h>
#endif
+#include "bl.h"
+
typedef struct {
uint32_t bl_len;
uint32_t bl_version;
@@ -245,8 +238,8 @@ bl_init(bl_t b, bool srv)
#if defined(LOCAL_CREDS)
#define CRED_LEVEL 0
#define CRED_NAME LOCAL_CREDS
-#define CRED_SC_UID sc_euid
-#define CRED_SC_GID sc_egid
+#define CRED_SC_UID(x) (x)->sc_euid
+#define CRED_SC_GID(x) (x)->sc_egid
#define CRED_MESSAGE SCM_CREDS
#define CRED_SIZE SOCKCREDSIZE(NGROUPS_MAX)
#define CRED_TYPE struct sockcred
@@ -254,12 +247,21 @@ bl_init(bl_t b, bool srv)
#elif defined(SO_PASSCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_PASSCRED
-#define CRED_SC_UID uid
-#define CRED_SC_GID gid
+#define CRED_SC_UID(x) (x)->uid
+#define CRED_SC_GID(x) (x)->gid
#define CRED_MESSAGE SCM_CREDENTIALS
#define CRED_SIZE sizeof(struct ucred)
#define CRED_TYPE struct ucred
#define GOT_CRED 2
+#elif defined(SO_RECVUCRED)
+#define CRED_LEVEL SOL_SOCKET
+#define CRED_NAME SO_RECVUCRED
+#define CRED_SC_UID(x) ucred_geteuid(x)
+#define CRED_SC_GID(x) ucred_getegid(x)
+#define CRED_MESSAGE SCM_UCRED
+#define CRED_SIZE ucred_size()
+#define CRED_TYPE ucred_t
+#define GOT_CRED 2
#else
#define GOT_CRED 0
/*
@@ -436,10 +438,11 @@ bl_recv(bl_t b)
union {
char ctrl[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(CRED_SIZE)];
uint32_t fd;
- CRED_TYPE sc;
} ua;
struct cmsghdr *cmsg;
+#if GOT_CRED != 0
CRED_TYPE *sc;
+#endif
union {
bl_message_t bl;
char buf[512];
@@ -493,8 +496,8 @@ bl_recv(bl_t b)
#ifdef CRED_MESSAGE
case CRED_MESSAGE:
sc = (void *)CMSG_DATA(cmsg);
- bi->bi_uid = sc->CRED_SC_UID;
- bi->bi_gid = sc->CRED_SC_GID;
+ bi->bi_uid = CRED_SC_UID(sc);
+ bi->bi_gid = CRED_SC_GID(sc);
got |= GOT_CRED;
break;
#endif