]> git.proxmox.com Git - mirror_lxc.git/commitdiff
tree-wide: log function called in userns_exec_1()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 3 Jun 2017 21:35:07 +0000 (23:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 3 Jun 2017 21:35:07 +0000 (23:35 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/bdev/bdev.c
src/lxc/bdev/lxcaufs.c
src/lxc/bdev/lxcbtrfs.c
src/lxc/bdev/lxcoverlay.c
src/lxc/cgroups/cgfs.c
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgmanager.c
src/lxc/conf.c
src/lxc/conf.h
src/lxc/lxccontainer.c
src/lxc/start.c

index 3526ed540fe1ce71e0764166fa96f596fafbe8ec..b1193f57aeab6e766aef6d7d2e9f341c7fb4893b 100644 (file)
@@ -437,7 +437,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
        data.orig = orig;
        data.new = new;
        if (am_unpriv())
-               ret = userns_exec_1(c0->lxc_conf, rsync_rootfs_wrapper, &data);
+               ret = userns_exec_1(c0->lxc_conf, rsync_rootfs_wrapper, &data, "rsync_rootfs_wrapper");
        else
                ret = rsync_rootfs(&data);
 
index 01529669e95d4db605a15eac4249934c46d8c417..fd5e97503cb9d60eb60ce03c9505376f9c0fd64f 100644 (file)
@@ -133,7 +133,8 @@ int aufs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
                rdata.src = odelta;
                rdata.dest = ndelta;
                if (am_unpriv())
-                       ret = userns_exec_1(conf, rsync_delta_wrapper, &rdata);
+                       ret = userns_exec_1(conf, rsync_delta_wrapper, &rdata,
+                                           "rsync_delta_wrapper");
                else
                        ret = rsync_delta(&rdata);
                if (ret) {
index 7879d718b62535a36be106dabf05feb9c3c917bb..74edc679304eba9f45ec97abbf067a1b2f953352 100644 (file)
@@ -398,7 +398,8 @@ int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
                        return btrfs_snapshot(orig->dest, new->dest);
                sdata.dest = new->dest;
                sdata.src = orig->dest;
-               return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata);
+               return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata,
+                                    "btrfs_snapshot_wrapper");
        }
 
        if (rmdir(new->dest) < 0 && errno != ENOENT) {
index e8d0f6d30baca2491d884d41774d99485dc3af26..65daed8dbb76434b315bc4b27c0b0f08ef5f8ae0 100644 (file)
@@ -750,7 +750,8 @@ static int ovl_do_rsync(struct bdev *orig, struct bdev *new, struct lxc_conf *co
        rdata.orig = orig;
        rdata.new = new;
        if (am_unpriv())
-               ret = userns_exec_1(conf, ovl_rsync_wrapper, &rdata);
+               ret = userns_exec_1(conf, ovl_rsync_wrapper, &rdata,
+                                   "ovl_rsync_wrapper");
        else
                ret = ovl_rsync(&rdata);
        if (ret)
index 3bfa5239780420d8d56db39049dbc08d772b9fc2..4528821eccb842570c96a7b5c1c6dc9565aca576 100644 (file)
@@ -1874,7 +1874,8 @@ static int create_or_remove_cgroup(bool do_remove,
                        return 0;
                if (recurse) {
                        if (conf && !lxc_list_empty(&conf->id_map))
-                               r = userns_exec_1(conf, rmdir_wrapper, buf);
+                               r = userns_exec_1(conf, rmdir_wrapper, buf,
+                                                 "rmdir_wrapper");
                        else
                                r = cgroup_rmdir(buf);
                } else
@@ -2616,7 +2617,8 @@ static bool do_cgfs_chown(char *cgroup_path, struct lxc_conf *conf)
        /* Unpriv users can't chown it themselves, so chown from
         * a child namespace mapping both our own and the target uid
         */
-       if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
+       if (userns_exec_1(conf, chown_cgroup_wrapper, &data,
+                         "chown_cgroup_wrapper") < 0) {
                ERROR("Error requesting cgroup chown in new namespace");
                return false;
        }
index 7c627229ec4fc63459536dd515923e2a5a376e81..fd71c106d0c5b9631d1fd9d941549588de8eee86 100644 (file)
@@ -1284,7 +1284,7 @@ void recursive_destroy(char *path, struct lxc_conf *conf)
 {
        int r;
        if (conf && !lxc_list_empty(&conf->id_map))
-               r = userns_exec_1(conf, rmdir_wrapper, path);
+               r = userns_exec_1(conf, rmdir_wrapper, path, "rmdir_wrapper");
        else
                r = cgroup_rmdir(path);
 
@@ -1507,7 +1507,8 @@ static bool cgfsns_chown(void *hdata, struct lxc_conf *conf)
        wrap.d = d;
        wrap.origuid = geteuid();
 
-       if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap) < 0) {
+       if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap,
+                         "chown_cgroup_wrapper") < 0) {
                ERROR("Error requesting cgroup chown in new namespace");
                return false;
        }
index f2756b07fbe2cc5ce06e5d043b5881b9d02bdb95..6917d3c05c267e32ec22e195d6aec6ef5ad05b8c 100644 (file)
@@ -497,7 +497,8 @@ static bool chown_cgroup(const char *cgroup_path, struct lxc_conf *conf)
        /* Unpriv users can't chown it themselves, so chown from
         * a child namespace mapping both our own and the target uid
         */
-       if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
+       if (userns_exec_1(conf, chown_cgroup_wrapper, &data,
+                         "chown_cgroup_wrapper") < 0) {
                ERROR("Error requesting cgroup chown in new namespace");
                return false;
        }
index f5357d51bf6261b43267357fefccfd4723725a1e..2490e5cf6a68ec60a834d50282020dc8d1a8944f 100644 (file)
@@ -4669,6 +4669,7 @@ void lxc_conf_free(struct lxc_conf *conf)
 
 struct userns_fn_data {
        int (*fn)(void *);
+       const char *fn_name;
        void *arg;
        int p[2];
 };
@@ -4690,6 +4691,8 @@ static int run_userns_fn(void *data)
        /* Close read end of the pipe. */
        close(d->p[0]);
 
+       if (d->fn_name)
+               TRACE("calling function \"%s\"", d->fn_name);
        /* Call function to run. */
        return d->fn(d->arg);
 }
@@ -4767,7 +4770,8 @@ static struct id_map *idmap_add(struct lxc_conf *conf, uid_t id, enum idtype typ
  * retrieve from the ontainer's configured {g,u}id mappings as it must have been
  * there to start the container in the first place.
  */
-int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data)
+int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
+                 const char *fn_name)
 {
        pid_t pid;
        uid_t euid, egid;
@@ -4787,6 +4791,7 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data)
                return -1;
        }
        d.fn = fn;
+       d.fn_name = fn_name;
        d.arg = data;
        d.p[0] = p[0];
        d.p[1] = p[1];
index 9033a1a53845f75db14d0a7541b4c9db45e24c40..d8d5a6aeafd413b7d23526299b8c6944bf514da4 100644 (file)
@@ -473,7 +473,8 @@ extern int find_unmapped_nsid(struct lxc_conf *conf, enum idtype idtype);
 extern int mapped_hostid(unsigned id, struct lxc_conf *conf, enum idtype idtype);
 extern int chown_mapped_root(char *path, struct lxc_conf *conf);
 extern int ttys_shift_ids(struct lxc_conf *c);
-extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data);
+extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
+                        const char *fn_name);
 extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
                         char **mntdata);
 extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
index f93fdfc9536daae06bcff155a36315ad13e9cfc0..ebed82bc1a34ac0545799451b30ba62d801d73ee 100644 (file)
@@ -2339,7 +2339,8 @@ static bool has_snapshots(struct lxc_container *c)
 
 static bool do_destroy_container(struct lxc_conf *conf) {
        if (am_unpriv()) {
-               if (userns_exec_1(conf, bdev_destroy_wrapper, conf) < 0)
+               if (userns_exec_1(conf, bdev_destroy_wrapper, conf,
+                                 "bdev_destroy_wrapper") < 0)
                        return false;
                return true;
        }
@@ -2421,7 +2422,8 @@ static bool container_destroy(struct lxc_container *c)
        char *path = alloca(strlen(p1) + strlen(c->name) + 2);
        sprintf(path, "%s/%s", p1, c->name);
        if (am_unpriv())
-               ret = userns_exec_1(conf, lxc_rmdir_onedev_wrapper, path);
+               ret = userns_exec_1(conf, lxc_rmdir_onedev_wrapper, path,
+                                   "lxc_rmdir_onedev_wrapper");
        else
                ret = lxc_rmdir_onedev(path, "snaps");
        if (ret < 0) {
@@ -3230,7 +3232,7 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
        data.hookargs = hookargs;
        if (am_unpriv())
                ret = userns_exec_1(c->lxc_conf, clone_update_rootfs_wrapper,
-                               &data);
+                                   &data, "clone_update_rootfs_wrapper");
        else
                ret = clone_update_rootfs(&data);
        if (ret < 0)
index 36f8b231882556a79f897c37979ed52831d84184..6d932038d4454bc70d6771b133d20c24388d2f68 100644 (file)
@@ -1541,7 +1541,8 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
        }
 
        if (am_unpriv())
-               ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper, destroy);
+               ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper,
+                                   destroy, "lxc_rmdir_onedev_wrapper");
        else
                ret = lxc_rmdir_onedev(destroy, NULL);
 
@@ -1560,7 +1561,8 @@ static int lxc_rmdir_onedev_wrapper(void *data)
 
 static bool do_destroy_container(struct lxc_conf *conf) {
        if (am_unpriv()) {
-               if (userns_exec_1(conf, bdev_destroy_wrapper, conf) < 0)
+               if (userns_exec_1(conf, bdev_destroy_wrapper, conf,
+                                 "bdev_destroy_wrapper") < 0)
                        return false;
                return true;
        }