X-Git-Url: https://git.hcoop.net/hcoop/debian/libnss-afs.git/blobdiff_plain/be93aa7b0ef9b5b58a15e03a0bf47a8b5cf8e9fc..HEAD:/nss_afs.c?ds=sidebyside diff --git a/nss_afs.c b/nss_afs.c index 9c9740c..a9326d4 100644 --- a/nss_afs.c +++ b/nss_afs.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -56,13 +57,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #define HOMEDIR_AUTO 0 @@ -87,12 +88,14 @@ extern struct ubik_client *pruclient; int afs_initialized = 0; char cellname[MAXCELLNAMELEN]; -char homedir_prefix[MAXPATHLEN]; -char cell_root[MAXPATHLEN]; +char homedir_prefix[PATH_MAX]; +char cell_root[PATH_MAX]; int homedir_prefix_len=0; char homedirs_method=0; char shells_method=0; +int init_afs (); + /** * The cpstr() function copies a null-terminated string from str* * (the first argument) into buf and updates both buf and buflen. If @@ -111,12 +114,12 @@ int cpstr( char *str, char **buf, size_t *buflen) { /** * Look up the name corresponding to uid, store in buffer. */ -enum nss_status ptsid2name(int uid, char **buffer, int *buflen) { +enum nss_status ptsid2name(int uid, char **buffer, size_t *buflen) { int ret, i; idlist lid; namelist lnames; - init_afs(); + if (init_afs()) return NSS_STATUS_UNAVAIL; if (uid==AFS_MAGIC_ANONYMOUS_USERID) { if (!cpstr("anonymous", buffer, buflen)) return NSS_STATUS_UNAVAIL; @@ -130,7 +133,7 @@ enum nss_status ptsid2name(int uid, char **buffer, int *buflen) { lnames.namelist_val = 0; lnames.namelist_len = 0; - if (ubik_Call(PR_IDToName,pruclient,0,&lid,&lnames) != PRSUCCESS) { + if (ubik_PR_IDToName(pruclient,0,&lid,&lnames) != PRSUCCESS) { perror("ubik_Call() in ptsid2name() failed\n"); pthread_mutex_unlock(&mutex); return NSS_STATUS_UNAVAIL; @@ -139,7 +142,7 @@ enum nss_status ptsid2name(int uid, char **buffer, int *buflen) { ret = NSS_STATUS_NOTFOUND; for (i=0;igr_passwd=buffer; - if (!cpstr("x",&buffer,&buflen)) break; + if (!cpstr("z",&buffer,&buflen)) break; if (buflen < sizeof(char*)) break; - result->gr_mem=buffer; + result->gr_mem=&buffer; result->gr_mem[0] = NULL; *errnop=errno; @@ -390,9 +417,9 @@ enum nss_status fill_result_buf(uid_t uid, int *errnop) { result_buf->pw_name = name; do { - /* set the password to "x" */ + /* set the password to "z"; we can't use "x" because of pam_unix.so */ result_buf->pw_passwd = buffer; - if ( ! cpstr("x",&buffer, &buflen) ) break; + if ( ! cpstr("z",&buffer, &buflen) ) break; /* the uid and gid are both the uid passed in */ result_buf->pw_uid = uid;