Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
afb486da
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
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看板
提交
afb486da
编写于
6月 14, 2023
作者:
C
chengjinsong2
提交者:
cheng_jinsong
6月 16, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
根据配置修改实际设备的权限
Signed-off-by:
N
chengjinsong2
<
chengjinsong2@huawei.com
>
上级
5434b02f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
20 deletion
+30
-20
ueventd/include/ueventd_read_cfg.h
ueventd/include/ueventd_read_cfg.h
+1
-1
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+24
-15
ueventd/ueventd_read_cfg.c
ueventd/ueventd_read_cfg.c
+5
-4
未找到文件。
ueventd/include/ueventd_read_cfg.h
浏览文件 @
afb486da
...
...
@@ -53,7 +53,7 @@ struct FirmwareUdevConf {
extern
"C"
{
#endif
void
ParseUeventdConfigFile
(
const
char
*
file
);
void
GetDeviceNodePermissions
(
const
char
*
devNode
,
uid_t
*
uid
,
gid_t
*
gid
,
mode_t
*
mode
);
int
GetDeviceNodePermissions
(
const
char
*
devNode
,
uid_t
*
uid
,
gid_t
*
gid
,
mode_t
*
mode
);
void
ChangeSysAttributePermissions
(
const
char
*
sysPath
);
int
ParseUeventConfig
(
char
*
buffer
);
struct
DeviceUdevConf
*
GetDeviceUdevConfByDevNode
(
const
char
*
devNode
);
...
...
ueventd/ueventd_device_handler.c
浏览文件 @
afb486da
...
...
@@ -37,16 +37,39 @@
#include <policycoreutils.h>
#endif
static
inline
void
AdjustDeviceNodePermissions
(
const
char
*
deviceNode
,
uid_t
uid
,
gid_t
gid
,
mode_t
mode
)
{
if
(
INVALIDSTRING
(
deviceNode
))
{
return
;
}
if
(
chown
(
deviceNode
,
uid
,
gid
)
!=
0
)
{
INIT_LOGW
(
"Failed to change
\"
%s
\"
owner, errno %d"
,
deviceNode
,
errno
);
}
if
(
chmod
(
deviceNode
,
mode
)
!=
0
)
{
INIT_LOGW
(
"Failed to change
\"
%s
\"
mode, errno %d"
,
deviceNode
,
errno
);
}
}
static
void
CreateSymbolLinks
(
const
char
*
deviceNode
,
char
**
symLinks
)
{
if
(
INVALIDSTRING
(
deviceNode
)
||
symLinks
==
NULL
)
{
return
;
}
uid_t
uid
=
0
;
gid_t
gid
=
0
;
mode_t
mode
=
DEVMODE
;
for
(
int
i
=
0
;
symLinks
[
i
]
!=
NULL
;
i
++
)
{
const
char
*
linkName
=
symLinks
[
i
];
char
linkBuf
[
DEVICE_FILE_SIZE
]
=
{};
if
(
strstr
(
linkName
,
"/dev/block/by-name"
)
!=
NULL
)
{
int
res
=
GetDeviceNodePermissions
(
linkName
,
&
uid
,
&
gid
,
&
mode
);
INIT_CHECK
(
res
!=
0
,
AdjustDeviceNodePermissions
(
deviceNode
,
uid
,
gid
,
mode
));
}
if
(
strncpy_s
(
linkBuf
,
DEVICE_FILE_SIZE
-
1
,
linkName
,
strlen
(
linkName
))
!=
EOK
)
{
INIT_LOGE
(
"Failed to copy link name"
);
return
;
...
...
@@ -67,20 +90,6 @@ static void CreateSymbolLinks(const char *deviceNode, char **symLinks)
}
}
static
inline
void
AdjustDeviceNodePermissions
(
const
char
*
deviceNode
,
uid_t
uid
,
gid_t
gid
,
mode_t
mode
)
{
if
(
INVALIDSTRING
(
deviceNode
))
{
return
;
}
if
(
chown
(
deviceNode
,
uid
,
gid
)
!=
0
)
{
INIT_LOGW
(
"Failed to change
\"
%s
\"
owner, errno %d"
,
deviceNode
,
errno
);
}
if
(
chmod
(
deviceNode
,
mode
)
!=
0
)
{
INIT_LOGW
(
"Failed to change
\"
%s
\"
mode, errno %d"
,
deviceNode
,
errno
);
}
}
#if defined(WITH_SELINUX) && !defined(__RAMDISK__)
static
void
SetDeviceLable
(
const
char
*
path
)
{
...
...
@@ -151,7 +160,7 @@ static int CreateDeviceNode(const struct Uevent *uevent, const char *deviceNode,
return
rc
;
}
GetDeviceNodePermissions
(
deviceNode
,
&
uid
,
&
gid
,
&
mode
);
(
void
)
GetDeviceNodePermissions
(
deviceNode
,
&
uid
,
&
gid
,
&
mode
);
mode
|=
isBlock
?
S_IFBLK
:
S_IFCHR
;
dev_t
dev
=
makedev
(
major
,
minor
);
setegid
(
0
);
...
...
ueventd/ueventd_read_cfg.c
浏览文件 @
afb486da
...
...
@@ -337,13 +337,14 @@ struct DeviceUdevConf *GetDeviceUdevConfByDevNode(const char *devNode)
}
}
}
return
NULL
;
}
void
GetDeviceNodePermissions
(
const
char
*
devNode
,
uid_t
*
uid
,
gid_t
*
gid
,
mode_t
*
mode
)
int
GetDeviceNodePermissions
(
const
char
*
devNode
,
uid_t
*
uid
,
gid_t
*
gid
,
mode_t
*
mode
)
{
if
(
INVALIDSTRING
(
devNode
))
{
return
;
return
-
1
;
}
struct
ListNode
*
node
=
NULL
;
...
...
@@ -354,11 +355,11 @@ void GetDeviceNodePermissions(const char *devNode, uid_t *uid, gid_t *gid, mode_
*
uid
=
config
->
uid
;
*
gid
=
config
->
gid
;
*
mode
=
config
->
mode
;
break
;
return
0
;
}
}
}
return
;
return
-
1
;
}
void
ChangeSysAttributePermissions
(
const
char
*
sysPath
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录