From 76c4f8396524f83538317b785b66ca1e591f18c3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 15 Dec 2010 23:12:38 +0000 Subject: [PATCH] * priv.c -> priv.cpp * Defined curthread to NULL. Using Haiku's struct thread is not acceptable without proper locking and the only purpose ATM is to pass it to priv_check() which ignores it anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39858 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/Jamfile | 2 +- src/libs/compat/freebsd_network/compat/sys/pcpu.h | 12 ++++++++++-- src/libs/compat/freebsd_network/compat/sys/priv.h | 8 ++++++++ src/libs/compat/freebsd_network/{priv.c => priv.cpp} | 6 +++++- 4 files changed, 24 insertions(+), 4 deletions(-) rename src/libs/compat/freebsd_network/{priv.c => priv.cpp} (64%) diff --git a/src/libs/compat/freebsd_network/Jamfile b/src/libs/compat/freebsd_network/Jamfile index 1dddf1817e..509a582b67 100644 --- a/src/libs/compat/freebsd_network/Jamfile +++ b/src/libs/compat/freebsd_network/Jamfile @@ -37,7 +37,7 @@ KernelStaticLibrary libfreebsd_network.a : mbuf.c mii.c mutex.c - priv.c + priv.cpp synch.c taskqueue.c unit.c diff --git a/src/libs/compat/freebsd_network/compat/sys/pcpu.h b/src/libs/compat/freebsd_network/compat/sys/pcpu.h index aacd760aba..858d57b7f8 100644 --- a/src/libs/compat/freebsd_network/compat/sys/pcpu.h +++ b/src/libs/compat/freebsd_network/compat/sys/pcpu.h @@ -6,9 +6,17 @@ #define _FBSD_COMPAT_SYS_PCPU_H_ -#include +#include -#define curthread (thread_get_current_thread()) +struct thread; + +#define curthread ((struct thread*)NULL) + /* NOTE: Dereferencing curthread will crash, which is intentional. There is + no FreeBSD compatible struct thread and Haiku's should not be used as it + is only valid for the current thread or with proper locking. Currently + only priv_check() expects a struct thread parameter and ignores it. Using + NULL will show us when other uses appear. */ + #endif /* _FBSD_COMPAT_SYS_PCPU_H_ */ diff --git a/src/libs/compat/freebsd_network/compat/sys/priv.h b/src/libs/compat/freebsd_network/compat/sys/priv.h index 8b78ce4460..4ba76e34c6 100644 --- a/src/libs/compat/freebsd_network/compat/sys/priv.h +++ b/src/libs/compat/freebsd_network/compat/sys/priv.h @@ -6,6 +6,9 @@ #define _FBSD_COMPAT_SYS_PRIV_H_ +#include + + /* * 802.11-related privileges. */ @@ -25,6 +28,11 @@ struct thread; +__BEGIN_DECLS + int priv_check(struct thread*, int); +__END_DECLS + + #endif /* _FBSD_COMPAT_SYS_PRIV_H_ */ diff --git a/src/libs/compat/freebsd_network/priv.c b/src/libs/compat/freebsd_network/priv.cpp similarity index 64% rename from src/libs/compat/freebsd_network/priv.c rename to src/libs/compat/freebsd_network/priv.cpp index 6a1351e09c..61525ba7e7 100644 --- a/src/libs/compat/freebsd_network/priv.c +++ b/src/libs/compat/freebsd_network/priv.cpp @@ -14,8 +14,12 @@ * FreeBSD has a more sophisticated privilege checking system. * We only check for superuser rights. */ -int priv_check(struct thread *thread, int privilegeLevel) +int +priv_check(struct thread *thread, int privilegeLevel) { + // Note: The thread parameter is ignored intentionally (cf. the comment in + // pcpu.h). Currently calling this function is only valid for the current + // thread. if (thread_get_current_thread()->team->effective_uid == 0) return ENOERR;