summaryrefslogtreecommitdiff
path: root/src/remote.cc
diff options
context:
space:
mode:
authorTim Allen <screwtape@froup.com>2022-04-07 21:23:10 +1000
committerTim Allen <screwtape@froup.com>2022-04-07 21:23:10 +1000
commit9e6b678cf709986e3ee83d1354da577f7f436c47 (patch)
treef037dd6956debca59105195eea0c9a73bb504ffe /src/remote.cc
parenteae8ea8a548ef2bf9d02d542fe58b95dfce186a5 (diff)
Do all session name validation in session_path().
Diffstat (limited to 'src/remote.cc')
-rw-r--r--src/remote.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/remote.cc b/src/remote.cc
index e6992c20..7a8f0d02 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -605,8 +605,8 @@ const String& session_directory()
String session_path(StringView session)
{
- if (contains(session, '/'))
- throw runtime_error{"session names cannot have slashes"};
+ if (not all_of(session, is_identifier))
+ throw runtime_error{format("invalid session name: '{}'", session)};
return format("{}/{}", session_directory(), session);
}
@@ -848,9 +848,6 @@ private:
Server::Server(String session_name, bool is_daemon)
: m_session{std::move(session_name)}, m_is_daemon{is_daemon}
{
- if (not all_of(m_session, is_identifier))
- throw runtime_error{format("invalid session name: '{}'", m_session)};
-
int listen_sock = socket(AF_UNIX, SOCK_STREAM, 0);
fcntl(listen_sock, F_SETFD, FD_CLOEXEC);
sockaddr_un addr = session_addr(m_session);
@@ -885,9 +882,6 @@ Server::Server(String session_name, bool is_daemon)
bool Server::rename_session(StringView name)
{
- if (not all_of(name, is_identifier))
- throw runtime_error{format("invalid session name: '{}'", name)};
-
String old_socket_file = session_path(m_session);
String new_socket_file = session_path(name);