]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec: move mac_smack_apply_pid() and setup_pam() to same condition block 1357/head
authorSangjung Woo <sangjung.woo@samsung.com>
Wed, 23 Sep 2015 11:53:09 +0000 (20:53 +0900)
committerSangjung Woo <sangjung.woo@samsung.com>
Wed, 23 Sep 2015 13:11:38 +0000 (22:11 +0900)
This cleans up exec_child() function by moving mac_smack_apply_pid()
and setup_pam() to the same condition block, since both of them have
the same condition (i.e params->apply_permissions). It improves
readability without changing its operation.

src/core/execute.c

index eef2dacc54b850b0ce7b6e02fac663552f8fb092..a7e2362236d2c5e7628152efb45d1bc77c36cac2 100644 (file)
@@ -1582,18 +1582,15 @@ static int exec_child(
                 }
         }
 
+        umask(context->umask);
+
         if (params->apply_permissions) {
                 r = enforce_groups(context, username, gid);
                 if (r < 0) {
                         *exit_status = EXIT_GROUP;
                         return r;
                 }
-        }
-
-        umask(context->umask);
-
 #ifdef HAVE_SMACK
-        if (params->apply_permissions) {
                 if (context->smack_process_label) {
                         r = mac_smack_apply_pid(0, context->smack_process_label);
                         if (r < 0) {
@@ -1617,19 +1614,18 @@ static int exec_child(
                                 return r;
                         }
                 }
-        }
 #endif
 #endif
-
 #ifdef HAVE_PAM
-        if (params->apply_permissions && context->pam_name && username) {
-                r = setup_pam(context->pam_name, username, uid, context->tty_path, &pam_env, fds, n_fds);
-                if (r < 0) {
-                        *exit_status = EXIT_PAM;
-                        return r;
+                if (context->pam_name && username) {
+                        r = setup_pam(context->pam_name, username, uid, context->tty_path, &pam_env, fds, n_fds);
+                        if (r < 0) {
+                                *exit_status = EXIT_PAM;
+                                return r;
+                        }
                 }
-        }
 #endif
+        }
 
         if (context->private_network && runtime && runtime->netns_storage_socket[0] >= 0) {
                 r = setup_netns(runtime->netns_storage_socket);