libselinux: selinux_restorecon(): fstat() if skip_multilink set
Stephen Smalley
maintainerPATCH 1/1 libselinux: selinux_restorecon(): fstat() if skip_multilink set
selinux_restorecon() must call fstat() on every entry if skip_multilink is set to fetch the st_nlink value.
Signed-off-by Stephen Smalley <[email protected]>
--- libselinux/src/selinux_restorecon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
libselinux/src/selinux_restorecon.c +4 -2
@@ -1271,13 +1271,15 @@ static int walk_next(struct rest_state *state, int *ent_fd, int *rd_fd,/* * Skip fstat() when d_type already gives the file type and -* neither xdev (st_dev) nor add_assoc (st_ino) is needed. +* none of xdev (st_dev), add_assoc (st_ino), or +* skip_multilink (st_nlink) are needed. * Directories always fstat for cycle detection and walk_push(). */ mode_t mode_from_dtype =d_type_to_mode (de->d_type);bool need_fstat = mode_from_dtype ==0 ||S_ISDIR (mode_from_dtype) || - state->flags.set_xdev || state->flags.add_assoc; + state->flags.set_xdev || state->flags.add_assoc || + state->flags.skip_multilink;if (need_fstat) {if (fstat (fd, ent_sb) <0 ) {
Signature · 1 line
2.54.0
Quoted 4 lines · Stephen Smalley
selinux_restorecon()must callfstat()on every entry ifskip_multilinkis set to fetch thest_nlinkvalue.Signed-off-by Stephen Smalley <[email protected]>
Acked-by Petr Lautrbach <[email protected]>
Quoted 28 lines
--- libselinux/src/selinux_restorecon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)libselinux/src/selinux_restorecon.c +4
-2@@ -1271,13 +1271,15 @@ static int walk_next(struct rest_state *state, int *ent_fd, int *rd_fd,/* * Skip fstat() when d_type already gives the file type and -* neither xdev (st_dev) nor add_assoc (st_ino) is needed. +* none of xdev (st_dev), add_assoc (st_ino), or +* skip_multilink (st_nlink) are needed. * Directories always fstat for cycle detection and walk_push(). */ mode_t mode_from_dtype =d_type_to_mode (de->d_type);bool need_fstat = mode_from_dtype ==0 ||S_ISDIR (mode_from_dtype) || - state->flags.set_xdev || state->flags.add_assoc; + state->flags.set_xdev || state->flags.add_assoc || + state->flags.skip_multilink;if (need_fstat) {if (fstat (fd, ent_sb) <0 ) {Signature · 1 line
2.54.0
Petr Lautrbach
AppliedQuoted 8 lines · Petr Lautrbach
Quoted 4 lines · Stephen Smalley
selinux_restorecon()must callfstat()on every entry ifskip_multilinkis set to fetch thest_nlinkvalue.Signed-off-by Stephen Smalley <[email protected]>Acked-by Petr Lautrbach <[email protected]>
Merged, thanks!
Quoted 29 lines
Quoted 29 lines
--- libselinux/src/selinux_restorecon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)libselinux/src/selinux_restorecon.c +4
-2@@ -1271,13 +1271,15 @@ static int walk_next(struct rest_state *state, int *ent_fd, int *rd_fd,/* * Skip fstat() when d_type already gives the file type and -* neither xdev (st_dev) nor add_assoc (st_ino) is needed. +* none of xdev (st_dev), add_assoc (st_ino), or +* skip_multilink (st_nlink) are needed. * Directories always fstat for cycle detection and walk_push(). */ mode_t mode_from_dtype =d_type_to_mode (de->d_type);bool need_fstat = mode_from_dtype ==0 ||S_ISDIR (mode_from_dtype) || - state->flags.set_xdev || state->flags.add_assoc; + state->flags.set_xdev || state->flags.add_assoc || + state->flags.skip_multilink;if (need_fstat) {if (fstat (fd, ent_sb) <0 ) {Signature · 1 line
2.54.0