void xchroot(const char *path) FAST_FUNC;
void xsetenv(const char *key, const char *value) FAST_FUNC;
void bb_unsetenv(const char *key) FAST_FUNC;
+void bb_unsetenv_and_free(char *key) FAST_FUNC;
void xunlink(const char *pathname) FAST_FUNC;
void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
int xopen(const char *pathname, int flags) FAST_FUNC;
free(tp);
}
+void FAST_FUNC bb_unsetenv_and_free(char *var)
+{
+ bb_unsetenv(var);
+ free(var);
+}
// Die with an error message if we can't set gid. (Because resource limits may
// limit this user to a given number of processes, and if that fills up the
char *var_val = *pvar_val;
if (var_val) {
- bb_unsetenv(var_val);
- free(var_val);
+ bb_unsetenv_and_free(var_val);
}
*pvar_val = xasprintf("%s=%s", var, val);
putenv(*pvar_val);
char **pp = env_cur = &env_var[0];
while (*pp) {
char *var = *pp;
- bb_unsetenv(var);
- free(var);
+ bb_unsetenv_and_free(var);
*pp++ = NULL;
}
}
for (curr = envp; *curr; curr++) {
log2(" %s", *curr);
- bb_unsetenv(*curr);
- free(*curr);
+ bb_unsetenv_and_free(*curr);
}
free(envp);
}
putenv(s1);
if (system(command) == -1)
bb_perror_msg("can't run '%s'", command);
- unsetenv("SUBSYSTEM");
- free(s1);
- unsetenv("MDEV");
- free(s);
+ bb_unsetenv_and_free(s1);
+ bb_unsetenv_and_free(s);
free(command);
}