[FEATURE] Implement kernel -> user connection
[platform/core/system/swap-manager.git] / daemon / smack.c
1 /*
2  *  DA manager
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim           <jaewon81.lim@samsung.com>
9  * Woojin Jung          <woojin2.jung@samsung.com>
10  * Juyoung Kim          <j0.kim@samsung.com>
11  * Nikita Kalyazin      <n.kalyazin@samsung.com>
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  * - Samsung RnD Institute Russia
28  *
29  */
30
31
32 #include <sys/smack.h>
33 #include <attr/xattr.h>
34 #include "smack.h"
35
36 #define SELF_LABEL_FILE "/proc/self/attr/current"
37 #define SMACK_LABEL_LEN 255
38
39 void fd_setup_attributes(int fd)
40 {
41         fsetxattr(fd, "security.SMACK64IPIN", "*", 1, 0);
42         fsetxattr(fd, "security.SMACK64IPOUT", "*", 1, 0);
43 }
44
45 void set_label_for_all(const char *path)
46 {
47         smack_lsetlabel(path, "*", SMACK_LABEL_ACCESS);
48 }