xiaoxiang781216 commented on code in PR #19162:
URL: https://github.com/apache/nuttx/pull/19162#discussion_r3430331684


##########
fs/inode/fs_inode.c:
##########
@@ -244,16 +272,29 @@ int inode_checkperm(FAR struct inode *inode, int oflags)
       return -EACCES;
     }
 
-#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && defined(CONFIG_SCHED_USER_IDENTITY)
+#ifdef CONFIG_FS_PERMISSION
 
   if (INODE_IS_MOUNTPT(inode))
     {
       return OK;
     }
 
+  /* /etc/passwd and /etc/group must be world-readable so that getpwnam()
+   * and getgrnam() work after a non-root setuid().  Encrypted passwords
+   * live in the passwd file; secrecy is provided by hashing, not file
+   * permissions.
+   */
+
+  if ((oflags & O_RDOK) != 0 &&
+      (strcmp(inode->i_name, "passwd") == 0 ||
+       strcmp(inode->i_name, "group") == 0))
+    {
+      return OK;
+    }
+
   return _inode_checkmode(inode, amode);

Review Comment:
   ditto



##########
fs/inode/fs_inode.c:
##########


Review Comment:
   call fs_checkmode



-- 
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]

Reply via email to