Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check return value of cap_set for success instead of single failure v… #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ void Workspace::drop_cap(cap_value_t cap_arg, int dbuid)
// cap_list[0] = CAP_DAC_OVERRIDE;
// cap_list[1] = CAP_CHOWN;

if (cap_set_flag(caps, CAP_PERMITTED, 1, cap_list, CAP_SET) == -1) {
if (cap_set_flag(caps, CAP_PERMITTED, 1, cap_list, CAP_SET) != 0) {
cerr << "Error: problem with capabilities." << endl;
}

if (cap_set_proc(caps) == -1) {
if (cap_set_proc(caps) != 0) {
cerr << "Error: problem dropping capabilities." << endl;
cap_t cap = cap_get_proc();
cerr << "Running with capabilities: " << cap_to_text(cap, NULL) << endl;
Expand Down Expand Up @@ -849,11 +849,11 @@ void Workspace::drop_cap(cap_value_t cap_arg1, cap_value_t cap_arg2, int dbuid)
// cap_list[0] = CAP_DAC_OVERRIDE;
// cap_list[1] = CAP_CHOWN;

if (cap_set_flag(caps, CAP_PERMITTED, 2, cap_list, CAP_SET) == -1) {
if (cap_set_flag(caps, CAP_PERMITTED, 2, cap_list, CAP_SET) != 0) {
cerr << "Error: problem with capabilities." << endl;
}

if (cap_set_proc(caps) == -1) {
if (cap_set_proc(caps) != 0) {
cerr << "Error: problem dropping capabilities." << endl;
cap_t cap = cap_get_proc();
cerr << "Running with capabilities: " << cap_to_text(cap, NULL) << endl;
Expand Down Expand Up @@ -882,11 +882,11 @@ void Workspace::lower_cap(int cap, int dbuid)
caps = cap_get_proc();

cap_list[0] = cap;
if (cap_set_flag(caps, CAP_EFFECTIVE, 1, cap_list, CAP_CLEAR) == -1) {
if (cap_set_flag(caps, CAP_EFFECTIVE, 1, cap_list, CAP_CLEAR) != 0) {
cerr << "Error: problem with capabilities." << endl;
}

if (cap_set_proc(caps) == -1) {
if (cap_set_proc(caps) != 0) {
cerr << "Error: problem lowering capabilities." << endl;
cap_t cap = cap_get_proc();
cerr << "Running with capabilities: " << cap_to_text(cap, NULL) << endl;
Expand Down Expand Up @@ -915,11 +915,11 @@ void Workspace::raise_cap(int cap)
caps = cap_get_proc();

cap_list[0] = cap;
if (cap_set_flag(caps, CAP_EFFECTIVE, 1, cap_list, CAP_SET) == -1) {
if (cap_set_flag(caps, CAP_EFFECTIVE, 1, cap_list, CAP_SET) != 0) {
cerr << "Error: problem with capabilities." << endl;
}

if (cap_set_proc(caps) == -1) {
if (cap_set_proc(caps) != 0) {
cerr << "Error: problem raising capabilities." << endl;
cap_t cap = cap_get_proc();
cerr << "Running with capabilities: " << cap_to_text(cap, NULL) << endl;
Expand Down