Fix id file creation 59/266359/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 11 Nov 2021 03:49:01 +0000 (12:49 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 11 Nov 2021 06:43:02 +0000 (15:43 +0900)
The child process writes zero to the id file. When calling the aul_initialize(),
the process will write one to the id file.
This is to check the socket status of the running application.

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/launchpad/+/266359/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/266360/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/266361/

Change-Id: I0abe08650b60d4e97f039ffaa16a20c299054110
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/common/src/launchpad_common.c

index 17ab641..7bfd547 100644 (file)
@@ -1415,17 +1415,18 @@ int _verify_proc_caps(void)
 int _prepare_id_file(void)
 {
        char path[PATH_MAX];
-       int fd;
+       FILE* fp;
 
        snprintf(path, sizeof(path), "/run/aul/apps/%u/%d/%s",
                        getuid(), getpid(), getenv("AUL_APPID"));
-       fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0600);
-       if (fd < 0) {
-               _E("Failed to create %s. errno(%d)", path, errno);
+       fp = fopen(path, "w");
+       if (!fp) {
+               _E("fopen() is failed. path(%s), errno(%d)", path, errno);
                return -1;
        }
-       close(fd);
 
+       fprintf(fp, "0");
+       fclose(fp);
        return 0;
 }