mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
fs/vfs: inherit ownership in pseudofile_create
Initialize i_owner and i_group from the creating task's effective uid/gid when a pseudo-file is created via O_CREAT. This aligns pseudo-file ownership with the creator's effective credentials instead of leaving new files root-owned by default. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
This commit is contained in:
parent
d7f168061b
commit
ce01327a45
1 changed files with 16 additions and 0 deletions
|
|
@ -468,6 +468,10 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
|||
mode_t mode)
|
||||
{
|
||||
FAR struct fs_pseudofile_s *pf;
|
||||
#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \
|
||||
defined(CONFIG_SCHED_USER_IDENTITY)
|
||||
FAR struct tcb_s *rtcb;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
if (node == NULL || path == NULL)
|
||||
|
|
@ -493,6 +497,18 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
|||
(*node)->i_flags = 1;
|
||||
(*node)->u.i_ops = &g_pseudofile_ops;
|
||||
(*node)->i_private = pf;
|
||||
|
||||
#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \
|
||||
defined(CONFIG_SCHED_USER_IDENTITY)
|
||||
|
||||
rtcb = nxsched_self();
|
||||
if (rtcb != NULL && rtcb->group != NULL)
|
||||
{
|
||||
(*node)->i_owner = rtcb->group->tg_euid;
|
||||
(*node)->i_group = rtcb->group->tg_egid;
|
||||
}
|
||||
#endif
|
||||
|
||||
atomic_fetch_add(&(*node)->i_crefs, 1);
|
||||
|
||||
inode_unlock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue