From 15b3d786d7330defc796e73044f45d4983a432c8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 11 Sep 2023 16:21:11 -0600 Subject: [PATCH] Don't expose the implementation of the pivot_root state. --- MANIFEST | 1 + plugins/sudoers/pivot.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 plugins/sudoers/pivot.h diff --git a/MANIFEST b/MANIFEST index 342b9c2af..6e9af61b5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -686,6 +686,7 @@ plugins/sudoers/mkdefaults plugins/sudoers/parse.h plugins/sudoers/parse_ldif.c plugins/sudoers/pivot.c +plugins/sudoers/pivot.h plugins/sudoers/po/README plugins/sudoers/po/ast.mo plugins/sudoers/po/ast.po diff --git a/plugins/sudoers/pivot.h b/plugins/sudoers/pivot.h new file mode 100644 index 000000000..7336d3ab6 --- /dev/null +++ b/plugins/sudoers/pivot.h @@ -0,0 +1,35 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2023 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef SUDOERS_PIVOT_H +#define SUDOERS_PIVOT_H + +#define SUDOERS_PIVOT_INITIALIZER { -1, -1 } + +struct sudoers_pivot { + int saved_root; + int saved_cwd; +}; +typedef struct sudoers_pivot sudoers_pivot_t; + +bool pivot_root(const char *new_root, sudoers_pivot_t cookie); +bool unpivot_root(sudoers_pivot_t cookie); +int pivot_get_root(sudoers_pivot_t cookie); +int pivot_get_cwd(sudoers_pivot_t cookie); + +#endif /* SUDOERS_PIVOT_H */