Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_con


Modified Files:
      Tag: SPLIT
        ecore_con.c 


Log Message:


local user sockets are now locked down permission-wise

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_con/Attic/ecore_con.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -3 -r1.1.2.9 -r1.1.2.10
--- ecore_con.c 8 Apr 2003 08:03:21 -0000       1.1.2.9
+++ ecore_con.c 8 Sep 2003 03:53:58 -0000       1.1.2.10
@@ -110,43 +110,79 @@
      {
        char *homedir;
        struct stat st;
+       mode_t pmode, mask;
        
        if (!name) goto error;
+       mask =
+         S_IRGRP | S_IWGRP | S_IXGRP |
+         S_IROTH | S_IWOTH | S_IXOTH;
        if (type == ECORE_CON_LOCAL_USER)
          {
-            mode_t mask;
-            
             homedir = getenv("HOME");
             if (!homedir) homedir = getenv("TMP");
             if (!homedir) homedir = "/tmp";
+            mask = S_IRUSR | S_IWUSR | S_IXUSR;
             snprintf(buf, sizeof(buf), "%s/.ecore", homedir);
-            mask = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP;
             if (stat(buf, &st) < 0) mkdir(buf, mask);
             snprintf(buf, sizeof(buf), "%s/.ecore/%s", homedir, name);
             if (stat(buf, &st) < 0) mkdir(buf, mask);
             snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, name, port);
+            mask =
+              S_IRGRP | S_IWGRP | S_IXGRP |
+              S_IROTH | S_IWOTH | S_IXOTH;
          }
        else if (type == ECORE_CON_LOCAL_SYSTEM)
          {
+            mask = 0;
             snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", name, port);
          }
+       pmode = umask(mask);
        svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (svr->fd < 0) goto error;
-       if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
-       if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
+       if (svr->fd < 0)
+         {
+            umask(pmode);
+            goto error;
+         }
+       if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
+         {
+            umask(pmode);           
+            goto error;
+         }
+       if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0)
+         {
+            umask(pmode);           
+            goto error;
+         }
        lin.l_onoff = 1;
        lin.l_linger = 100;
-       if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 
0) goto error;
+       if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 
0)
+         {
+            umask(pmode);           
+            goto error;
+         }
        socket_unix.sun_family = AF_UNIX;
        strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
-       if (bind(svr->fd, (struct sockaddr *)&socket_unix, 
LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0) goto error;
-       if (listen(svr->fd, 4096) < 0) goto error;
+       if (bind(svr->fd, (struct sockaddr *)&socket_unix, 
LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0)
+         {
+            umask(pmode);           
+            goto error;
+         }
+       if (listen(svr->fd, 4096) < 0)
+         {
+            umask(pmode);           
+            goto error;
+         }
        svr->path = strdup(buf);
-       if (!svr->path) goto error;
+       if (!svr->path)
+         {
+            umask(pmode);           
+            goto error;
+         }
        svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
                                                    ECORE_FD_READ,
                                                    _ecore_con_svr_handler, svr,
                                                    NULL, NULL);
+       umask(pmode);
        if (!svr->fd_handler) goto error;
      }
    else if (type == ECORE_CON_REMOTE_SYSTEM)




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to