X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fui.c;h=6beb6a7c9fe66b413ca06c2916897327a61a568c;hb=8754fb8567f5c21e9e034032d1a8abc4dab909fe;hp=34eebc10210f0ae6cf860f3c10e3b24ec8ba4401;hpb=3616b334bc6426e973e08b612a5e8fd30ad80a5f;p=doldaconnect.git diff --git a/daemon/ui.c b/daemon/ui.c index 34eebc1..6beb6a7 100644 --- a/daemon/ui.c +++ b/daemon/ui.c @@ -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); }