mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-18 15:49:56 +00:00
clean up formatting and conformance to code guidelines
revert Mark's change that caused a memory leak (cap_set_proc() does not free the capability structure so we always need to call cap_free()) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44152 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2521,7 +2521,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!is_child_of_nonroot && runuser) {
|
if (!is_child_of_nonroot && runuser) {
|
||||||
#ifdef HAVE_CAP
|
#ifdef HAVE_CAP
|
||||||
cap_t cap;
|
|
||||||
int has_cap = 1;
|
int has_cap = 1;
|
||||||
#endif /* HAVE_CAP */
|
#endif /* HAVE_CAP */
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -2533,7 +2532,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef HAVE_CAP
|
#ifdef HAVE_CAP
|
||||||
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
|
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
|
||||||
ast_log(LOG_WARNING, "Unable to keep capabilities.\n");
|
ast_log(LOG_WARNING, "Unable to keep capabilities.\n");
|
||||||
has_cap = 0;
|
has_cap = 0;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CAP */
|
#endif /* HAVE_CAP */
|
||||||
if (!rungroup) {
|
if (!rungroup) {
|
||||||
@@ -2555,12 +2554,15 @@ int main(int argc, char *argv[])
|
|||||||
ast_verbose("Running as user '%s'\n", runuser);
|
ast_verbose("Running as user '%s'\n", runuser);
|
||||||
#ifdef HAVE_CAP
|
#ifdef HAVE_CAP
|
||||||
if (has_cap) {
|
if (has_cap) {
|
||||||
|
cap_t cap;
|
||||||
|
|
||||||
cap = cap_from_text("cap_net_admin=ep");
|
cap = cap_from_text("cap_net_admin=ep");
|
||||||
if (cap_set_proc(cap)) {
|
|
||||||
|
if (cap_set_proc(cap))
|
||||||
ast_log(LOG_WARNING, "Unable to install capabilities.\n");
|
ast_log(LOG_WARNING, "Unable to install capabilities.\n");
|
||||||
} else if (cap_free(cap)) {
|
|
||||||
|
if (cap_free(cap))
|
||||||
ast_log(LOG_WARNING, "Unable to drop capabilities.\n");
|
ast_log(LOG_WARNING, "Unable to drop capabilities.\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CAP */
|
#endif /* HAVE_CAP */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user