Use struct sudoers_pivot instead of defining sudoers_pivot_t.

We want to pass around a pointer, not the struct itself.
This commit is contained in:
Todd C. Miller
2023-09-13 08:36:07 -06:00
parent 15b3d786d7
commit 34990c0e08
7 changed files with 51 additions and 52 deletions

View File

@@ -806,7 +806,7 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
const struct command_digest_list *digests)
{
const bool intercepted = info ? info->intercepted : false;
sudoers_pivot_t pivot_state = SUDOERS_PIVOT_INITIALIZER;
struct sudoers_pivot pivot_state = SUDOERS_PIVOT_INITIALIZER;
char *saved_user_cmnd = NULL;
struct stat saved_user_stat;
bool reset_cmnd = false;
@@ -832,7 +832,7 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
/* Pivot root. */
if (runchroot != NULL) {
if (!pivot_root(runchroot, pivot_state))
if (!pivot_root(runchroot, &pivot_state))
goto done;
}
@@ -856,7 +856,7 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
if (sudoers_cmnd == NULL) {
sudoers_cmnd = "ALL";
ret = command_matches_all(ctx, pivot_get_root(pivot_state),
ret = command_matches_all(ctx, pivot_get_root(&pivot_state),
intercepted, digests);
goto done;
}
@@ -864,7 +864,7 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
/* Check for regular expressions first. */
if (sudoers_cmnd[0] == '^') {
ret = command_matches_regex(ctx, sudoers_cmnd, sudoers_args,
pivot_get_root(pivot_state), intercepted, digests);
pivot_get_root(&pivot_state), intercepted, digests);
goto done;
}
@@ -894,19 +894,19 @@ command_matches(struct sudoers_context *ctx, const char *sudoers_cmnd,
*/
if (def_fast_glob) {
ret = command_matches_fnmatch(ctx, sudoers_cmnd, sudoers_args,
pivot_get_root(pivot_state), intercepted, digests);
pivot_get_root(&pivot_state), intercepted, digests);
} else {
ret = command_matches_glob(ctx, sudoers_cmnd, sudoers_args,
pivot_get_root(pivot_state), intercepted, digests);
pivot_get_root(&pivot_state), intercepted, digests);
}
} else {
ret = command_matches_normal(ctx, sudoers_cmnd, sudoers_args,
pivot_get_root(pivot_state), intercepted, digests);
pivot_get_root(&pivot_state), intercepted, digests);
}
done:
/* Restore root. */
if (runchroot != NULL)
(void)unpivot_root(pivot_state);
(void)unpivot_root(&pivot_state);
/* Restore ctx->user.cmnd and ctx->user.cmnd_stat. */
if (saved_user_cmnd != NULL) {