使用者工具

網站工具


freebsd:pam_mkhomedir

這是本文件的舊版!


pam_mkhomedir

第一次透過 PAM_LDAP 登入時,可以使用 PAM_MKHOMEDIR 自動創建使用者家目錄,但是原本的程式有缺陷,不能遞迴地建立目錄,只好自己 patch。

例:若 /home 存在,可以建立 /home/sars 目錄,但無法建立 /home/student/sars。

79,80c79,80
<       if (mkdir(dir, mode) != 0 && errno != EEXIST) {
<               PAM_LOG("mkdir(%s)", dir);
---
>       if (opendir(dir)!=NULL) {
>               /* exist */
86a87,105
>
>               /* create DIR recursively */
>               int index = 0;
>               char *tempstr = (void*)malloc(strlen(dir));
>               strcpy(tempstr,dir);
>
>               for (index = 1; tempstr[index] != '\0'; index++) {
>                       /* Create the new directory */
>                       if ( tempstr[index] == '/' ) {
>                               tempstr[index] = '\0';
>                               mkdir(tempstr, mode);
>                               chown(tempstr, 0, 0);
>                               tempstr[index] = '/';
>                       }
>               }
>
>               mkdir(dir, mode);
>               free(tempstr);
>               /* end of modify */
freebsd/pam_mkhomedir.1188022534.txt.gz · 上一次變更: 2007/08/25 14:15 由 wenpei