eina: add the last fallback runtime directory as /tmp 13/189713/5 accepted/tizen/unified/20180921.042445 submit/tizen/20180920.084839 submit/tizen/20180920.105841
authorYoungbok Shin <youngb.shin@samsung.com>
Thu, 20 Sep 2018 04:32:59 +0000 (13:32 +0900)
committerHermet Park <hermetpark@gmail.com>
Thu, 20 Sep 2018 08:35:20 +0000 (17:35 +0900)
When XDG_RUNTIME_DIR environment value is empty,
Eina Vpath tries to use fallback runtime dir by calling _fallback_runtime_dir with "home".
But, that "home" path is not allowed for using runtime dir in Tizen.
So, we are going to add one more fallback directory as "/tmp" which is allowed in Tizen.

@tizen_fix

Change-Id: Ib57e2976d919bfe2a9a4babaa3e8c4626aaa2f8f

src/lib/eina/eina_vpath.c

index b1b6af5..a5da2f1 100644 (file)
@@ -45,12 +45,15 @@ _eina_vpath_data_get(const char *key)
 static char *
 _fallback_runtime_dir(const char *home)
 {
+  static int recursive_fail = 0;   // TIZEN_ONLY(20180920)
+
    char buf[PATH_MAX];
 #if defined(HAVE_GETUID)
    uid_t uid = getuid();
 #endif
    struct stat st;
 
+
 #if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
    if (setuid(geteuid()) != 0)
       {
@@ -75,7 +78,8 @@ _fallback_runtime_dir(const char *home)
                        fprintf(stderr,
                                "FATAL: run dir '%s' exists but not a dir\n",
                                buf);
-                       abort();
+                       /* TIZEN_ONLY(20180920): add the last fallback runtime directory as /tmp instead of abort(); */
+                       goto tizen_fail;
                     }
 #if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
                   if (st.st_uid != geteuid())
@@ -84,7 +88,8 @@ _fallback_runtime_dir(const char *home)
                        fprintf(stderr,
                                "FATAL: run dir '%s' not owned by uid %i\n",
                                buf, (int)geteuid());
-                       abort();
+                       /* TIZEN_ONLY(20180920): add the last fallback runtime directory as /tmp instead of abort(); */
+                       goto tizen_fail;
                     }
 #endif
                }
@@ -94,7 +99,8 @@ _fallback_runtime_dir(const char *home)
                   fprintf(stderr,
                           "FATAL: Cannot verify run dir '%s' errno=%i\n",
                           buf, errno);
-                  abort();
+                  /* TIZEN_ONLY(20180920): add the last fallback runtime directory as /tmp instead of abort(); */
+                  goto tizen_fail;
                }
           }
         else
@@ -103,7 +109,8 @@ _fallback_runtime_dir(const char *home)
              fprintf(stderr,
                      "FATAL: Cannot create run dir '%s' - errno=%i\n",
                      buf, errno);
-             abort();
+             /* TIZEN_ONLY(20180920): add the last fallback runtime directory as /tmp instead of abort(); */
+             goto tizen_fail;
           }
      }
 #if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
@@ -116,9 +123,18 @@ _fallback_runtime_dir(const char *home)
      }
 #endif
 
-   return strdup(buf);
-}
+  recursive_fail = 0;
+
+  return strdup(buf);
 
+tizen_fail:
+   if (!recursive_fail)
+     {
+        recursive_fail = 1;
+        return _fallback_runtime_dir(_eina_vpath_data_get("tmp"));
+     }
+   return NULL;
+}
 static char *
 _fallback_home_dir()
 {