[hipl-commit] [trunk] Rev 4350: Merge both implementations of hip_set_lowcapability().

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 20 Apr 2010 13:38:46 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 20/04/2010 at 13:38:46
Revision: 4350
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Merge both implementations of hip_set_lowcapability().
  
  The #ifdefs are now inside the function so that at least the declaration
  and a few lines of code are shared.

Modified:
  M  lib/core/hip_capability.c

=== modified file 'lib/core/hip_capability.c'
--- lib/core/hip_capability.c   2010-04-20 10:32:14 +0000
+++ lib/core/hip_capability.c   2010-04-20 10:38:04 +0000
@@ -70,20 +70,22 @@
     return uid;
 }
 
+/**
+ * Lower the privileges of the currently running process.
+ *
+ * @param run_as_sudo 1 if the process was started with "sudo" or
+ *                    0 otherwise
+ * @return zero on success and negative on error
+ */
+int hip_set_lowcapability(int run_as_sudo)
+{
+    int err   = 0;
+    uid_t uid = -1;
+
 #ifdef CONFIG_HIP_ALTSEP
 
 #define LINUX_CAPABILITY_VERSION_HIPL  0x19980330
 
-/**
- * lower the privileges of the running process
- *
- * @param run_as_sudo
- * @return
- */
-int hip_set_lowcapability(int run_as_sudo)
-{
-    int err = 0;
-    uid_t uid;
     struct __user_cap_header_struct header;
     struct __user_cap_data_struct data;
 
@@ -132,22 +134,9 @@
               data.effective, data.permitted, data.inheritable);
 
 out_err:
-    return err;
-}
 
 #else /* ! ALTSEP */
 
-/**
- * Lower the privileges of the currently running process.
- *
- * @param run_as_sudo 1 if the process was started with "sudo" or
- *                    0 otherwise
- * @return zero on success and negative on error
- */
-int hip_set_lowcapability(int run_as_sudo)
-{
-    int err                = 0;
-    uid_t uid              = -1;
     cap_value_t cap_list[] = {CAP_NET_RAW, CAP_NET_ADMIN };
     int ncap_list          = 2;
     cap_t cap_p            = NULL;
@@ -214,7 +203,7 @@
 
 out_err:
     cap_free(cap_p);
-    return err;
-}
 
 #endif
+    return err;
+}

Other related posts:

  • » [hipl-commit] [trunk] Rev 4350: Merge both implementations of hip_set_lowcapability(). - Diego Biurrun