#define OPTUTILS_EXIT_CODE MNT_EX_USAGE
#include "optutils.h"
+static struct ul_env_list *envs_removed;
+
static int mk_exit_code(struct libmnt_context *cxt, int rc);
static void suid_drop(struct libmnt_context *cxt)
errx(MNT_EX_FAIL, _("drop permissions failed."));
mnt_context_force_unrestricted(cxt);
+
+ /* restore "bad" environment variables */
+ if (envs_removed) {
+ env_list_setenv(envs_removed);
+ env_list_free(envs_removed);
+ envs_removed = NULL;
+ }
}
static void __attribute__((__noreturn__)) mount_print_version(void)
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
- sanitize_env();
+ __sanitize_env(&envs_removed);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
success_message(cxt);
done:
mnt_free_context(cxt);
+ env_list_free(envs_removed);
return rc;
}
#include "optutils.h"
static int quiet;
+static struct ul_env_list *envs_removed;
static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)),
const char *filename, int line)
errx(MNT_EX_FAIL, _("drop permissions failed."));
mnt_context_force_unrestricted(cxt);
+
+ /* restore "bad" environment variables */
+ if (envs_removed) {
+ env_list_setenv(envs_removed);
+ env_list_free(envs_removed);
+ envs_removed = NULL;
+ }
}
static void success_message(struct libmnt_context *cxt)
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
- sanitize_env();
+ __sanitize_env(&envs_removed);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
}
mnt_free_context(cxt);
+ env_list_free(envs_removed);
+
return (rc < 256) ? rc : 255;
}