aboutsummaryrefslogtreecommitdiff
path: root/src/nix/daemon.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-02-25 16:00:00 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-02-25 16:13:02 +0100
commitdf552ff53e68dff8ca360adbdbea214ece1d08ee (patch)
tree9ed3cb700377d4731b4c234ebec16efb0099c71a /src/nix/daemon.cc
parent14b38d0887f8a8d6b75039113eface57cfb19d06 (diff)
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
Diffstat (limited to 'src/nix/daemon.cc')
-rw-r--r--src/nix/daemon.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nix/daemon.cc b/src/nix/daemon.cc
index 6a40a0bd3..940923d3b 100644
--- a/src/nix/daemon.cc
+++ b/src/nix/daemon.cc
@@ -76,7 +76,7 @@ static void setSigChldAction(bool autoReap)
}
-bool matchUser(const string & user, const string & group, const Strings & users)
+bool matchUser(const std::string & user, const std::string & group, const Strings & users)
{
if (find(users.begin(), users.end(), "*") != users.end())
return true;
@@ -85,12 +85,12 @@ bool matchUser(const string & user, const string & group, const Strings & users)
return true;
for (auto & i : users)
- if (string(i, 0, 1) == "@") {
- if (group == string(i, 1)) return true;
+ if (i.substr(0, 1) == "@") {
+ if (group == i.substr(1)) return true;
struct group * gr = getgrnam(i.c_str() + 1);
if (!gr) continue;
for (char * * mem = gr->gr_mem; *mem; mem++)
- if (user == string(*mem)) return true;
+ if (user == std::string(*mem)) return true;
}
return false;
@@ -198,10 +198,10 @@ static void daemonLoop()
PeerInfo peer = getPeerInfo(remote.get());
struct passwd * pw = peer.uidKnown ? getpwuid(peer.uid) : 0;
- string user = pw ? pw->pw_name : std::to_string(peer.uid);
+ std::string user = pw ? pw->pw_name : std::to_string(peer.uid);
struct group * gr = peer.gidKnown ? getgrgid(peer.gid) : 0;
- string group = gr ? gr->gr_name : std::to_string(peer.gid);
+ std::string group = gr ? gr->gr_name : std::to_string(peer.gid);
Strings trustedUsers = settings.trustedUsers;
Strings allowedUsers = settings.allowedUsers;
@@ -212,7 +212,7 @@ static void daemonLoop()
if ((!trusted && !matchUser(user, group, allowedUsers)) || group == settings.buildUsersGroup)
throw Error("user '%1%' is not allowed to connect to the Nix daemon", user);
- printInfo(format((string) "accepted connection from pid %1%, user %2%" + (trusted ? " (trusted)" : ""))
+ printInfo(format((std::string) "accepted connection from pid %1%, user %2%" + (trusted ? " (trusted)" : ""))
% (peer.pidKnown ? std::to_string(peer.pid) : "<unknown>")
% (peer.uidKnown ? user : "<unknown>"));
@@ -234,7 +234,7 @@ static void daemonLoop()
// For debugging, stuff the pid into argv[1].
if (peer.pidKnown && savedArgv[1]) {
- string processName = std::to_string(peer.pid);
+ auto processName = std::to_string(peer.pid);
strncpy(savedArgv[1], processName.c_str(), strlen(savedArgv[1]));
}