Don't call cap_set_proc() unless we were started with elevated

privileges.  Otherwise, we might print

dumpcap: cap_set_proc() fail return: Operation not permitted

to stderr.

svn path=/trunk/; revision=24704
This commit is contained in:
Gerald Combs 2008-03-20 19:18:33 +00:00
parent d4ba88b677
commit c288c1ae05
1 changed files with 8 additions and 5 deletions

View File

@ -508,12 +508,15 @@ relinquish_privs_except_capture(void)
relinquish_special_privs_perm();
print_caps("Post drop, pre set");
cap_set_flag(caps, CAP_EFFECTIVE, cl_len, cap_list, CAP_SET);
if (cap_set_proc(caps)) {
cmdarg_err("cap_set_proc() fail return: %s", strerror(errno));
if (started_with_special_privs()) {
print_caps("Post drop, pre set");
cap_set_flag(caps, CAP_EFFECTIVE, cl_len, cap_list, CAP_SET);
if (cap_set_proc(caps)) {
cmdarg_err("cap_set_proc() fail return: %s", strerror(errno));
}
print_caps("Post drop, post set");
}
print_caps("Post drop, post set");
cap_free(caps);
}
#endif /* HAVE_LIBCAP */