X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fui.c;h=2bd5a9d9a2b33c5e3daebe6e7e06951539f3a384;hb=5e1e52f14fabed501d62d56fecc0b91d972e5673;hp=f94737907ff07c9f00d4855ba0944aa41f3800d6;hpb=ddb933f1aa1817f5a285bba0a9bda18e00bc30ef;p=doldaconnect.git diff --git a/daemon/ui.c b/daemon/ui.c index f947379..2bd5a9d 100644 --- a/daemon/ui.c +++ b/daemon/ui.c @@ -19,7 +19,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include @@ -356,7 +355,7 @@ static void cmd_connect(struct socket *sk, struct uidata *data, int argc, wchar_ return; } } - sq(sk, 0, L"200", L"%Dolda Connect daemon v%s", VERSION, NULL); + sq(sk, 0, L"201", L"1", L"1", L"%Dolda Connect daemon v%s", VERSION, NULL); } static void cmd_notfound(struct socket *sk, struct uidata *data, int argc, wchar_t **argv) @@ -390,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); @@ -439,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); @@ -513,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); @@ -2133,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) { @@ -2227,6 +2226,8 @@ static int init(int hup) { struct uiuser *user, *next; struct sockaddr_un *un; + struct passwd *pwd; + wchar_t *wcsname; if(hup) { @@ -2255,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); }