ignore chown & chmod errors 76/131576/1
authorBoram Park <boram1288.park@samsung.com>
Tue, 30 May 2017 05:31:43 +0000 (14:31 +0900)
committerBoram Park <boram1288.park@samsung.com>
Tue, 30 May 2017 05:32:17 +0000 (14:32 +0900)
Change-Id: I7eca721fdd7129973cb9d13e914b89ed43f0f531

src/tbm_drm_helper_server.c

index c60f479..7881d66 100644 (file)
@@ -197,7 +197,7 @@ failed:
        return -1;
 }
 
-static int
+static void
 _tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
 {
        const char *dir = NULL;
@@ -206,50 +206,39 @@ _tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
        uid_t uid;
        gid_t gid;
 
-       if (wl_display_add_socket(tbm_drm_auth_srv->display, "tbm-drm-auth")) {
-               TBM_LOG_E("createing a tdm-socket failed\n");
-               return 0;
-       }
-
        dir = getenv("XDG_RUNTIME_DIR");
        if (!dir) {
-               TBM_LOG_E("getting XDG_RUNTIME_DIR failed\n");
-               return 0;
+               TBM_LOG_W("getting XDG_RUNTIME_DIR failed\n");
+               return;
        }
 
        snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, "tbm-drm-auth");
 
        ret = chmod(socket_path, 509);
        if (ret < 0) {
-               TBM_LOG_E("changing modes of socket file failed:%s (%m)\n", socket_path);
-               return 0;
+               TBM_LOG_W("changing modes of socket file failed:%s (%m)\n", socket_path);
+               return;
        }
 
-       /* if not super user, we don't need to change owner and group */
-       if (getuid() != 0)
-               return 1;
-
        ret = _tbm_getgrnam_r("root");
        if (ret < 0) {
-               TBM_LOG_E("getting uid failed\n");
-               return 0;
+               TBM_LOG_W("getting uid failed\n");
+               return;
        }
        uid = ret;
 
        ret = _tbm_getgrnam_r("display");
        if (ret < 0) {
-               TBM_LOG_E("getting gid failed\n");
-               return 0;
+               TBM_LOG_W("getting gid failed\n");
+               return;
        }
        gid = ret;
 
        ret = chown(socket_path, uid, gid);
        if (ret < 0) {
-               TBM_LOG_E("changing owner of socket file failed:%s (%m)\n", socket_path);
-               return 0;
+               TBM_LOG_W("changing owner of socket file failed:%s (%m)\n", socket_path);
+               return;
        }
-
-       return 1;
 }
 
 int
@@ -266,8 +255,8 @@ tbm_drm_helper_wl_auth_server_init(void *wl_display,   int fd, const char *devic
                tbm_drm_auth_srv->fd = fd;
                tbm_drm_auth_srv->flags = flags;
 
-               if (!_tbm_drm_auth_socket_init(tbm_drm_auth_srv)) {
-                       TBM_LOG_E("[TBM_DRM] fail to _tbm_drm_auth_socket_init\n");
+               if (wl_display_add_socket(tbm_drm_auth_srv->display, "tbm-drm-auth")) {
+                       TBM_LOG_E("[TBM_DRM] fail to add socket\n");
 
                        if (tbm_drm_auth_srv->device_name)
                                free(tbm_drm_auth_srv->device_name);
@@ -278,6 +267,8 @@ tbm_drm_helper_wl_auth_server_init(void *wl_display,   int fd, const char *devic
                        return 0;
                }
 
+               _tbm_drm_auth_socket_init(tbm_drm_auth_srv);
+
                /* init the client resource list */
                tbm_drm_auth_srv->wl_tbm_drm_auth_global = wl_global_create(tbm_drm_auth_srv->display, &wl_tbm_drm_auth_interface, 1,
                                         tbm_drm_auth_srv, _wayland_tbm_drm_auth_server_bind_cb);