From 9df1a722568148400d21163bc8bfe52cc823cc74 Mon Sep 17 00:00:00 2001 From: vitaly Date: Mon, 15 Sep 2008 18:30:27 +0000 Subject: [PATCH] Branch b1_8_gate b=15949 i=adilger i=shadow --- lnet/include/libcfs/winnt/winnt-prim.h | 5 ---- lnet/libcfs/winnt/winnt-curproc.c | 47 +++++++++++++++++++++++++++++----- lnet/libcfs/winnt/winnt-module.c | 4 +-- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/lnet/include/libcfs/winnt/winnt-prim.h b/lnet/include/libcfs/winnt/winnt-prim.h index 83795a9..4163306 100644 --- a/lnet/include/libcfs/winnt/winnt-prim.h +++ b/lnet/include/libcfs/winnt/winnt-prim.h @@ -709,11 +709,6 @@ libcfs_arch_cleanup(void); #define lock_kernel() do {} while(0) #define unlock_kernel() do {} while(0) -#define CAP_SYS_ADMIN 0 -#define CAP_SYS_ROOT 1 - -#define capable(a) (TRUE) - #define USERMODEHELPER(path, argv, envp) (0) diff --git a/lnet/libcfs/winnt/winnt-curproc.c b/lnet/libcfs/winnt/winnt-curproc.c index 55bfc20..40c5f5f 100644 --- a/lnet/libcfs/winnt/winnt-curproc.c +++ b/lnet/libcfs/winnt/winnt-curproc.c @@ -107,16 +107,45 @@ char *cfs_curproc_comm(void) return this_task.comm; } -cfs_kernel_cap_t cfs_curproc_cap_get(void) +void cfs_cap_raise(cfs_cap_t cap) { - return this_task.cap_effective; + this_task.cap_effective |= (1 << cap); } -void cfs_curproc_cap_set(cfs_kernel_cap_t cap) +void cfs_cap_lower(cfs_cap_t cap) { - this_task.cap_effective = cap; + this_task.cap_effective &= ~(1 << cap); } +int cfs_cap_raised(cfs_cap_t cap) +{ + return this_task.cap_effective & (1 << cap); +} + +void cfs_kernel_cap_pack(cfs_kernel_cap_t kcap, cfs_cap_t *cap) +{ + *cap = kcap; +} + +void cfs_kernel_cap_unpack(cfs_kernel_cap_t *kcap, cfs_cap_t cap) +{ + *kcap = cap; +} + +cfs_cap_t cfs_curproc_cap_pack(void) { + cfs_cap_t cap; + cfs_kernel_cap_pack(this_task.cap_effective, &cap); + return cap; +} + +void cfs_curproc_cap_unpack(cfs_cap_t cap) { + cfs_kernel_cap_unpack(&this_task.cap_effective, cap); +} + +int cfs_capable(cfs_cap_t cap) +{ + return TRUE; +} /* * Implementation of linux task management routines @@ -469,5 +498,11 @@ EXPORT_SYMBOL(cfs_curproc_comm); EXPORT_SYMBOL(cfs_curproc_groups_nr); EXPORT_SYMBOL(cfs_curproc_groups_dump); EXPORT_SYMBOL(cfs_curproc_is_in_groups); -EXPORT_SYMBOL(cfs_curproc_cap_get); -EXPORT_SYMBOL(cfs_curproc_cap_set); +EXPORT_SYMBOL(cfs_cap_raise); +EXPORT_SYMBOL(cfs_cap_lower); +EXPORT_SYMBOL(cfs_cap_raised); +EXPORT_SYMBOL(cfs_kernel_cap_pack); +EXPORT_SYMBOL(cfs_kernel_cap_unpack); +EXPORT_SYMBOL(cfs_curproc_cap_pack); +EXPORT_SYMBOL(cfs_curproc_cap_unpack); +EXPORT_SYMBOL(cfs_capable); diff --git a/lnet/libcfs/winnt/winnt-module.c b/lnet/libcfs/winnt/winnt-module.c index 87e4c26..5dd151a 100644 --- a/lnet/libcfs/winnt/winnt-module.c +++ b/lnet/libcfs/winnt/winnt-module.c @@ -138,7 +138,7 @@ libcfs_ioctl(cfs_file_t * file, unsigned int cmd, ulong_ptr arg) /* Handle platform-dependent IOC requests */ switch (cmd) { case IOC_LIBCFS_PANIC: - if (!capable (CAP_SYS_BOOT)) + if (!cfs_capable(CFS_CAP_SYS_BOOT)) return (-EPERM); CERROR(("debugctl-invoked panic")); KeBugCheckEx('LUFS', (ULONG_PTR)libcfs_ioctl, (ULONG_PTR)NULL, (ULONG_PTR)NULL, (ULONG_PTR)NULL); @@ -146,7 +146,7 @@ libcfs_ioctl(cfs_file_t * file, unsigned int cmd, ulong_ptr arg) return (0); case IOC_LIBCFS_MEMHOG: - if (!capable (CAP_SYS_ADMIN)) + if (!cfs_capable(CFS_CAP_SYS_ADMIN)) return -EPERM; break; } -- 1.8.3.1