mirror of https://github.com/fairyglade/ly.git
Use XDG_RUNTIME_DIR for storing Xauthority
This commit is contained in:
parent
609b3f9ddc
commit
908ebf8964
24
src/login.c
24
src/login.c
|
@ -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();
|
||||||
|
@ -531,7 +523,7 @@ void auth(
|
||||||
if (pwd->pw_shell[0] == '\0')
|
if (pwd->pw_shell[0] == '\0')
|
||||||
{
|
{
|
||||||
setusershell();
|
setusershell();
|
||||||
|
|
||||||
char* shell = getusershell();
|
char* shell = getusershell();
|
||||||
|
|
||||||
if (shell != NULL)
|
if (shell != NULL)
|
||||||
|
@ -552,7 +544,7 @@ void auth(
|
||||||
|
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
{
|
{
|
||||||
// set user info
|
// set user info
|
||||||
ok = initgroups(pwd->pw_name, pwd->pw_gid);
|
ok = initgroups(pwd->pw_name, pwd->pw_gid);
|
||||||
|
|
||||||
if (ok != 0)
|
if (ok != 0)
|
||||||
|
@ -658,21 +650,21 @@ void auth(
|
||||||
|
|
||||||
// close pam session
|
// close pam session
|
||||||
ok = pam_do(pam_close_session, handle, 0, buf);
|
ok = pam_do(pam_close_session, handle, 0, buf);
|
||||||
|
|
||||||
if (ok != PAM_SUCCESS)
|
if (ok != PAM_SUCCESS)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = pam_do(pam_setcred, handle, PAM_DELETE_CRED, buf);
|
ok = pam_do(pam_setcred, handle, PAM_DELETE_CRED, buf);
|
||||||
|
|
||||||
if (ok != PAM_SUCCESS)
|
if (ok != PAM_SUCCESS)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = pam_end(handle, 0);
|
ok = pam_end(handle, 0);
|
||||||
|
|
||||||
if (ok != PAM_SUCCESS)
|
if (ok != PAM_SUCCESS)
|
||||||
{
|
{
|
||||||
pam_diagnose(ok, buf);
|
pam_diagnose(ok, buf);
|
||||||
|
|
Loading…
Reference in New Issue