X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fui.c;h=6beb6a7c9fe66b413ca06c2916897327a61a568c;hb=f2c559da411213b4366ee179ba6cd7e853982f9e;hp=d77efa79146b67eac62588d857e30e0127b2eff7;hpb=b5010caaa4606ea37df9cd1334dc99fff05a8bd3;p=doldaconnect.git diff --git a/daemon/ui.c b/daemon/ui.c index d77efa7..6beb6a7 100644 --- a/daemon/ui.c +++ b/daemon/ui.c @@ -389,7 +389,7 @@ static void cmd_lsauth(struct socket *sk, struct uidata *data, int argc, wchar_t 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); @@ -438,7 +438,7 @@ static void cmd_login(struct socket *sk, struct uidata *data, int argc, wchar_t return; } free(buf); - switch(authenticate(data->auth, NULL)) + switch(authenticate(data->auth, sk, NULL)) { case AUTH_SUCCESS: data->userinfo = finduser(data->username); @@ -512,7 +512,7 @@ static void cmd_pass(struct socket *sk, struct uidata *data, int argc, wchar_t * 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); @@ -2132,7 +2132,7 @@ static void preinit(int hup) if(!hup) { - newuser(L"default", 0); + newuser(L"default", PERM_DISALLOW); } else { for(user = users; user != NULL; user = user->next) { @@ -2226,6 +2226,8 @@ static int init(int hup) { struct uiuser *user, *next; struct sockaddr_un *un; + struct passwd *pwd; + wchar_t *wcsname; if(hup) { @@ -2254,6 +2256,29 @@ static int init(int 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); }