X-Git-Url: http://dolda2000.com/gitweb/?p=doldaconnect.git;a=blobdiff_plain;f=daemon%2Fauth-unix.c;h=7cf9c8ef90dabe3f0d89882057b898069fbd5e26;hp=00266e161b6b2407df7e6fb4288e10ee83eb4e88;hb=d1ef02006f3d39a45ef40235f716c7f9317195f6;hpb=2b9a1911defbd6f0295b74cd7b41a2a5328d9e6a diff --git a/daemon/auth-unix.c b/daemon/auth-unix.c index 00266e1..7cf9c8e 100644 --- a/daemon/auth-unix.c +++ b/daemon/auth-unix.c @@ -59,16 +59,18 @@ static int unixauth(struct authhandle *auth, struct socket *sk, char *passdata) { struct passwd *pwd; struct unixdata *data; + uid_t uid; + gid_t gid; data = auth->mechdata; if((pwd = getpwnam(data->username)) == NULL) return(AUTH_ERR); - if(sk->ucred.uid == -1) { + if(getucred(sk, &uid, &gid)) { errno = EOPNOTSUPP; /* Bleh */ return(AUTH_ERR); } - if(pwd->pw_uid == sk->ucred.uid) { - flog(LOG_INFO, "successful authentication as %s with Unix credentials (uid=%i, gid=%i)", data->username, sk->ucred.uid, sk->ucred.gid); + if(pwd->pw_uid == uid) { + flog(LOG_INFO, "successful authentication as %s with Unix credentials (uid=%i, gid=%i)", data->username, uid, gid); return(AUTH_SUCCESS); } auth->text = swcsdup(L"Unix credentials do not match supplied user name"); @@ -77,7 +79,7 @@ static int unixauth(struct authhandle *auth, struct socket *sk, char *passdata) static int available(struct socket *sk) { - return((sk->family == PF_UNIX) && (sk->ucred.uid != -1)); + return(sockfamily(sk) == PF_UNIX); } static struct authmech mechdesc = {