server: remove useless codes 36/170536/5
authorBoram Park <boram1288.park@samsung.com>
Tue, 16 Jan 2018 02:12:55 +0000 (11:12 +0900)
committerBoram Park <boram1288.park@samsung.com>
Wed, 21 Feb 2018 00:44:08 +0000 (09:44 +0900)
Change-Id: I09d265a0a5ab8eda71826f55ce9e4b23e1a25048

src/tdm_private.h
src/tdm_server.c

index ff8e244..30dfb81 100644 (file)
@@ -52,7 +52,6 @@
 #include <sys/syscall.h>
 #include <sys/eventfd.h>
 #include <math.h>
-#include <grp.h>
 
 #include <wayland-server-protocol.h>
 #include <tbm_bufmgr.h>
index 8fc2336..1bb5683 100644 (file)
@@ -808,136 +808,6 @@ _tdm_server_bind(struct wl_client *client, void *data,
        wl_resource_set_implementation(resource, &tdm_implementation, data, destroy_client);
 }
 
-static int
-_tdm_getgrnam_r(const char *name)
-{
-       struct group *grp = NULL;
-       struct group *grp_res = NULL;
-       char* buf = NULL;
-       size_t buf_len;
-       int ret;
-       int id;
-
-       buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
-       if (buf_len == -1)
-               buf_len = 2048;
-
-       buf = calloc(1, buf_len * sizeof(char));
-       if (!buf) {
-               TDM_ERR("creating buffer failed");
-               goto failed;
-       }
-
-       grp = calloc(1, sizeof(struct group));
-       if (!grp) {
-               TDM_ERR("creating group failed");
-               goto failed;
-       }
-
-       ret = getgrnam_r(name, grp, buf, buf_len, &grp_res);
-       if (ret < 0) {
-               TDM_ERR("getgrnam_r failed errno:%d(%m)", ret);
-               goto failed;
-       }
-
-       if (grp_res == NULL) {
-               TDM_ERR("finding name:%s group failed", name);
-               goto failed;
-       }
-
-       id = grp->gr_gid;
-       free(buf);
-       free(grp);
-
-       return id;
-
-failed:
-       /* LCOV_EXCL_START */
-
-       if (buf)
-               free(buf);
-       if (grp)
-               free(grp);
-
-       return -1;
-
-       /* LCOV_EXCL_STOP */
-}
-
-static void
-_tdm_socket_init(tdm_private_loop *private_loop)
-{
-       const char *dir = NULL;
-       char socket_path[TDM_NAME_LEN * 2];
-       int ret = -1, len;
-       uid_t uid;
-       gid_t gid;
-
-       dir = getenv("XDG_RUNTIME_DIR");
-       if (!dir) {
-               /* LCOV_EXCL_START */
-
-               TDM_WRN("getting XDG_RUNTIME_DIR failed");
-               return;
-
-               /* LCOV_EXCL_STOP */
-       }
-
-       len = strlen(dir);
-       if (len > TDM_NAME_LEN - 1) {
-               TDM_ERR("XDG_RUNTIME_DIR is too long\n");
-               return;
-       }
-
-       strncpy(socket_path, dir, TDM_NAME_LEN - 1);
-       socket_path[TDM_NAME_LEN - 1] = '\0';
-
-       strncat(socket_path, "/tdm-socket", 11);
-       socket_path[TDM_NAME_LEN + 10] = '\0';
-
-       ret = chmod(socket_path, 509);
-       if (ret < 0) {
-               /* LCOV_EXCL_START */
-
-               TDM_WRN("changing modes of socket file failed:%s (%m)", socket_path);
-               return;
-
-               /* LCOV_EXCL_STOP */
-       }
-
-       ret = _tdm_getgrnam_r("root");
-       if (ret < 0) {
-               /* LCOV_EXCL_START */
-
-               TDM_WRN("getting uid failed");
-               return;
-
-               /* LCOV_EXCL_STOP */
-       }
-       uid = ret;
-
-       ret = _tdm_getgrnam_r("display");
-       if (ret < 0) {
-               /* LCOV_EXCL_START */
-
-               TDM_WRN("getting gid failed");
-               return;
-
-               /* LCOV_EXCL_STOP */
-       }
-       gid = ret;
-
-       ret = chown(socket_path, uid, gid);
-       if (ret < 0) {
-               /* LCOV_EXCL_START */
-
-               TDM_WRN("changing owner of socket file failed:%s (%m)", socket_path);
-               return;
-
-               /* LCOV_EXCL_STOP */
-       }
-}
-
 INTERN tdm_error
 tdm_server_init(tdm_private_loop *private_loop)
 {
@@ -958,8 +828,6 @@ tdm_server_init(tdm_private_loop *private_loop)
                /* LCOV_EXCL_STOP */
        }
 
-       _tdm_socket_init(private_loop);
-
        private_server = calloc(1, sizeof * private_server);
        if (!private_server) {
                TDM_ERR("alloc failed");