criu/include/files-reg.h
Pavel Emelyanov 9a392dff3a reg-files: Do not try to linkat with wrong user
We link files to each other at restore time to restore
unlinked paths. Kernel has strange secutiry restrictions
about linkat we use. If the fsuid of the caller doesn't
equals the uid of the file and the file is not "safe"
one, then only global CAP_CHOWN will be allowed to link().

This brings problems in user namespaces -- uns root is
not allowed to linkat any file, unlike global root.

Fortunately, we can change the fsuid temporarily and
still linkat the file we want. Hopefully this hack will
go away some day soon, when the kernel will have saner
checks for linkat capabilities.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2015-02-13 16:11:38 +04:00

54 lines
1.4 KiB
C

#ifndef __CR_FILES_REG_H__
#define __CR_FILES_REG_H__
#include "asm/types.h"
#include "files.h"
#include "image.h"
#include "protobuf/regfile.pb-c.h"
#include "protobuf/ghost-file.pb-c.h"
struct cr_imgset;
struct fd_parms;
struct file_remap {
char *path;
bool is_dir;
int mnt_id;
unsigned int users;
uid_t owner;
};
struct reg_file_info {
struct file_desc d;
RegFileEntry *rfe;
struct file_remap *remap;
bool size_checked;
char *path;
};
extern int open_reg_by_id(u32 id);
extern int open_reg_fd(struct file_desc *);
extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd,
struct reg_file_info *, void *), void *arg);
extern void clear_ghost_files(void);
extern int prepare_shared_reg_files(void);
extern const struct fdtype_ops regfile_dump_ops;
extern int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *arg);
extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
extern struct file_remap *lookup_ghost_remap(u32 dev, u32 ino);
extern void remap_put(struct file_remap *remap);
extern struct file_desc *try_collect_special_file(u32 id, int optional);
#define collect_special_file(id) try_collect_special_file(id, 0)
extern struct collect_image_info reg_file_cinfo;
extern struct collect_image_info remap_cinfo;
extern void delete_link_remaps(void);
extern void free_link_remaps(void);
#endif /* __CR_FILES_REG_H__ */