restrict-access.c revision 0b7a602d536242ebdc446d5ceaf0c92ed3062fb7
/*
Copyright (c) 2002 Timo Sirainen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "lib.h"
#include "restrict-access.h"
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <grp.h>
const char *chroot_dir)
{
}
void restrict_access_by_env(void)
{
const char *env;
/* chrooting */
/* kludge: localtime() must be called before chroot(),
or the timezone isn't known */
time_t t = 0;
(void)localtime(&t);
if (chdir("/") != 0)
i_fatal("chdir(/) failed: %m");
}
/* groups - the getgid() checks are just so we don't fail if we're
not running as root and try to just use our own GID. */
/* user not known, use only this one group */
} else {
i_fatal("initgroups(%s, %ld) failed: %m",
}
}
}
/* uid last */
if (uid != 0) {
/* just extra verification */
#ifdef HAVE_SETREUID
#else
if (setuid(0) == 0)
#endif
i_fatal("We couldn't drop root privileges");
}
}