criu check: don't run as non-root

In case criu check is run as non-root, a lot of information is printed
to a user, with the only missing bit is it should run it as root.

Fix it.

I still don't like the fact that some other stuff is printed here,
like the timestamp and the __FILE__:__LINE__, but this should be
fixed separately.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Kir Kolyshkin 2013-12-13 00:02:00 +04:00 committed by Pavel Emelyanov
parent abd061481b
commit b11f24fd5d
3 changed files with 14 additions and 0 deletions

View file

@ -533,6 +533,9 @@ int cr_check(void)
log_set_loglevel(LOG_WARN);
if (!is_root_user())
return -1;
if (mntns_collect_root(getpid())) {
pr_err("Can't collect root mount point\n");
return -1;

View file

@ -272,6 +272,7 @@ extern void shfree_last(void *ptr);
extern int run_scripts(char *action);
extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]);
extern int is_root_user(void);
static inline bool dir_dots(struct dirent *de)
{

10
util.c
View file

@ -571,3 +571,13 @@ out:
return ret;
}
int is_root_user()
{
if (geteuid() != 0) {
pr_err("You need to be root to run this command\n");
return 0;
}
return 1;
}