1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { const char *PAM_user = NULL; char fnam[400]; int ret, err, count, i; struct mount_entries *entries; struct stat statbuf; ret = pam_get_user(pamh, &PAM_user, NULL); if (ret != PAM_SUCCESS) { mysyslog(LOG_ERR, "PAM-MOUNT: couldn't get user\n"); return PAM_SESSION_ERR; } /* check whether /share/$pam_user/root exists. If so, chroot to it */ sprintf(fnam, "/share/%s/root", PAM_user); ret = stat(fnam, &statbuf); if (ret == 0 && S_ISDIR(statbuf.st_mode)) { ret = chroot(fnam); if (ret) { mysyslog(LOG_ERR, "PAM-MOUNT: unable to chroot to %s\n", fnam); return PAM_SESSION_ERR; } } return PAM_SUCCESS; } |
1 2 3 4 5 | mkdir -p /share/USER/root mount --make-rshared / mount --rbind / /share/USER/root mount --make-rslave /share/USER/root mount --bind /share/USER/root/tmp/priv/USER /share/USER/root/tmp |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |