這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
freebsd:pam_mkhomedir [2007/08/25 14:15] wenpei 建立 |
freebsd:pam_mkhomedir [2008/01/28 15:37] (目前版本) wenpei |
||
---|---|---|---|
行 3: | 行 3: | ||
例:若 /home 存在,可以建立 /home/sars 目錄,但無法建立 /home/student/sars。 | 例:若 /home 存在,可以建立 /home/sars 目錄,但無法建立 /home/student/sars。 | ||
+ | |||
+ | 從 /usr/ports/security/pam_mkhomedir/work/pam_mkhomedir-0.1 修改: | ||
<code> | <code> | ||
79,80c79,80 | 79,80c79,80 | ||
- | < if (mkdir(dir, mode) != 0 && errno != EEXIST) { | + | < if (mkdir(dir, mode) != 0 && errno != EEXIST) { |
- | < PAM_LOG("mkdir(%s)", dir); | + | < PAM_LOG("mkdir(%s)", dir); |
--- | --- | ||
- | > if (opendir(dir)!=NULL) { | + | > if (opendir(dir)!=NULL) { |
- | > /* exist */ | + | > /* exist */ |
86a87,105 | 86a87,105 | ||
- | > | + | > |
- | > /* create DIR recursively */ | + | > /* create DIR recursively */ |
- | > int index = 0; | + | > int index = 0; |
- | > char *tempstr = (void*)malloc(strlen(dir)); | + | > char *tempstr = (void*)malloc(strlen(dir)); |
- | > strcpy(tempstr,dir); | + | > strcpy(tempstr,dir); |
- | > | + | > |
- | > for (index = 1; tempstr[index] != '\0'; index++) { | + | > for (index = 1; tempstr[index] != '\0'; index++) { |
- | > /* Create the new directory */ | + | > /* Create the new directory */ |
- | > if ( tempstr[index] == '/' ) { | + | > if ( tempstr[index] == '/' ) { |
- | > tempstr[index] = '\0'; | + | > tempstr[index] = '\0'; |
- | > mkdir(tempstr, mode); | + | > mkdir(tempstr, mode); |
- | > chown(tempstr, 0, 0); | + | > chown(tempstr, 0, 0); |
- | > tempstr[index] = '/'; | + | > tempstr[index] = '/'; |
- | > } | + | > } |
- | > } | + | > } |
- | > | + | > |
- | > mkdir(dir, mode); | + | > mkdir(dir, mode); |
- | > free(tempstr); | + | > free(tempstr); |
- | > /* end of modify */ | + | > /* end of modify */ |
</code> | </code> |