* 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
This commit is contained in:
Ingo Weinhold
2010-12-15 23:12:38 +00:00
parent a68810a9a4
commit 76c4f83965
4 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ KernelStaticLibrary libfreebsd_network.a :
mbuf.c
mii.c
mutex.c
priv.c
priv.cpp
synch.c
taskqueue.c
unit.c
@@ -6,9 +6,17 @@
#define _FBSD_COMPAT_SYS_PCPU_H_
#include <thread.h>
#include <OS.h>
#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_ */
@@ -6,6 +6,9 @@
#define _FBSD_COMPAT_SYS_PRIV_H_
#include <sys/cdefs.h>
/*
* 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_ */
@@ -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;