mirror of
https://github.com/swaywm/sway.git
synced 2026-04-28 06:46:26 -04:00
Remove allowed shell check from swayrun
Because swayrun should be run from a safe environment, validating the user's shell against /etc/shells seems unnecessary.
This commit is contained in:
parent
f1d64f811d
commit
eb22dee79c
3 changed files with 5 additions and 44 deletions
|
|
@ -1,48 +1,16 @@
|
|||
#define _POSIX_C_SOURCE 200809L // for getline
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "stringop.h"
|
||||
|
||||
#define SWAY_COMMAND "sway"
|
||||
|
||||
char allowed_shell(char *shell) {
|
||||
FILE *fp;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
char allowed = false;
|
||||
|
||||
if (strstr(shell, "false") != NULL || strstr(shell, "nologin") != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fp = fopen("/etc/shells", "r");
|
||||
if (fp == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
while (getline(&line, &len, fp) != -1) {
|
||||
strip_whitespace(line);
|
||||
if (strcmp(shell, line) == 0) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
if (line) {
|
||||
free(line);
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char *shell = getenv("SHELL");
|
||||
|
||||
if (shell && allowed_shell(shell)) {
|
||||
if (shell) {
|
||||
// 3 exec arguments + argc + argv[argc] NULL pointer
|
||||
int exec_argc = 4 + argc;
|
||||
char **exec_argv = malloc(exec_argc * sizeof(char*));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue