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

List private rooms if valid admin_key was provided. #2161

Merged
merged 3 commits into from
May 20, 2020
Merged
Changes from 2 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
26 changes: 21 additions & 5 deletions plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -3546,16 +3546,32 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, rooms);
gboolean lock_room_list = TRUE;
if(admin_key != NULL) {
json_t *admin_key_json = json_object_get(root, "admin_key");
/* Verify admin_key if it was provided */
if(admin_key_json != NULL && strlen(json_string_value(admin_key_json)) > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also have a check on json_is_string(admin_key_json), as there's no guarantee admin_key is a string in the JSON (it's not part of the objects we use for validation in "list", since list requires no arguments).

JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause,
JANUS_VIDEOROOM_ERROR_MISSING_ELEMENT, JANUS_VIDEOROOM_ERROR_INVALID_ELEMENT, JANUS_VIDEOROOM_ERROR_UNAUTHORIZED);
if(error_code != 0) {
janus_mutex_unlock(&rooms_mutex);
goto prepare_response;
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put theelse on the same line as the closing bracket (only code style, sorry for the bother).

lock_room_list = FALSE;
}
}
}
while(g_hash_table_iter_next(&iter, NULL, &value)) {
janus_videoroom *room = value;
if(!room)
continue;
janus_refcount_increase(&room->ref);
if(room->is_private) {
/* Skip private room */
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name);
janus_refcount_decrease(&room->ref);
continue;
if(room->is_private && lock_room_list) {
/* Skip private room if no valid admin_key was provided */
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name);
janus_refcount_decrease(&room->ref);
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you added an extra tab for the lines above?

}
if(!g_atomic_int_get(&room->destroyed)) {
json_t *rl = json_object();
Expand Down