Cookie executable path logic fixed and refactored.
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 13 May 2013 15:17:47 +0000 (17:17 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:09:36 +0000 (17:09 +0100)
[Issue#] SSDWSSP-237 / P130508-4841
[Bug] Security-server has closed unexpectedly
[Problem] N/A
[Cause] Executable paths were improperly compared and triggered pid reusage code
branch.
[Solution] Executable paths logic fixed and refactored.

[Verification] Run all security-server tests

Change-Id: I68219631378be17c980b52fa8995d9bc37d69ed7

src/server/security-server-cookie.c

index 315df0d..9bd4fc2 100644 (file)
@@ -145,23 +145,8 @@ cookie_list *search_existing_cookie(int pid, const cookie_list *c_list)
                        /* Check the path is different.  */
                        if(strcmp(exe, current->path) != 0)
                        {
-                               SEC_SVR_DBG("pid [%d] has been reused by %s. deleting the old cookie.", pid, exe);
-                               debug_cmdline = malloc(current->path_len + 1);
-                               if(debug_cmdline == NULL)
-                               {
-                                       SEC_SVR_ERR("%s", "out of memory error");
-                                       free(exe);
-                                       return NULL;
-                               }
-                               strncpy(debug_cmdline, current->path, current->path_len);
-                               debug_cmdline[current->path_len] = 0;
-                               SEC_SVR_DBG("[%s] --> [%s]", exe, debug_cmdline);
-                               if(debug_cmdline != NULL)
-                               {
-                                       free(debug_cmdline);
-                                       debug_cmdline = NULL;
-                               }
-                               /* Okay. delete current cookie */
+                               /* Delete cookie for reused pid. This is an extremely rare situation. */
+                               SEC_SVR_DBG("Pid [%d] for exec [%s] has been reused by [%s]. Deleting the old cookie.", pid, current->path, exe);
                                current = delete_cookie_item(current);
                        }
                        else
@@ -518,19 +503,8 @@ out_of_while:
         }
     }
 
-    /* Check SMACK label */
-    if (smack_check())
-    {
-        ret = smack_new_label_from_socket(sockfd, &smack_label);
-        if (ret < 0)
-        {
-            SEC_SVR_DBG("Error checking peer label: %d", ret);
-            free(added);
-            added = NULL;
-            goto error;
-        }
-    }
-
+       added->path = exe;
+       exe = NULL;
     added->permission_len = perm_num;
     added->pid = pid;
     added->permissions = permissions;