Use XDG_RUNTIME_DIR for storing Xauthority

This commit is contained in:
Utkarsh Verma 2022-01-02 15:55:36 +05:30
parent 609b3f9ddc
commit 908ebf8964
No known key found for this signature in database
GPG Key ID: 817656CF818EFCCC
1 changed files with 8 additions and 16 deletions

View File

@ -304,10 +304,10 @@ void remove_utmp_entry(struct utmp *entry) {
endutent(); endutent();
} }
void xauth(const char* display_name, const char* shell, const char* dir) void xauth(const char* display_name, const char* shell)
{ {
char xauthority[256]; char xauthority[256];
snprintf(xauthority, 256, "%s/%s", dir, ".lyxauth"); snprintf(xauthority, 256, "%s/%s", getenv("XDG_RUNTIME_DIR"), "lyxauth");
setenv("XAUTHORITY", xauthority, 1); setenv("XAUTHORITY", xauthority, 1);
setenv("DISPLAY", display_name, 1); setenv("DISPLAY", display_name, 1);
@ -343,18 +343,10 @@ void xorg(
const char* vt, const char* vt,
const char* desktop_cmd) const char* desktop_cmd)
{ {
// generate xauthority file
const char* xauth_dir = getenv("XDG_CONFIG_HOME");
if ((xauth_dir == NULL) || (*xauth_dir == '\0'))
{
xauth_dir = pwd->pw_dir;
}
char display_name[4]; char display_name[4];
snprintf(display_name, 3, ":%d", get_free_display()); snprintf(display_name, 3, ":%d", get_free_display());
xauth(display_name, pwd->pw_shell, xauth_dir); xauth(display_name, pwd->pw_shell);
// start xorg // start xorg
pid_t pid = fork(); pid_t pid = fork();