From: fredrik Date: Tue, 19 Jun 2007 02:49:41 +0000 (+0000) Subject: Create Unix socket with correct perms. X-Git-Tag: 0.4~6 X-Git-Url: http://git.dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=4cb04c42ed9d608b619c511ea7f6e966cc8cbecb Create Unix socket with correct perms. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1080 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/daemon/ui.c b/daemon/ui.c index 8e9b643..e4178eb 100644 --- a/daemon/ui.c +++ b/daemon/ui.c @@ -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);