Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
3135a696
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3135a696
编写于
3月 22, 2022
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修改属性设置错误
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
9ad8dc2d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
54 deletion
+66
-54
services/begetctl/shell/shell_bas.h
services/begetctl/shell/shell_bas.h
+1
-1
services/etc/param/ohos.para.dac
services/etc/param/ohos.para.dac
+17
-17
services/loopevent/include/loop_event.h
services/loopevent/include/loop_event.h
+1
-1
services/param/adapter/param_dac.c
services/param/adapter/param_dac.c
+36
-34
services/param/manager/param_utils.c
services/param/manager/param_utils.c
+10
-0
services/param/service/param_service.c
services/param/service/param_service.c
+1
-1
未找到文件。
services/begetctl/shell/shell_bas.h
浏览文件 @
3135a696
...
...
@@ -27,7 +27,7 @@
#define BSH_KEY_CTRLC 0x03 // ctr + c
#define BSH_KEY_ESC 0x1B // ecs
#define BSH_COMMAND_MAX_LENGTH
5 * 1024
#define BSH_COMMAND_MAX_LENGTH
(5 * 1024)
#define BSH_PARAMETER_MAX_NUMBER 10
#define BSH_CMD_NAME_END 48
#define BSH_CMD_MAX_KEY 5
...
...
services/etc/param/ohos.para.dac
浏览文件 @
3135a696
...
...
@@ -11,23 +11,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
build_version root:root:0777
hw_sc.build.os.enable root:root:0777
hw_sc.build.os.apiversion root:root:0777
hw_sc.build.os.version root:root:0777
hw_sc.build.os.releasetype root:root:0777
build_version
=
root:root:0777
hw_sc.build.os.enable
=
root:root:0777
hw_sc.build.os.apiversion
=
root:root:0777
hw_sc.build.os.version
=
root:root:0777
hw_sc.build.os.releasetype
=
root:root:0777
const.actionable_compatible_property.enabled root:root:0777
const.postinstall.fstab.prefix root:root:0777
const.secure root:root:0777
security.perf_harden root:root:0777
const.allow.mock.location root:root:0777
const.debuggable root:root:0777
persist.sys.usb.config root:root:0777
const.actionable_compatible_property.enabled
=
root:root:0777
const.postinstall.fstab.prefix
=
root:root:0777
const.secure
=
root:root:0777
security.perf_harden
=
root:root:0777
const.allow.mock.location
=
root:root:0777
const.debuggable
=
root:root:0777
persist.sys.usb.config
=
root:root:0777
# default forbit other user to start service
ohos.servicectrl. system:root:0770
test.permission. root:root:0770
test.permission.read. root:root:0774
test.permission.write. root:root:0772
test.permission.watcher. root:root:0771
\ No newline at end of file
ohos.servicectrl. = system:servicectrl:0775
test.permission. = root:root:0770
test.permission.read. = root:root:0774
test.permission.write. = root:root:0772
test.permission.watcher. = root:root:0771
\ No newline at end of file
services/loopevent/include/loop_event.h
浏览文件 @
3135a696
...
...
@@ -27,7 +27,7 @@ extern "C" {
// 配置
#define LOOP_EVENT_USE_EPOLL 1
#define LOOP_DEFAULT_BUFFER
1024
#define LOOP_DEFAULT_BUFFER
(1024 * 5)
#define LOOP_MAX_BUFFER (1024 * 64)
#define LOOP_MAX_CLIENT 1024
...
...
services/param/adapter/param_dac.c
浏览文件 @
3135a696
...
...
@@ -25,10 +25,9 @@
#define OCT_BASE 8
static
ParamSecurityLabel
g_localSecurityLabel
=
{};
static
void
GetUserIdByName
(
FILE
*
fp
,
uid_t
*
uid
,
const
char
*
name
,
uint32_t
nameLen
)
static
void
GetUserIdByName
(
uid_t
*
uid
,
const
char
*
name
,
uint32_t
nameLen
)
{
*
uid
=
-
1
;
(
void
)
fp
;
struct
passwd
*
data
=
NULL
;
while
((
data
=
getpwent
())
!=
NULL
)
{
if
((
data
->
pw_name
!=
NULL
)
&&
(
strlen
(
data
->
pw_name
)
==
nameLen
)
&&
...
...
@@ -40,10 +39,9 @@ static void GetUserIdByName(FILE *fp, uid_t *uid, const char *name, uint32_t nam
endpwent
();
}
static
void
GetGroupIdByName
(
FILE
*
fp
,
gid_t
*
gid
,
const
char
*
name
,
uint32_t
nameLen
)
static
void
GetGroupIdByName
(
gid_t
*
gid
,
const
char
*
name
,
uint32_t
nameLen
)
{
*
gid
=
-
1
;
(
void
)
fp
;
struct
group
*
data
=
NULL
;
while
((
data
=
getgrent
())
!=
NULL
)
{
if
((
data
->
gr_name
!=
NULL
)
&&
(
strlen
(
data
->
gr_name
)
==
nameLen
)
&&
...
...
@@ -56,7 +54,7 @@ static void GetGroupIdByName(FILE *fp, gid_t *gid, const char *name, uint32_t na
}
// user:group:r|w
static
int
GetParamDacData
(
FILE
*
fpForGroup
,
FILE
*
fpForUser
,
ParamDacData
*
dacData
,
const
char
*
value
)
static
int
GetParamDacData
(
ParamDacData
*
dacData
,
const
char
*
value
)
{
if
(
dacData
==
NULL
)
{
return
-
1
;
...
...
@@ -69,8 +67,8 @@ static int GetParamDacData(FILE *fpForGroup, FILE *fpForUser, ParamDacData *dacD
if
(
mode
==
NULL
)
{
return
-
1
;
}
GetUserIdByName
(
fpForUser
,
&
dacData
->
uid
,
value
,
groupName
-
value
);
GetGroupIdByName
(
fpForGroup
,
&
dacData
->
gid
,
groupName
+
1
,
mode
-
groupName
-
1
);
GetUserIdByName
(
&
dacData
->
uid
,
value
,
groupName
-
value
);
GetGroupIdByName
(
&
dacData
->
gid
,
groupName
+
1
,
mode
-
groupName
-
1
);
dacData
->
mode
=
strtol
(
mode
+
1
,
NULL
,
OCT_BASE
);
return
0
;
}
...
...
@@ -116,45 +114,49 @@ static int DecodeSecurityLabel(ParamSecurityLabel **srcLabel, const char *buffer
return
0
;
}
typedef
struct
{
SecurityLabelFunc
label
;
void
*
context
;
}
LoadContext
;
static
int
LoadOneParam_
(
const
uint32_t
*
context
,
const
char
*
name
,
const
char
*
value
)
{
LoadContext
*
loadContext
=
(
LoadContext
*
)
context
;
ParamAuditData
auditData
=
{
0
};
auditData
.
name
=
name
;
#ifdef STARTUP_INIT_TEST
auditData
.
label
=
value
;
#endif
int
ret
=
GetParamDacData
(
&
auditData
.
dacData
,
value
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to get param info %d %s"
,
ret
,
name
);
ret
=
loadContext
->
label
(
&
auditData
,
loadContext
->
context
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to write param info %d
\"
%s
\"
"
,
ret
,
name
);
return
0
;
}
static
int
LoadParamLabels
(
const
char
*
fileName
,
SecurityLabelFunc
label
,
void
*
context
)
{
LoadContext
loadContext
=
{
label
,
context
};
uint32_t
infoCount
=
0
;
ParamAuditData
auditData
=
{
0
};
FILE
*
fpForGroup
=
fopen
(
GROUP_FILE_PATH
,
"r"
);
FILE
*
fpForUser
=
fopen
(
USER_FILE_PATH
,
"r"
);
FILE
*
fp
=
fopen
(
fileName
,
"r"
);
char
*
buff
=
(
char
*
)
calloc
(
1
,
PARAM_BUFFER_SIZE
);
SubStringInfo
*
info
=
calloc
(
1
,
sizeof
(
SubStringInfo
)
*
(
SUBSTR_INFO_DAC
+
1
));
while
(
fp
!=
NULL
&&
fpForGroup
!=
NULL
&&
fpForUser
!=
NULL
&&
info
!=
NULL
&&
buff
!=
NULL
&&
fgets
(
buff
,
PARAM_BUFFER_SIZE
,
fp
)
!=
NULL
)
{
buff
[
PARAM_BUFFER_SIZE
-
1
]
=
'\0'
;
int
subStrNumber
=
GetSubStringInfo
(
buff
,
strlen
(
buff
),
' '
,
info
,
SUBSTR_INFO_DAC
+
1
);
if
(
subStrNumber
<=
SUBSTR_INFO_DAC
)
{
const
uint32_t
buffSize
=
PARAM_NAME_LEN_MAX
+
PARAM_CONST_VALUE_LEN_MAX
+
10
;
// 10 size
char
*
buff
=
(
char
*
)
calloc
(
1
,
buffSize
);
while
(
fp
!=
NULL
&&
buff
!=
NULL
&&
fgets
(
buff
,
buffSize
,
fp
)
!=
NULL
)
{
buff
[
buffSize
-
1
]
=
'\0'
;
int
ret
=
SpliteString
(
buff
,
NULL
,
0
,
LoadOneParam_
,
(
uint32_t
*
)
&
loadContext
);
if
(
ret
!=
0
)
{
PARAM_LOGE
(
"Failed to splite string %s fileName %s"
,
buff
,
fileName
);
continue
;
}
auditData
.
name
=
info
[
SUBSTR_INFO_NAME
].
value
;
#ifdef STARTUP_INIT_TEST
auditData
.
label
=
info
[
SUBSTR_INFO_NAME
].
value
;
#endif
int
ret
=
GetParamDacData
(
fpForGroup
,
fpForUser
,
&
auditData
.
dacData
,
info
[
SUBSTR_INFO_DAC
].
value
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to get param info %d %s"
,
ret
,
buff
);
ret
=
label
(
&
auditData
,
context
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to write param info %d %s"
,
ret
,
buff
);
infoCount
++
;
}
PARAM_LOGI
(
"Load parameter label total %u success %s"
,
infoCount
,
fileName
);
if
(
fp
!=
NULL
)
{
(
void
)
fclose
(
fp
);
}
if
(
info
!=
NULL
)
{
free
(
info
);
}
if
(
fpForGroup
!=
NULL
)
{
(
void
)
fclose
(
fpForGroup
);
}
if
(
fpForUser
!=
NULL
)
{
(
void
)
fclose
(
fpForUser
);
}
if
(
buff
!=
NULL
)
{
free
(
buff
);
}
...
...
services/param/manager/param_utils.c
浏览文件 @
3135a696
...
...
@@ -131,6 +131,16 @@ int SpliteString(char *line, const char *exclude[], uint32_t count,
value
++
;
}
// Skip spaces
char
*
tmp
=
name
;
while
((
tmp
<
value
)
&&
(
*
tmp
!=
'\0'
))
{
if
(
isspace
(
*
tmp
))
{
(
*
tmp
)
=
'\0'
;
break
;
}
tmp
++
;
}
// empty name, just ignore this line
if
(
*
value
==
'\0'
)
{
return
0
;
...
...
services/param/service/param_service.c
浏览文件 @
3135a696
...
...
@@ -123,7 +123,7 @@ PARAM_STATIC int AddSecurityLabel(const ParamAuditData *auditData, void *context
PARAM_CHECK
(
context
!=
NULL
,
return
-
1
,
"Invalid context"
);
ParamWorkSpace
*
workSpace
=
(
ParamWorkSpace
*
)
context
;
int
ret
=
CheckParamName
(
auditData
->
name
,
1
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Illegal param name
%s
"
,
auditData
->
name
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Illegal param name
\"
%s
\"
"
,
auditData
->
name
);
ParamTrieNode
*
node
=
FindTrieNode
(
&
workSpace
->
paramSpace
,
auditData
->
name
,
strlen
(
auditData
->
name
),
NULL
);
if
(
node
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录