X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fauth-unix.c;h=7cf9c8ef90dabe3f0d89882057b898069fbd5e26;hb=d1ef02006f3d39a45ef40235f716c7f9317195f6;hp=c90aba88d9cfc77ca0fa1c52c3790804565edb02;hpb=3616b334bc6426e973e08b612a5e8fd30ad80a5f;p=doldaconnect.git diff --git a/daemon/auth-unix.c b/daemon/auth-unix.c index c90aba8..7cf9c8e 100644 --- a/daemon/auth-unix.c +++ b/daemon/auth-unix.c @@ -1,6 +1,6 @@ /* * Dolda Connect - Modular multiuser Direct Connect-style client - * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) + * Copyright (C) 2004 Fredrik Tolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,23 +59,27 @@ 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.pid == 0) { - errno = EBADE; + if(getucred(sk, &uid, &gid)) { + errno = EOPNOTSUPP; /* Bleh */ return(AUTH_ERR); } - if(pwd->pw_uid == sk->ucred.uid) + 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"); return(AUTH_DENIED); } static int available(struct socket *sk) { - return((sk->family == PF_UNIX) && (sk->ucred.pid != 0)); + return(sockfamily(sk) == PF_UNIX); } static struct authmech mechdesc = {