#define _GNU_SOURCE
#include <unistd.h>
#include <stdlib.h>
-#include <malloc.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
prev = NULL;
for(mech = mechs; mech != NULL; mech = mech->next)
{
- if(mech->enabled)
+ if(mech->enabled && authavailable(mech, sk))
{
if(prev != NULL)
sq(sk, 1, L"200", prev->name, NULL);
return;
}
free(buf);
- switch(authenticate(data->auth, NULL))
+ switch(authenticate(data->auth, sk, NULL))
{
case AUTH_SUCCESS:
data->userinfo = finduser(data->username);
sq(sk, 0, L"507", L"Data not expected", NULL);
return;
}
- switch(authenticate(data->auth, buf))
+ switch(authenticate(data->auth, sk, buf))
{
case AUTH_SUCCESS:
data->userinfo = finduser(data->username);
if(!hup)
{
- newuser(L"default", 0);
+ newuser(L"default", PERM_DISALLOW);
} else {
for(user = users; user != NULL; user = user->next)
{
{
struct uiuser *user, *next;
struct sockaddr_un *un;
+ struct passwd *pwd;
+ wchar_t *wcsname;
if(hup)
{
GCBREG(newfncb, newfnetnode, NULL);
GCBREG(newtransfercb, newtransfernotify, NULL);
}
+ if(getuid() != 0)
+ {
+ for(user = users; user != NULL; user = user->next)
+ {
+ if(wcscmp(user->name, L"default"))
+ break;
+ }
+ if(!user)
+ {
+ if((pwd = getpwuid(getuid())) == NULL)
+ {
+ flog(LOG_CRIT, "could not get login info: %s", strerror(errno));
+ return(1);
+ }
+ if((wcsname = icmbstowcs(pwd->pw_name, NULL)) == NULL)
+ {
+ flog(LOG_CRIT, "could not convert user name into wcs: %s", strerror(errno));
+ return(1);
+ }
+ newuser(wcsname, ~PERM_DISALLOW);
+ free(wcsname);
+ }
+ }
return(0);
}