Adding signature checking
[platform/core/system/tizen-platform-wrapper.git] / src / context.c
1 /*
2  * Copyright (C) 2013-2014 Intel Corporation.
3  * 
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors:
19  *   José Bollo <jose.bollo@open.eurogiciel.org>
20  *   Stéphane Desneux <stephane.desneux@open.eurogiciel.org>
21  *   Jean-Benoit Martin <jean-benoit.martin@open.eurogiciel.org>
22  *
23  */
24
25
26
27 #define _GNU_SOURCE
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <unistd.h>
34
35 #ifndef NOT_MULTI_THREAD_SAFE
36 #include <pthread.h>
37 #endif
38
39 #include "tzplatform_variables.h"
40 #include "heap.h"
41 #include "foreign.h"
42 #include "context.h"
43
44
45 inline uid_t get_uid(struct tzplatform_context *context)
46 {
47     uid_t result;
48
49     result = context->user;
50     if (result == _USER_NOT_SET_)
51         result = getuid();
52
53     return result;
54 }
55
56 #if _FOREIGN_HAS_(EUID)
57 inline uid_t get_euid(struct tzplatform_context *context)
58 {
59     uid_t result;
60
61     result = context->user;
62     if (result == _USER_NOT_SET_)
63         result = geteuid();
64
65     return result;
66 }
67 #endif
68
69 #if _FOREIGN_HAS_(GID)
70 inline gid_t get_gid(struct tzplatform_context *context)
71 {
72     return getgid();
73 }
74 #endif
75