mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
fs/inode: assign owner and group when reserving pseudo-inodes
Set i_owner and i_group from the caller's effective credentials in inode_reserve(), covering IPC objects, FIFOs, and pseudo-files. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
This commit is contained in:
parent
4c62271654
commit
4bbe61ead5
4 changed files with 17 additions and 22 deletions
|
|
@ -229,6 +229,10 @@ void inode_runlock(void)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: inode_checkperm
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
int inode_checkperm(FAR struct inode *inode, int amode)
|
int inode_checkperm(FAR struct inode *inode, int amode)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_FS_PERMISSION
|
#ifdef CONFIG_FS_PERMISSION
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
|
|
||||||
#include "inode/inode.h"
|
#include "inode/inode.h"
|
||||||
|
|
@ -82,6 +83,9 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode;
|
FAR struct inode *inode;
|
||||||
int namelen;
|
int namelen;
|
||||||
|
#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && defined(CONFIG_SCHED_USER_IDENTITY)
|
||||||
|
FAR struct tcb_s *rtcb;
|
||||||
|
#endif
|
||||||
|
|
||||||
namelen = inode_namelen(name);
|
namelen = inode_namelen(name);
|
||||||
inode = fs_heap_zalloc(FSNODE_SIZE(namelen));
|
inode = fs_heap_zalloc(FSNODE_SIZE(namelen));
|
||||||
|
|
@ -94,6 +98,15 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode)
|
||||||
clock_gettime(CLOCK_REALTIME, &inode->i_atime);
|
clock_gettime(CLOCK_REALTIME, &inode->i_atime);
|
||||||
inode->i_mtime = inode->i_atime;
|
inode->i_mtime = inode->i_atime;
|
||||||
inode->i_ctime = inode->i_atime;
|
inode->i_ctime = inode->i_atime;
|
||||||
|
# if defined(CONFIG_SCHED_USER_IDENTITY)
|
||||||
|
rtcb = nxsched_self();
|
||||||
|
if (rtcb != NULL && rtcb->group != NULL)
|
||||||
|
{
|
||||||
|
inode->i_owner = rtcb->group->tg_euid;
|
||||||
|
inode->i_group = rtcb->group->tg_egid;
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
inode_namecpy(inode->i_name, name);
|
inode_namecpy(inode->i_name, name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -461,12 +461,6 @@ int fs_open_amode(int oflags);
|
||||||
int fs_checkopenperm(uid_t owner, gid_t group, mode_t mode, int oflags);
|
int fs_checkopenperm(uid_t owner, gid_t group, mode_t mode, int oflags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_FS_PERMISSION
|
|
||||||
int fs_checkmode(uid_t owner, gid_t group, mode_t mode, int amode);
|
|
||||||
int fs_open_amode(int oflags);
|
|
||||||
int fs_checkopenperm(uid_t owner, gid_t group, mode_t mode, int oflags);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: foreach_inode
|
* Name: foreach_inode
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
|
@ -468,10 +467,6 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
||||||
mode_t mode)
|
mode_t mode)
|
||||||
{
|
{
|
||||||
FAR struct fs_pseudofile_s *pf;
|
FAR struct fs_pseudofile_s *pf;
|
||||||
#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \
|
|
||||||
defined(CONFIG_SCHED_USER_IDENTITY)
|
|
||||||
FAR struct tcb_s *rtcb;
|
|
||||||
#endif
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (node == NULL || path == NULL)
|
if (node == NULL || path == NULL)
|
||||||
|
|
@ -498,17 +493,6 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path,
|
||||||
(*node)->u.i_ops = &g_pseudofile_ops;
|
(*node)->u.i_ops = &g_pseudofile_ops;
|
||||||
(*node)->i_private = pf;
|
(*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);
|
atomic_fetch_add(&(*node)->i_crefs, 1);
|
||||||
|
|
||||||
inode_unlock();
|
inode_unlock();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue