version 1.294, 2018/03/03 03:15:51 |
version 1.295, 2018/06/01 03:33:53 |
|
|
void |
void |
do_setusercontext(struct passwd *pw) |
do_setusercontext(struct passwd *pw) |
{ |
{ |
char *chroot_path, *tmp; |
char uidstr[32], *chroot_path, *tmp; |
|
|
if (getuid() == 0 || geteuid() == 0) { |
if (getuid() == 0 || geteuid() == 0) { |
/* Prepare groups */ |
/* Prepare groups */ |
|
|
strcasecmp(options.chroot_directory, "none") != 0) { |
strcasecmp(options.chroot_directory, "none") != 0) { |
tmp = tilde_expand_filename(options.chroot_directory, |
tmp = tilde_expand_filename(options.chroot_directory, |
pw->pw_uid); |
pw->pw_uid); |
|
snprintf(uidstr, sizeof(uidstr), "%llu", |
|
(unsigned long long)pw->pw_uid); |
chroot_path = percent_expand(tmp, "h", pw->pw_dir, |
chroot_path = percent_expand(tmp, "h", pw->pw_dir, |
"u", pw->pw_name, (char *)NULL); |
"u", pw->pw_name, "U", uidstr, (char *)NULL); |
safely_chroot(chroot_path, pw->pw_uid); |
safely_chroot(chroot_path, pw->pw_uid); |
free(tmp); |
free(tmp); |
free(chroot_path); |
free(chroot_path); |