mirror of
https://github.com/javalsai/lidm.git
synced 2026-02-27 12:00:44 +01:00
fix: search Xorg binary in PATH
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
|
char* NULLABLE search_path(const char* NNULLABLE for_binary);
|
||||||
int execvpe_desktop(char** args, char* NNULLABLE* NNULLABLE envlist);
|
int execvpe_desktop(char** args, char* NNULLABLE* NNULLABLE envlist);
|
||||||
int parse_exec_string(const char* exec_s, int* arg_count, char*** args);
|
int parse_exec_string(const char* exec_s, int* arg_count, char*** args);
|
||||||
void free_parsed_args(int arg_count, char** args);
|
void free_parsed_args(int arg_count, char** args);
|
||||||
|
|||||||
35
src/auth.c
35
src/auth.c
@@ -23,9 +23,6 @@
|
|||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// no PATH search for now
|
|
||||||
#define XORG_COMMAND "/usr/bin/X"
|
|
||||||
|
|
||||||
#define XORG_MESSAGE_LENGTH 16
|
#define XORG_MESSAGE_LENGTH 16
|
||||||
|
|
||||||
static void try_source_file(struct Vector* NNULLABLE vec_envlist,
|
static void try_source_file(struct Vector* NNULLABLE vec_envlist,
|
||||||
@@ -139,16 +136,8 @@ static void push_dyn_arr(void*** arr, void* item) {
|
|||||||
|
|
||||||
// TODO: properly pass this down
|
// TODO: properly pass this down
|
||||||
extern int vt;
|
extern int vt;
|
||||||
// TODO: add error msgs
|
|
||||||
/// returns on completion
|
|
||||||
static void launch_with_xorg_server(struct session_exec* NNULLABLE exec,
|
|
||||||
struct passwd* pw,
|
|
||||||
char** NNULLABLE envlist) {
|
|
||||||
int xorg_pipefd[2];
|
|
||||||
if (pipe(xorg_pipefd) == -1) _exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
pid_t xorg_pid = fork();
|
static void start_xorg_server(struct passwd* pw, char** NNULLABLE envlist, int xorg_pipefd[2]) {
|
||||||
if (xorg_pid == 0) {
|
|
||||||
close(xorg_pipefd[0]);
|
close(xorg_pipefd[0]);
|
||||||
if (!pw->pw_dir) _exit(EXIT_FAILURE);
|
if (!pw->pw_dir) _exit(EXIT_FAILURE);
|
||||||
// !!!!!!!!!! ATTENTION: this fails silently, of course add failure msgs but
|
// !!!!!!!!!! ATTENTION: this fails silently, of course add failure msgs but
|
||||||
@@ -167,13 +156,33 @@ static void launch_with_xorg_server(struct session_exec* NNULLABLE exec,
|
|||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int exit = execle(XORG_COMMAND, XORG_COMMAND, "-displayfd", fd_str, vt_path,
|
char* xorg_path = search_path("Xorg");
|
||||||
|
if (!xorg_path) {
|
||||||
|
(void)fputs("couldn't find Xorg binary in PATH, sure it's installed?\n", stderr);
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int exit = execle(xorg_path, xorg_path, "-displayfd", fd_str, vt_path,
|
||||||
NULL, envlist);
|
NULL, envlist);
|
||||||
perror("exec");
|
perror("exec");
|
||||||
|
|
||||||
free(vt_path);
|
free(vt_path);
|
||||||
free(fd_str);
|
free(fd_str);
|
||||||
|
free(xorg_path);
|
||||||
_exit(exit);
|
_exit(exit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add error msgs
|
||||||
|
/// returns on completion
|
||||||
|
static void launch_with_xorg_server(struct session_exec* NNULLABLE exec,
|
||||||
|
struct passwd* pw,
|
||||||
|
char** NNULLABLE envlist) {
|
||||||
|
int xorg_pipefd[2];
|
||||||
|
if (pipe(xorg_pipefd) == -1) _exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
pid_t xorg_pid = fork();
|
||||||
|
if (xorg_pid == 0) {
|
||||||
|
start_xorg_server(pw, envlist, xorg_pipefd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int display = 0;
|
int display = 0;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
// returns NULL on any error
|
// returns NULL on any error
|
||||||
// otherwise it returns the absolute path of the program that MUST BE FREED
|
// otherwise it returns the absolute path of the program that MUST BE FREED
|
||||||
static char* NULLABLE search_path(const char* NNULLABLE for_binary) {
|
char* NULLABLE search_path(const char* NNULLABLE for_binary) {
|
||||||
if (strchr(for_binary, '/') != NULL) {
|
if (strchr(for_binary, '/') != NULL) {
|
||||||
// skip absolute paths
|
// skip absolute paths
|
||||||
return strdup(for_binary);
|
return strdup(for_binary);
|
||||||
|
|||||||
Reference in New Issue
Block a user