mirror of
https://gitee.com/openharmony/security_selinux
synced 2024-11-23 05:19:57 +00:00
fix code problem
Signed-off-by: steven_q <qichanggui@huawei.com> Change-Id: Ib0e6e22fa54b1f3a44bee7b1171b4099f97d4caa
This commit is contained in:
parent
9ce232ead7
commit
73a5be4917
2
BUILD.gn
2
BUILD.gn
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 北京万里红科技有限公司
|
||||
# Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
25
LICENSE
25
LICENSE
@ -175,28 +175,3 @@
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
18
OAT.xml
18
OAT.xml
@ -1,4 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021 北京万里红科技有限公司
|
||||
/* Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +16,20 @@
|
||||
#ifndef __POLICYCOREUTILS_H__
|
||||
#define __POLICYCOREUTILS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int LoadPolicy(void);
|
||||
int Restorecon(const char *path);
|
||||
int RestoreconRecurse(const char *path);
|
||||
#endif // __POLICYCOREUTILS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // __POLICYCOREUTILS_H__
|
||||
|
@ -31,6 +31,7 @@ enum Errno {
|
||||
SELINUX_CONTEXTS_FILE_LOAD_ERROR,
|
||||
SELINUX_FTS_OPEN_ERROR,
|
||||
SELINUX_FTS_ELOOP,
|
||||
SELINUX_RESTORECON_ERROR,
|
||||
SELINUX_UNKNOWN_ERROR,
|
||||
SELINUX_PERMISSION_DENY,
|
||||
SELINUX_ERROR_MAX,
|
||||
|
@ -282,11 +282,16 @@ int HapContext::HapFileRestorecon(std::vector<std::string> &pathNameOrig, const
|
||||
if (apl.empty() || pathNameOrig.empty()) {
|
||||
return -SELINUX_ARG_INVALID;
|
||||
}
|
||||
int res = SELINUX_SUCC;
|
||||
bool failFlag = false;
|
||||
for (auto pathname : pathNameOrig) {
|
||||
res |= HapFileRestorecon(pathname.c_str(), apl, packageName, flags);
|
||||
int res = HapFileRestorecon(pathname.c_str(), apl, packageName, flags);
|
||||
if (res != SELINUX_SUCC) {
|
||||
failFlag = true;
|
||||
SELINUX_LOG_ERROR(LABEL, "HapFileRestorecon fail for path: %{public}s, errorNo: %{public}d",
|
||||
pathname.c_str(), res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return failFlag ? -SELINUX_RESTORECON_ERROR : SELINUX_SUCC;
|
||||
}
|
||||
|
||||
int HapContext::HapFileRestorecon(const std::string &pathNameOrig, const std::string &apl,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021 北京万里红科技有限公司
|
||||
/* Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -13,10 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <selinux/selinux.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <policycoreutils.h>
|
||||
|
||||
int LoadPolicy(void)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ static struct ParameterInfo DecodeString(const std::string &line)
|
||||
return contextBuff;
|
||||
}
|
||||
|
||||
static bool InsertContextsList(ParameterInfo tmpInfo, ParamContextsList **head)
|
||||
static bool InsertContextsList(const ParameterInfo &tmpInfo, ParamContextsList **head)
|
||||
{
|
||||
ParamContextsList *node = (ParamContextsList *)malloc(sizeof(ParamContextsList));
|
||||
if (node == nullptr) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021 北京万里红科技有限公司
|
||||
/* Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
#include <selinux/label.h>
|
||||
#include <selinux/restorecon.h>
|
||||
#include <policycoreutils.h>
|
||||
|
||||
int Restorecon(const char *path)
|
||||
{
|
||||
@ -25,4 +26,3 @@ int RestoreconRecurse(const char *path)
|
||||
{
|
||||
return selinux_restorecon(path, SELINUX_RESTORECON_REALPATH | SELINUX_RESTORECON_RECURSE);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ static const char *g_selinuxErrMsg[SELINUX_ERROR_MAX] = {
|
||||
[SELINUX_CONTEXTS_FILE_LOAD_ERROR] = "load contexts file failed",
|
||||
[SELINUX_FTS_OPEN_ERROR] = "fts_open failed",
|
||||
[SELINUX_FTS_ELOOP] = "fts ELOOP",
|
||||
[SELINUX_RESTORECON_ERROR] = "hap path restorecon error",
|
||||
[SELINUX_UNKNOWN_ERROR] = "unknown error",
|
||||
[SELINUX_PERMISSION_DENY] = "permission denied",
|
||||
};
|
||||
|
@ -68,7 +68,7 @@ int SelinuKLog(int logLevel, const char *fmt, ...)
|
||||
res = snprintf_s(logInfo, MAX_LOG_SIZE, MAX_LOG_SIZE - 1, "[pid=%d][%s][%s] %s", getpid(), "SELINUX",
|
||||
LOG_LEVEL_STR[logLevel], tmpFmt);
|
||||
} else {
|
||||
res = snprintf_s(logInfo, MAX_LOG_SIZE, MAX_LOG_SIZE - 1, tmpFmt);
|
||||
res = snprintf_s(logInfo, MAX_LOG_SIZE, MAX_LOG_SIZE - 1, "%s", tmpFmt);
|
||||
}
|
||||
if (res == -1) {
|
||||
close(g_fd);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021 北京万里红科技有限公司
|
||||
/* Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021 北京万里红科技有限公司
|
||||
/* Copyright (c) 2021-2022 北京万里红科技有限公司
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -2,7 +2,7 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -2,7 +2,7 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) 2021 北京万里红科技有限公司
|
||||
# Copyright (c) 2022 北京万里红科技有限公司
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@ -16,7 +16,7 @@
|
||||
# i.e. /dev/camera_dev
|
||||
attribute dev_type;
|
||||
|
||||
# Type of all processes,including the hap process and native process.
|
||||
# Type of all processes, including the hap process and native process.
|
||||
# i.e. hdbd, media
|
||||
attribute domain;
|
||||
|
||||
@ -44,7 +44,7 @@ attribute system_file_type;
|
||||
# i.e. /vendor/*
|
||||
attribute vendor_file_type;
|
||||
|
||||
# Type of all domain access points,which is used in domain trasition.
|
||||
# Type of all domain access points, which is used in domain trasition.
|
||||
# i.e. vold_exec,
|
||||
# appspawn_exec
|
||||
attribute exec_type;
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -12,4 +12,5 @@
|
||||
# limitations under the License.
|
||||
|
||||
permissive shell;
|
||||
permissive init;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
Loading…
Reference in New Issue
Block a user