mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
security: add cr_fchown
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
df301b7eb7
commit
09c3f5d0c7
@ -8,5 +8,6 @@ extern int restrict_uid(unsigned int uid, unsigned int gid);
|
|||||||
extern bool may_dump(struct proc_status_creds *);
|
extern bool may_dump(struct proc_status_creds *);
|
||||||
extern bool may_restore(struct _CredsEntry *);
|
extern bool may_restore(struct _CredsEntry *);
|
||||||
extern bool cr_user_is_root(void);
|
extern bool cr_user_is_root(void);
|
||||||
|
extern int cr_fchown(int fd);
|
||||||
|
|
||||||
#endif /* __CR_SECURITY_H__ */
|
#endif /* __CR_SECURITY_H__ */
|
||||||
|
13
security.c
13
security.c
@ -169,3 +169,16 @@ bool may_restore(CredsEntry *creds)
|
|||||||
check_groups(creds->groups, creds->n_groups) &&
|
check_groups(creds->groups, creds->n_groups) &&
|
||||||
check_caps(creds->cap_inh, creds->cap_eff, creds->cap_prm);
|
check_caps(creds->cap_inh, creds->cap_eff, creds->cap_prm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cr_fchown(int fd)
|
||||||
|
{
|
||||||
|
if (cr_user_is_root())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (fchown(fd, cr_uid, cr_gid)) {
|
||||||
|
pr_perror("Can't chown to (%u,%u)", cr_uid, cr_gid);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user