@@ -134,25 +134,6 @@ do_stat(int fd, const char *path, struct stat *sb)
134134 }
135135 debug_return_bool (ret );
136136}
137-
138- /*
139- * Perform intercept-specific checks.
140- * Returns true if allowed, else false.
141- */
142- static bool
143- intercept_ok (const char * path , bool intercepted , struct stat * sb )
144- {
145- debug_decl (intercept_ok , SUDOERS_DEBUG_MATCH );
146-
147- if (intercepted ) {
148- if (!def_intercept_allow_setid && ISSET (sb -> st_mode , S_ISUID |S_ISGID )) {
149- sudo_debug_printf (SUDO_DEBUG_WARN |SUDO_DEBUG_LINENO ,
150- "rejecting setid command %s" , path );
151- debug_return_bool (false);
152- }
153- }
154- debug_return_bool (true);
155- }
156137#endif /* SUDOERS_NAME_MATCH */
157138
158139/*
@@ -257,8 +238,7 @@ set_cmnd_fd(struct sudoers_context *ctx, int fd, int real_root)
257238 */
258239static int
259240command_matches_dir (struct sudoers_context * ctx , const char * sudoers_dir ,
260- size_t dlen , int real_root , bool intercepted ,
261- const struct command_digest_list * digests )
241+ size_t dlen , int real_root , const struct command_digest_list * digests )
262242{
263243 struct stat sudoers_stat ;
264244 char path [PATH_MAX ];
@@ -288,8 +268,6 @@ command_matches_dir(struct sudoers_context *ctx, const char *sudoers_dir,
288268 goto done ;
289269 if (!do_stat (fd , path , & sudoers_stat ))
290270 goto done ;
291- if (!intercept_ok (path , intercepted , & sudoers_stat ))
292- goto done ;
293271
294272 if (ctx -> user .cmnd_stat == NULL ||
295273 (ctx -> user .cmnd_stat -> st_dev == sudoers_stat .st_dev &&
@@ -317,8 +295,7 @@ command_matches_dir(struct sudoers_context *ctx, const char *sudoers_dir,
317295 */
318296static int
319297command_matches_dir (struct sudoers_context * ctx , const char * sudoers_dir ,
320- size_t dlen , int real_root , bool intercepted ,
321- const struct command_digest_list * digests )
298+ size_t dlen , int real_root , const struct command_digest_list * digests )
322299{
323300 int fd = -1 ;
324301 debug_decl (command_matches_dir , SUDOERS_DEBUG_MATCH );
@@ -348,7 +325,7 @@ command_matches_dir(struct sudoers_context *ctx, const char *sudoers_dir,
348325
349326static int
350327command_matches_all (struct sudoers_context * ctx , int real_root ,
351- bool intercepted , const struct command_digest_list * digests )
328+ const struct command_digest_list * digests )
352329{
353330#ifndef SUDOERS_NAME_MATCH
354331 struct stat sb ;
@@ -367,8 +344,6 @@ command_matches_all(struct sudoers_context *ctx, int real_root,
367344 /* File exists but we couldn't open it above? */
368345 goto bad ;
369346 }
370- if (!intercept_ok (ctx -> user .cmnd , intercepted , & sb ))
371- goto bad ;
372347 }
373348#else
374349 /* Open the file for fdexec or for digest matching. */
@@ -391,7 +366,7 @@ command_matches_all(struct sudoers_context *ctx, int real_root,
391366
392367static int
393368command_matches_fnmatch (struct sudoers_context * ctx , const char * sudoers_cmnd ,
394- const char * sudoers_args , int real_root , bool intercepted ,
369+ const char * sudoers_args , int real_root ,
395370 const struct command_digest_list * digests )
396371{
397372 const char * cmnd = ctx -> user .cmnd ;
@@ -430,8 +405,6 @@ command_matches_fnmatch(struct sudoers_context *ctx, const char *sudoers_cmnd,
430405#ifndef SUDOERS_NAME_MATCH
431406 if (!do_stat (fd , cmnd , & sb ))
432407 goto bad ;
433- if (!intercept_ok (cmnd , intercepted , & sb ))
434- goto bad ;
435408#endif
436409 /* Check digest of cmnd since sudoers_cmnd is a pattern. */
437410 if (digest_matches (fd , cmnd , digests ) != ALLOW )
@@ -449,7 +422,7 @@ command_matches_fnmatch(struct sudoers_context *ctx, const char *sudoers_cmnd,
449422
450423static int
451424command_matches_regex (struct sudoers_context * ctx , const char * sudoers_cmnd ,
452- const char * sudoers_args , int real_root , bool intercepted ,
425+ const char * sudoers_args , int real_root ,
453426 const struct command_digest_list * digests )
454427{
455428 const char * cmnd = ctx -> user .cmnd ;
@@ -488,8 +461,6 @@ command_matches_regex(struct sudoers_context *ctx, const char *sudoers_cmnd,
488461#ifndef SUDOERS_NAME_MATCH
489462 if (!do_stat (fd , cmnd , & sb ))
490463 goto bad ;
491- if (!intercept_ok (cmnd , intercepted , & sb ))
492- goto bad ;
493464#endif
494465 /* Check digest of cmnd since sudoers_cmnd is a pattern. */
495466 if (digest_matches (fd , cmnd , digests ) != ALLOW )
@@ -508,7 +479,7 @@ command_matches_regex(struct sudoers_context *ctx, const char *sudoers_cmnd,
508479#ifndef SUDOERS_NAME_MATCH
509480static int
510481command_matches_glob (struct sudoers_context * ctx , const char * sudoers_cmnd ,
511- const char * sudoers_args , int real_root , bool intercepted ,
482+ const char * sudoers_args , int real_root ,
512483 const struct command_digest_list * digests )
513484{
514485 struct stat sudoers_stat ;
@@ -558,8 +529,6 @@ command_matches_glob(struct sudoers_context *ctx, const char *sudoers_cmnd,
558529 continue ;
559530 if (!do_stat (fd , cp , & sudoers_stat ))
560531 continue ;
561- if (!intercept_ok (cp , intercepted , & sudoers_stat ))
562- continue ;
563532 if (ctx -> user .cmnd_stat == NULL ||
564533 (ctx -> user .cmnd_stat -> st_dev == sudoers_stat .st_dev &&
565534 ctx -> user .cmnd_stat -> st_ino == sudoers_stat .st_ino )) {
@@ -592,8 +561,7 @@ command_matches_glob(struct sudoers_context *ctx, const char *sudoers_cmnd,
592561 /* If it ends in '/' it is a directory spec. */
593562 dlen = strlen (cp );
594563 if (cp [dlen - 1 ] == '/' ) {
595- if (command_matches_dir (ctx , cp , dlen , real_root , intercepted ,
596- digests ) == ALLOW ) {
564+ if (command_matches_dir (ctx , cp , dlen , real_root , digests ) == ALLOW ) {
597565 globfree (& gl );
598566 debug_return_int (ALLOW );
599567 }
@@ -628,8 +596,6 @@ command_matches_glob(struct sudoers_context *ctx, const char *sudoers_cmnd,
628596 continue ;
629597 if (!do_stat (fd , cp , & sudoers_stat ))
630598 continue ;
631- if (!intercept_ok (cp , intercepted , & sudoers_stat ))
632- continue ;
633599 if (ctx -> user .cmnd_stat == NULL ||
634600 (ctx -> user .cmnd_stat -> st_dev == sudoers_stat .st_dev &&
635601 ctx -> user .cmnd_stat -> st_ino == sudoers_stat .st_ino )) {
@@ -661,7 +627,7 @@ command_matches_glob(struct sudoers_context *ctx, const char *sudoers_cmnd,
661627
662628static int
663629command_matches_normal (struct sudoers_context * ctx , const char * sudoers_cmnd ,
664- const char * sudoers_args , int real_root , bool intercepted ,
630+ const char * sudoers_args , int real_root ,
665631 const struct command_digest_list * digests )
666632{
667633 struct stat sudoers_stat ;
@@ -674,7 +640,7 @@ command_matches_normal(struct sudoers_context *ctx, const char *sudoers_cmnd,
674640 dlen = strlen (sudoers_cmnd );
675641 if (sudoers_cmnd [dlen - 1 ] == '/' ) {
676642 debug_return_int (command_matches_dir (ctx , sudoers_cmnd , dlen ,
677- real_root , intercepted , digests ));
643+ real_root , digests ));
678644 }
679645
680646 /* Only proceed if ctx->user.cmnd_base and basename(sudoers_cmnd) match */
@@ -716,8 +682,6 @@ command_matches_normal(struct sudoers_context *ctx, const char *sudoers_cmnd,
716682 * d) there is a digest and it matches
717683 */
718684 if (ctx -> user .cmnd_stat != NULL && do_stat (fd , sudoers_cmnd , & sudoers_stat )) {
719- if (!intercept_ok (sudoers_cmnd , intercepted , & sudoers_stat ))
720- goto bad ;
721685 if (ctx -> user .cmnd_stat -> st_dev != sudoers_stat .st_dev ||
722686 ctx -> user .cmnd_stat -> st_ino != sudoers_stat .st_ino )
723687 goto bad ;
@@ -747,16 +711,16 @@ command_matches_normal(struct sudoers_context *ctx, const char *sudoers_cmnd,
747711#else /* SUDOERS_NAME_MATCH */
748712static int
749713command_matches_glob (struct sudoers_context * ctx , const char * sudoers_cmnd ,
750- const char * sudoers_args , int real_root , bool intercepted ,
714+ const char * sudoers_args , int real_root ,
751715 const struct command_digest_list * digests )
752716{
753717 return command_matches_fnmatch (ctx , sudoers_cmnd , sudoers_args , real_root ,
754- intercepted , digests );
718+ digests );
755719}
756720
757721static int
758722command_matches_normal (struct sudoers_context * ctx , const char * sudoers_cmnd ,
759- const char * sudoers_args , int real_root , bool intercepted ,
723+ const char * sudoers_args , int real_root ,
760724 const struct command_digest_list * digests )
761725{
762726 size_t dlen ;
@@ -767,7 +731,7 @@ command_matches_normal(struct sudoers_context *ctx, const char *sudoers_cmnd,
767731 dlen = strlen (sudoers_cmnd );
768732 if (sudoers_cmnd [dlen - 1 ] == '/' ) {
769733 debug_return_int (command_matches_dir (ctx , sudoers_cmnd , dlen , real_root ,
770- intercepted , digests ));
734+ digests ));
771735 }
772736
773737 if (strcmp (ctx -> user .cmnd , sudoers_cmnd ) == 0 ) {
@@ -806,7 +770,6 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
806770 const char * sudoers_args , const char * runchroot , struct cmnd_info * info ,
807771 const struct command_digest_list * digests )
808772{
809- const bool intercepted = info ? info -> intercepted : false;
810773 struct sudoers_pivot pivot_state = SUDOERS_PIVOT_INITIALIZER ;
811774 char * saved_user_cmnd = NULL ;
812775 struct stat saved_user_stat ;
@@ -859,14 +822,14 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
859822
860823 if (sudoers_cmnd == NULL ) {
861824 sudoers_cmnd = "ALL" ;
862- ret = command_matches_all (ctx , real_root , intercepted , digests );
825+ ret = command_matches_all (ctx , real_root , digests );
863826 goto done ;
864827 }
865828
866829 /* Check for regular expressions first. */
867830 if (sudoers_cmnd [0 ] == '^' ) {
868831 ret = command_matches_regex (ctx , sudoers_cmnd , sudoers_args , real_root ,
869- intercepted , digests );
832+ digests );
870833 goto done ;
871834 }
872835
@@ -896,14 +859,14 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
896859 */
897860 if (def_fast_glob ) {
898861 ret = command_matches_fnmatch (ctx , sudoers_cmnd , sudoers_args ,
899- real_root , intercepted , digests );
862+ real_root , digests );
900863 } else {
901864 ret = command_matches_glob (ctx , sudoers_cmnd , sudoers_args ,
902- real_root , intercepted , digests );
865+ real_root , digests );
903866 }
904867 } else {
905868 ret = command_matches_normal (ctx , sudoers_cmnd , sudoers_args ,
906- real_root , intercepted , digests );
869+ real_root , digests );
907870 }
908871done :
909872 /* Restore root. */
0 commit comments