]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - bindings.c
bindings: cleanup send_creds_clone_wrapper()
[mirror_lxcfs.git] / bindings.c
index e4a8d15b1d9f9778441935ea134dfc7e7ac71ebc..9adc60d6177f7723a0c8590030356bf0551b197f 100644 (file)
@@ -45,6 +45,7 @@
 #include <sys/sysinfo.h>
 #include <sys/vfs.h>
 
+#include "api_extensions.h"
 #include "bindings.h"
 #include "config.h"
 #include "cgroup_fuse.h"
@@ -300,18 +301,15 @@ static struct pidns_init_store *lookup_verify_initpid(struct stat *sb)
 
 static int send_creds_clone_wrapper(void *arg)
 {
-       struct ucred cred;
-       char v;
-       int sock = *(int *)arg;
-
-       /* we are the child */
-       cred.uid = 0;
-       cred.gid = 0;
-       cred.pid = 1;
-       v = '1';
-       if (send_creds(sock, &cred, v, true) != SEND_CREDS_OK)
-               return 1;
-       return 0;
+       int sock = PTR_TO_INT(arg);
+       char v = '1'; /* we are the child */
+       struct ucred cred = {
+           .uid = 0,
+           .gid = 0,
+           .pid = 1,
+       };
+
+       return send_creds(sock, &cred, v, true) != SEND_CREDS_OK;
 }
 
 /*
@@ -364,7 +362,7 @@ static void write_task_init_pid_exit(int sock, pid_t target)
        if (setns(fd, 0))
                log_exit("Failed to setns to pid namespace of process %d", target);
 
-       pid = lxcfs_clone(send_creds_clone_wrapper, &sock, 0);
+       pid = lxcfs_clone(send_creds_clone_wrapper, INT_TO_PTR(sock), 0);
        if (pid < 0)
                _exit(EXIT_FAILURE);
 
@@ -748,8 +746,12 @@ static void __attribute__((constructor)) lxcfs_init(void)
        pidfd = pidfd_open(pid, 0);
        if (pidfd >= 0 && pidfd_send_signal(pidfd, 0, NULL, 0) == 0) {
                can_use_pidfd = true;
-               lxcfs_error("Kernel supports pidfds");
+               fprintf(stderr, "Kernel supports pidfds\n");
        }
+
+       fprintf(stderr, "api_extensions:\n");
+       for (i = 0; i < nr_api_extensions; i++)
+               fprintf(stderr, "- %s\n", api_extensions[i]);
 }
 
 static void __attribute__((destructor)) lxcfs_exit(void)