fxysunshine commented on code in PR #8924:
URL: https://github.com/apache/nuttx/pull/8924#discussion_r1196662515
##########
fs/binfs/fs_binfs.c:
##########
@@ -470,21 +470,35 @@ static int binfs_stat(struct inode *mountpt,
const char *relpath, struct stat *buf)
{
finfo("Entry\n");
+ int index;
+#ifdef CONFIG_SCHED_USER_IDENTITY
+ int mode;
+#endif
/* The requested directory must be the volume-relative "root" directory */
if (relpath && relpath[0] != '\0')
{
/* Check if there is a file with this name. */
- if (builtin_isavail(relpath) < 0)
+ index = builtin_isavail(relpath);
+ if (index < 0)
{
return -ENOENT;
}
/* It's a execute-only file name */
buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR;
+
+#ifdef CONFIG_SCHED_USER_IDENTITY
+ buf->st_uid = builtin_getuid(index);
+ buf->st_gid = builtin_getgid(index);
+
+ mode = builtin_getmode(index);
+ buf->st_mode |= (mode & S_ISUID) ? S_ISUID : 0;
+ buf->st_mode |= (mode & S_ISGID) ? S_ISGID : 0;
+#endif
Review Comment:
YES, current we only apply to builtin app and binfs. That depends on file
system and builtin load mode.
It seem it is easy to implement in binfs, but need some work to do in ELF
models and others.
For example, hostfs supports UID/GID and S_ISUID/S_ISGID default, we can get
in Nuttx if hostfs is mount.
https://github.com/apache/nuttx/blob/master/arch/sim/src/sim/posix/sim_hostfs.c#L617
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]