From: fredrik Date: Wed, 11 Apr 2007 14:46:29 +0000 (+0000) Subject: Add authorization for current user if no others specified. X-Git-Tag: 0.3~39 X-Git-Url: http://git.dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=8754fb8567f5c21e9e034032d1a8abc4dab909fe Add authorization for current user if no others specified. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@898 959494ce-11ee-0310-bf91-de5d638817bd --- 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); }