[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
66/118: nix-daemon: Show name of connecting user
From: |
Ludovic Courtès |
Subject: |
66/118: nix-daemon: Show name of connecting user |
Date: |
Tue, 19 May 2015 14:45:43 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit 0c730887c4ec4a03fb854490e422c134a1bf8139
Author: Eelco Dolstra <address@hidden>
Date: Thu Jul 17 15:49:33 2014 +0200
nix-daemon: Show name of connecting user
---
src/nix-daemon/nix-daemon.cc | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index f486806..fd030fe 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -17,6 +17,7 @@
#include <sys/un.h>
#include <fcntl.h>
#include <errno.h>
+#include <pwd.h>
using namespace nix;
@@ -855,23 +856,23 @@ static void daemonLoop()
closeOnExec(remote);
bool trusted = false;
-
pid_t clientPid = -1;
#if defined(SO_PEERCRED)
/* Get the identity of the caller, if possible. */
- uid_t clientUid = -1;
-
ucred cred;
socklen_t credLen = sizeof(cred);
if (getsockopt(remote, SOL_SOCKET, SO_PEERCRED, &cred, &credLen)
== -1)
throw SysError("getting peer credentials");
clientPid = cred.pid;
- clientUid = cred.uid;
- if (clientUid == 0) trusted = true;
- printMsg(lvlInfo, format("accepted connection from pid %1%, uid
%2%") % clientPid % clientUid);
+ struct passwd * pw = getpwuid(cred.uid);
+ string user = pw ? pw->pw_name : int2String(cred.uid);
+
+ if (cred.uid == 0) trusted = true;
+
+ printMsg(lvlInfo, format("accepted connection from pid %1%, user
%2%") % clientPid % user);
#endif
/* Fork a child to handle the connection. */
- 47/118: Replace message "importing path <...>" with "exporting path <...>", (continued)
- 47/118: Replace message "importing path <...>" with "exporting path <...>", Ludovic Courtès, 2015/05/19
- 37/118: Add a test for the SSH substituter, Ludovic Courtès, 2015/05/19
- 39/118: nix-copy-closure: Fix race condition, Ludovic Courtès, 2015/05/19
- 49/118: Allow $NIX_BUILD_HOOK to be relative to Nix libexec directory, Ludovic Courtès, 2015/05/19
- 52/118: Fix test, Ludovic Courtès, 2015/05/19
- 42/118: Refactoring: Move all fork handling into a higher-order function, Ludovic Courtès, 2015/05/19
- 41/118: nix-copy-closure: Restore compression and the progress viewer, Ludovic Courtès, 2015/05/19
- 54/118: build-remote.pl: Don't keep a shell process around, Ludovic Courtès, 2015/05/19
- 57/118: Manual: Typo, Ludovic Courtès, 2015/05/19
- 53/118: build-remote.pl: Fix build log, Ludovic Courtès, 2015/05/19
- 66/118: nix-daemon: Show name of connecting user,
Ludovic Courtès <=
- 58/118: Pass *_proxy vars to bootstrap fetchurl, Ludovic Courtès, 2015/05/19
- 56/118: Remove cruft, Ludovic Courtès, 2015/05/19
- 48/118: Fix broken Pid constructor, Ludovic Courtès, 2015/05/19
- 51/118: build-remote.pl: Use ‘nix-store --serve’ on the remote side, Ludovic Courtès, 2015/05/19
- 62/118: Be more strict about file names in NARs, Ludovic Courtès, 2015/05/19
- 65/118: nix-daemon: Only print connection info if we have SO_PEERCRED, Ludovic Courtès, 2015/05/19
- 72/118: Remove dead code, Ludovic Courtès, 2015/05/19
- 55/118: build-remote.pl: Fix building multiple output derivations, Ludovic Courtès, 2015/05/19
- 59/118: Install systemd and Upstart stuff only on Linux, Ludovic Courtès, 2015/05/19
- 68/118: Ugly hack to fix building on old Darwin, Ludovic Courtès, 2015/05/19