Skip to content

Commit 24cc9c3

Browse files
authored
Merge pull request #201183 from Artturin/utempter
tmux: build with utempter
2 parents 841bcc7 + 2af8090 commit 24cc9c3

File tree

6 files changed

+48
-31
lines changed

6 files changed

+48
-31
lines changed

nixos/modules/programs/tmux.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ in {
178178
description = lib.mdDoc "List of plugins to install.";
179179
example = lib.literalExpression "[ pkgs.tmuxPlugins.nord ]";
180180
};
181+
182+
withUtempter = mkOption {
183+
description = lib.mdDoc ''
184+
Whether to enable libutempter for tmux.
185+
This is required so that tmux can write to /var/run/utmp (which can be queried with `who` to display currently connected user sessions).
186+
Note, this will add a guid wrapper for the group utmp!
187+
'';
188+
default = true;
189+
type = types.bool;
190+
};
181191
};
182192
};
183193

@@ -193,6 +203,15 @@ in {
193203
TMUX_TMPDIR = lib.optional cfg.secureSocket ''''${XDG_RUNTIME_DIR:-"/run/user/$(id -u)"}'';
194204
};
195205
};
206+
security.wrappers = mkIf cfg.withUtempter {
207+
utempter = {
208+
source = "${pkgs.libutempter}/lib/utempter/utempter";
209+
owner = "root";
210+
group = "utmp";
211+
setuid = false;
212+
setgid = true;
213+
};
214+
};
196215
};
197216

198217
imports = [

pkgs/development/libraries/libutempter/default.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ with lib;
44

55
stdenv.mkDerivation rec {
66
pname = "libutempter";
7-
version = "1.1.6";
7+
version = "1.2.1";
88

99
src = fetchurl {
10-
url = "mirror://ubuntu/pool/main/libu/libutempter/libutempter_${version}.orig.tar.bz2";
11-
sha256 = "15y3xbgznjxnfmix4xg3bwmqdvghdw7slbhazb0ybmyf65gmd65q";
10+
url = "http://ftp.altlinux.org/pub/people/ldv/utempter/libutempter-${version}.tar.gz";
11+
sha256 = "sha256-ln/vNy85HeUBhDrYdXDGz12r2WUfAPF4MJD7wSsqNMs=";
1212
};
1313

1414
buildInputs = [ glib ];
1515

1616
patches = [ ./exec_path.patch ];
1717

18+
patchFlags = [ "-p2" ];
19+
1820
prePatch = ''
1921
substituteInPlace Makefile --replace 2711 0711
2022
'';
@@ -27,6 +29,7 @@ stdenv.mkDerivation rec {
2729
];
2830

2931
meta = {
32+
homepage = "https://github.com/altlinux/libutempter";
3033
description = "Interface for terminal emulators such as screen and xterm to record user sessions to utmp and wtmp files";
3134
longDescription = ''
3235
The bundled utempter binary must be able to run as a user belonging to group utmp.

pkgs/development/libraries/libutempter/exec_path.patch

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
diff -ur libutempter-1.1.6/iface.c libutempter-1.1.6.patched/iface.c
2-
--- libutempter-1.1.6/iface.c 2010-11-04 18:14:53.000000000 +0100
3-
+++ libutempter-1.1.6.patched/iface.c 2018-06-06 15:09:11.417755549 +0200
4-
@@ -60,9 +60,9 @@
1+
diff --git a/libutempter/iface.c b/libutempter/iface.c
2+
index 37c74a8..6f44c9a 100644
3+
--- a/libutempter/iface.c
4+
+++ b/libutempter/iface.c
5+
@@ -43,7 +43,7 @@
6+
__result; }))
7+
#endif
8+
9+
-#define UTEMPTER_DEFAULT_PATHNAME LIBEXECDIR "/utempter/utempter"
10+
+#define UTEMPTER_DEFAULT_PATHNAME "utempter"
11+
12+
static const char *utempter_pathname;
13+
static int saved_fd = -1;
14+
@@ -57,8 +57,8 @@ do_child(int master_fd, const char *path, char *const *argv)
515
_exit(EXIT_FAILURE);
616
}
717

818
- execv(path, argv);
19+
- print_dbg("execv: %s", strerror(errno));
920
+ execvp(path, argv);
10-
#ifdef UTEMPTER_DEBUG
11-
- fprintf(stderr, "libutempter: execv: %s\n", strerror(errno));
12-
+ fprintf(stderr, "libutempter: execvp: %s\n", strerror(errno));
13-
#endif
21+
+ print_dbg("execvp: %s", strerror(errno));
1422

15-
while (EACCES == errno)
16-
@@ -79,7 +79,7 @@
23+
while (EACCES == errno) {
24+
/* try saved group ID */
25+
@@ -73,7 +73,7 @@ do_child(int master_fd, const char *path, char *const *argv)
1726
if (setgid(sgid))
1827
break;
1928

2029
- (void) execv(path, argv);
2130
+ (void) execvp(path, argv);
2231
break;
2332
}
24-
25-
Only in libutempter-1.1.6.patched: result

pkgs/tools/misc/tmux/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
, pkg-config
99
, withSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic, systemd
1010
, utf8proc
11+
, withUtempter ? stdenv.isLinux && !stdenv.hostPlatform.isMusl, libutempter
1112
}:
1213

1314
let
@@ -44,12 +45,14 @@ stdenv.mkDerivation rec {
4445
ncurses
4546
libevent
4647
] ++ lib.optionals withSystemd [ systemd ]
47-
++ lib.optionals stdenv.isDarwin [ utf8proc ];
48+
++ lib.optionals stdenv.isDarwin [ utf8proc ]
49+
++ lib.optionals withUtempter [ libutempter ];
4850

4951
configureFlags = [
5052
"--sysconfdir=/etc"
5153
"--localstatedir=/var"
5254
] ++ lib.optionals withSystemd [ "--enable-systemd" ]
55+
++ lib.optionals withUtempter [ "--enable-utempter" ]
5356
++ lib.optionals stdenv.isDarwin [ "--enable-utf8proc" ];
5457

5558
enableParallelBuilding = true;

pkgs/tools/networking/mosh/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ stdenv.mkDerivation rec {
2424
patches = [
2525
./ssh_path.patch
2626
./mosh-client_path.patch
27-
./utempter_path.patch
2827
# Fix build with bash-completion 2.10
2928
./bash_completion_datadir.patch
3029
];

pkgs/tools/networking/mosh/utempter_path.patch

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)