Add authorization for current user if no others specified.
authorfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Wed, 11 Apr 2007 14:46:29 +0000 (14:46 +0000)
committerfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Wed, 11 Apr 2007 14:46:29 +0000 (14:46 +0000)
git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@898 959494ce-11ee-0310-bf91-de5d638817bd

daemon/ui.c

index 34eebc1..6beb6a7 100644 (file)
@@ -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);
 }