UbixOS
2.0
access.c
Go to the documentation of this file.
1
/*-
2
* Copyright (c) 2002-2018 The UbixOS Project.
3
* All rights reserved.
4
*
5
* This was developed by Christopher W. Olsen for the UbixOS Project.
6
*
7
* Redistribution and use in source and binary forms, with or without modification, are permitted
8
* provided that the following conditions are met:
9
*
10
* 1) Redistributions of source code must retain the above copyright notice, this list of
11
* conditions, the following disclaimer and the list of authors.
12
* 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13
* conditions, the following disclaimer and the list of authors in the documentation and/or
14
* other materials provided with the distribution.
15
* 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16
* endorse or promote products derived from this software without specific prior written
17
* permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#include <
ubixos/access.h
>
30
31
/************************************************************************
32
33
Function: sys_setUID();
34
35
Description: This will set the UID of the task
36
37
Notes:
38
39
2016/01/17 - This is very basic and will set any UID if you're 0
40
need to change later.
41
42
43
************************************************************************/
44
int
sys_setUID
(
struct
thread
*td,
struct
sys_setUID_args
*args) {
45
if
(
_current
->
uid
== 0x0) {
46
_current
->
uid
= args->
uid
;
47
return
(0);
48
}
49
return
(-1);
50
}
51
52
int
sys_getUID
(
struct
thread
*td,
void
*uap) {
53
return
(
_current
->
uid
);
54
}
55
56
int
sys_getEUID
(
struct
thread
*td,
void
*uap) {
57
return
(
_current
->
uid
);
58
}
59
60
int
sys_getGID
(
struct
thread
*td,
void
*uap) {
61
return
(
_current
->
gid
);
62
}
63
64
int
sys_setGID
(
struct
thread
*td,
struct
sys_setGID_args
*uap) {
65
66
if
(
_current
->
gid
== 0x0) {
67
68
_current
->
gid
= uap->
gid
;
69
70
return
(0);
71
72
}
73
74
return
(-1);
75
}
76
77
int
in_group_p
(
gid_t
grp) {
78
int
i;
79
80
if
(grp ==
_current
->
egid
)
81
return
1;
82
83
for
(i = 0; i <
NR_GROUPS
; i++) {
84
if
(
_current
->
groups
[i] ==
NO_GROUP
)
85
break
;
86
if
(
_current
->
groups
[i] == grp)
87
return
1;
88
}
89
return
0;
90
}
NR_GROUPS
#define NR_GROUPS
Definition:
sched.h:44
NO_GROUP
#define NO_GROUP
Definition:
sched.h:43
gid_t
__gid_t gid_t
Definition:
types.h:123
sys_setUID_args::uid
int uid
Definition:
sysproto_posix.h:144
thread
Definition:
thread.h:40
sys_setUID_args
Definition:
sysproto_posix.h:142
sys_setGID_args
Definition:
sysproto_posix.h:148
sys_getGID
int sys_getGID(struct thread *td, void *uap)
Definition:
access.c:59
sys_setGID
int sys_setGID(struct thread *td, struct sys_setGID_args *uap)
Definition:
access.c:63
sys_getEUID
int sys_getEUID(struct thread *td, void *uap)
Definition:
access.c:55
sys_setGID_args::gid
int gid
Definition:
sysproto_posix.h:150
taskStruct::egid
uint16_t egid
Definition:
sched.h:75
_current
kTask_t * _current
Definition:
sched.c:50
taskStruct::uid
uint32_t uid
Definition:
sched.h:73
taskStruct::groups
uint16_t groups[32]
Definition:
sched.h:85
access.h
sys_getUID
int sys_getUID(struct thread *td, void *uap)
Definition:
access.c:51
sys_setUID
int sys_setUID(struct thread *td, struct sys_setUID_args *args)
Definition:
access.c:43
in_group_p
int in_group_p(gid_t grp)
Definition:
access.c:76
taskStruct::gid
uint32_t gid
Definition:
sched.h:73
kernel
access.c
Generated by
1.8.16