Commit 38150048 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

kerndat: do not report error on loginuid feature test

Fix for commit 0ce8e429 ("kerndat: do not report errors on feature
test").
That commit hid error messages for feature testing when you cannot
write to /proc/*/loginuid files because of missing kernel patch that
allows unsetting loginuid value on older kernels, but it didn't hide
error messages in case of disabled CONFIG_AUDITSYSCALL - then you
don't have loginuid files.
Also fixed comment for kerndat feature test: procfs file might fail
to open if it's missing and that's fine - !CONFIG_AUDITSYSCALL case,
but it can't fail due permission fault on _read_ (then something is
wrong, lets report a problem).
Reported-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 46cf4edb
...@@ -329,7 +329,7 @@ static int dump_pid_misc(pid_t pid, TaskCoreEntry *tc) ...@@ -329,7 +329,7 @@ static int dump_pid_misc(pid_t pid, TaskCoreEntry *tc)
pr_info("dumping /proc/%d/loginuid\n", pid); pr_info("dumping /proc/%d/loginuid\n", pid);
tc->has_loginuid = true; tc->has_loginuid = true;
tc->loginuid = parse_pid_loginuid(pid, &ret); tc->loginuid = parse_pid_loginuid(pid, &ret, false);
tc->loginuid = userns_uid(tc->loginuid); tc->loginuid = userns_uid(tc->loginuid);
/* /*
* loginuid dumping is critical, as if not correctly * loginuid dumping is critical, as if not correctly
......
...@@ -1866,7 +1866,7 @@ static int prepare_userns_hook(void) ...@@ -1866,7 +1866,7 @@ static int prepare_userns_hook(void)
* inside container due to permissions. * inside container due to permissions.
* But you still can set this value if it was unset. * But you still can set this value if it was unset.
*/ */
saved_loginuid = parse_pid_loginuid(getpid(), &ret); saved_loginuid = parse_pid_loginuid(getpid(), &ret, false);
if (ret < 0) if (ret < 0)
return -1; return -1;
......
...@@ -125,7 +125,7 @@ struct vm_area_list; ...@@ -125,7 +125,7 @@ struct vm_area_list;
extern bool add_skip_mount(const char *mountpoint); extern bool add_skip_mount(const char *mountpoint);
extern struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump); extern struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump);
extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s); extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s);
extern unsigned int parse_pid_loginuid(pid_t pid, int *err); extern unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent);
extern int parse_pid_oom_score_adj(pid_t pid, int *err); extern int parse_pid_oom_score_adj(pid_t pid, int *err);
extern int prepare_loginuid(unsigned int value, unsigned int loglevel); extern int prepare_loginuid(unsigned int value, unsigned int loglevel);
extern int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list); extern int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list);
......
...@@ -465,8 +465,8 @@ int kerndat_loginuid(bool only_dump) ...@@ -465,8 +465,8 @@ int kerndat_loginuid(bool only_dump)
kdat.has_loginuid = false; kdat.has_loginuid = false;
/* No such file, or perm fault: CONFIG_AUDITSYSCALL disabled */ /* No such file: CONFIG_AUDITSYSCALL disabled */
saved_loginuid = parse_pid_loginuid(getpid(), &ret); saved_loginuid = parse_pid_loginuid(getpid(), &ret, true);
if (ret < 0) if (ret < 0)
return 0; return 0;
......
...@@ -830,13 +830,14 @@ int prepare_loginuid(unsigned int value, unsigned int loglevel) ...@@ -830,13 +830,14 @@ int prepare_loginuid(unsigned int value, unsigned int loglevel)
return ret; return ret;
} }
unsigned int parse_pid_loginuid(pid_t pid, int *err) unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent)
{ {
int fd; int fd;
ssize_t num; ssize_t num;
*err = 0; *err = 0;
fd = open_proc(pid, "loginuid"); fd = __open_proc(pid, (ignore_noent) ? ENOENT : 0,
O_RDONLY, "loginuid");
if (fd < 0) if (fd < 0)
goto out; goto out;
......
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