From 8bae4bbfdc26719c2233ad0f93ac826af24a8b60 Mon Sep 17 00:00:00 2001 From: hanez Date: Sun, 15 Nov 2026 09:07:25 +0100 Subject: [PATCH] Umask fix. --- README.md | 5 +++++ moerx.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ea4aeed..7e4e3a5 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,11 @@ option, restart the session server once so it understands the prefix setting. centred in its terminal, while a smaller client shows the top-left part. `Ctrl-A R` forces the session back to the current client's terminal size. - Panes run `$SHELL` as a login shell with `TERM=screen-256color`. + They inherit the launching process's umask, so builds keep their usual file + permissions. After upgrading from a version that forced `077`, restart the + session server to apply the fix. In an existing shell, `umask 022` restores + typical public file permissions for subsequent commands, including builds + published with `rsync -a`. - Window names show `hostname:program` for the foreground program in their active pane (for example `laptop:zsh` or `laptop:vim`), refreshed every second, including in inactive windows. When a program exits, the name diff --git a/moerx.c b/moerx.c index da40526..84101a8 100644 --- a/moerx.c +++ b/moerx.c @@ -3415,8 +3415,6 @@ static void server_start(const char *path, const char *name, int readyfd) { sigaction(SIGINT, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); - umask(077); - int lfd = socket(AF_UNIX, SOCK_STREAM, 0); if (lfd < 0) { server_fail(readyfd, "socket", errno); @@ -3427,10 +3425,15 @@ static void server_start(const char *path, const char *name, int readyfd) { saun.sun_family = AF_UNIX; snprintf(saun.sun_path, sizeof saun.sun_path, "%s", path); unlink(path); - if (bind(lfd, (struct sockaddr *)&saun, sizeof saun) < 0) { - int err = errno; + /* Protect the socket without imposing private file permissions on pane + shells and their build output (rsync -a preserves those permissions). */ + mode_t saved_umask = umask(077); + int bound = bind(lfd, (struct sockaddr *)&saun, sizeof saun); + int bind_err = errno; + umask(saved_umask); + if (bound < 0) { close(lfd); - server_fail(readyfd, "bind", err); + server_fail(readyfd, "bind", bind_err); _exit(1); } if (listen(lfd, 16) < 0) {