diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-03-06 18:21:57 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-03-06 18:21:57 +0000 |
| commit | e4436e84dfa68119496032621e284588c621fa99 (patch) | |
| tree | eaf7569ef09ec6fb369aa599ea4d13acadd87833 /slave.c | |
| parent | sixel: CSI setters also write a reply to the client (diff) | |
| parent | wayland: remove debug logs (diff) | |
Merge branch 'csd'
This implements client side decorations and have been tested on GNOME
and Weston.
They also render correctly in KWin, but cannot be used to move or
resize the window. I believe this is a bug in KWin's handling of
sub-surfaces positioned outside the parent surface. Luckily, KWin uses
server side decorations.
This merge also contains a lot of bug fixes related to resizing and
rendering of sub-surfaces in general (i.e. the scrollback search box).
Diffstat (limited to 'slave.c')
| -rw-r--r-- | slave.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -1,7 +1,9 @@ #include "slave.h" #include <stdlib.h> +#include <stdio.h> #include <string.h> +#include <ctype.h> #include <unistd.h> #include <errno.h> #include <assert.h> @@ -16,6 +18,52 @@ #include "tokenize.h" +static bool +is_valid_shell(const char *shell) +{ + FILE *f = fopen("/etc/shells", "r"); + if (f == NULL) + goto err; + + char *_line = NULL; + size_t count = 0; + + while (true) { + errno = 0; + ssize_t ret = getline(&_line, &count, f); + + if (ret < 0) { + free(_line); + break; + } + + char *line = _line; + { + while (isspace(*line)) + line++; + if (line[0] != '\0') { + char *end = line + strlen(line) - 1; + while (isspace(*end)) + end--; + *(end + 1) = '\0'; + } + } + + if (line[0] == '#') + continue; + + if (strcmp(line, shell) == 0) { + fclose(f); + return true; + } + } + +err: + if (f != NULL) + fclose(f); + return false; +} + static void slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell) { @@ -145,6 +193,9 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv, shell_argv[count] = NULL; } + if (is_valid_shell(shell_argv[0])) + setenv("SHELL", shell_argv[0], 1); + slave_exec(ptmx, shell_argv, fork_pipe[1], login_shell); assert(false); break; |
