Commit b11f24fd authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

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: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent abd06148
...@@ -533,6 +533,9 @@ int cr_check(void) ...@@ -533,6 +533,9 @@ int cr_check(void)
log_set_loglevel(LOG_WARN); log_set_loglevel(LOG_WARN);
if (!is_root_user())
return -1;
if (mntns_collect_root(getpid())) { if (mntns_collect_root(getpid())) {
pr_err("Can't collect root mount point\n"); pr_err("Can't collect root mount point\n");
return -1; return -1;
......
...@@ -272,6 +272,7 @@ extern void shfree_last(void *ptr); ...@@ -272,6 +272,7 @@ extern void shfree_last(void *ptr);
extern int run_scripts(char *action); extern int run_scripts(char *action);
extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]); 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) static inline bool dir_dots(struct dirent *de)
{ {
......
...@@ -571,3 +571,13 @@ out: ...@@ -571,3 +571,13 @@ out:
return ret; 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment