Create Unix socket with correct perms.
authorfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Tue, 19 Jun 2007 02:49:41 +0000 (02:49 +0000)
committerfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Tue, 19 Jun 2007 02:49:41 +0000 (02:49 +0000)
git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1080 959494ce-11ee-0310-bf91-de5d638817bd

daemon/ui.c

index 8e9b643..e4178eb 100644 (file)
@@ -2234,13 +2234,17 @@ static int unixsockupdate(struct configvar *var, void *uudata)
 {
     struct socket *newsock;
     struct sockaddr_un *un;
+    mode_t ou;
     
     newsock = NULL;
+    ou = umask(0111);
     if(((un = makeunixname()) != NULL) && ((newsock = netcslistenlocal(SOCK_STREAM, (struct sockaddr *)un, sizeof(*un), uiaccept, NULL)) == NULL))
     {
+       umask(ou);
        flog(LOG_WARNING, "could not create new Unix UI socket, reverting to old: %s", strerror(errno));
        return(0);
     }
+    umask(ou);
     if(unixsocket != NULL)
     {
        putsock(unixsocket);
@@ -2256,6 +2260,7 @@ static int init(int hup)
     struct sockaddr_un *un;
     struct passwd *pwd;
     wchar_t *wcsname;
+    mode_t ou;
     
     if(hup)
     {
@@ -2275,11 +2280,14 @@ static int init(int hup)
            return(1);
        }
        CBREG(confgetvar("ui", "port"), conf_update, tcpportupdate, NULL, NULL);
+       ou = umask(0111);
        if(((un = makeunixname()) != NULL) && ((unixsocket = netcslistenlocal(SOCK_STREAM, (struct sockaddr *)un, sizeof(*un), uiaccept, NULL)) == NULL))
        {
+           umask(ou);
            flog(LOG_CRIT, "could not create Unix UI socket: %s", strerror(errno));
            return(1);
        }
+       umask(ou);
        CBREG(confgetvar("ui", "unixsock"), conf_update, unixsockupdate, NULL, NULL);
        GCBREG(newfncb, newfnetnode, NULL);
        GCBREG(newtransfercb, newtransfernotify, NULL);