ncmlib: Cosmetic cleanups to chroot.c.
This commit is contained in:
parent
f78ea70d71
commit
f8773742c9
@ -1,7 +1,6 @@
|
|||||||
/* chroot.c - chroots ndyndns jobs
|
/* chroot.c - chroots jobs and drops privs
|
||||||
* Time-stamp: <2010-11-03 05:23:56 njk>
|
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Nicholas J. Kain <njkain at gmail dot com>
|
* (c) 2005-2013 Nicholas J. Kain <njkain at gmail dot com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -53,44 +52,36 @@ int chroot_enabled(void)
|
|||||||
|
|
||||||
void update_chroot(const char *path)
|
void update_chroot(const char *path)
|
||||||
{
|
{
|
||||||
strnkcpy(chrootd, path, sizeof chrootd);
|
strnkcpy(chrootd, path, sizeof chrootd);
|
||||||
chroot_modified = 1;
|
chroot_modified = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int chroot_exists(void)
|
int chroot_exists(void)
|
||||||
{
|
{
|
||||||
return chroot_modified;
|
return chroot_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_chroot(void)
|
char *get_chroot(void)
|
||||||
{
|
{
|
||||||
return chrootd;
|
return chrootd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wipe_chroot(void)
|
void wipe_chroot(void)
|
||||||
{
|
{
|
||||||
memset(chrootd, '\0', sizeof chrootd);
|
memset(chrootd, '\0', sizeof chrootd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imprison(const char *path)
|
void imprison(const char *chroot_dir)
|
||||||
{
|
{
|
||||||
int ret;
|
if (chdir(chroot_dir)) {
|
||||||
|
log_line("Failed to chdir(%s)!", chroot_dir);
|
||||||
if (path == NULL)
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (!chroot_enable)
|
||||||
return;
|
return;
|
||||||
|
if (chroot(chroot_dir)) {
|
||||||
ret = chdir(path);
|
log_line("Failed to chroot(%s)!", chroot_dir);
|
||||||
if (ret) {
|
exit(EXIT_FAILURE);
|
||||||
log_line("Failed to chdir(%s). Not invoking job.", path);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chroot_enable) {
|
|
||||||
ret = chroot(path);
|
|
||||||
if (ret) {
|
|
||||||
log_line("Failed to chroot(%s). Not invoking job.", path);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user