Skip to content

Commit

Permalink
scgi: bake in secure default socket permission
Browse files Browse the repository at this point in the history
  • Loading branch information
jesec committed Jan 23, 2021
1 parent 1c4f017 commit b391b3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion doc/rtorrent.rc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ network.http.dns_cache_timeout.set = 25

# XML-RPC interface
network.scgi.open_local = (cat,(cfg.basedir),rtorrent.sock)
execute.nothrow = chmod,770,(cat,(cfg.basedir),rtorrent.sock)

# Logging:
# Levels = critical error warn notice info debug
Expand Down
5 changes: 5 additions & 0 deletions src/rpc/scgi.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2005-2011, Jari Sundell <[email protected]>

#include <sys/stat.h>
#include <sys/un.h>

#include <torrent/connection_manager.h>
#include <torrent/exceptions.h>
#include <torrent/poll.h>
Expand Down Expand Up @@ -66,6 +68,9 @@ SCgi::open_named(const std::string& filename) {
if (!get_fd().open_local())
throw torrent::resource_error("Could not open socket for listening.");

// 700 permission by default
fchmod(get_fd().get_fd(), S_IRWXU);

open(sa, offsetof(struct sockaddr_un, sun_path) + filename.size() + 1);
m_path = filename;
}
Expand Down

0 comments on commit b391b3f

Please sign in to comment.