[hackers] [st] Applying the patch of Roberto Caballero to set WINDOWID and all the pwuid() || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Sun, 28 Oct 2012 13:39:04 +0100 (CET)

changeset: 368:8804f302e638
user: Christoph Lohmann <20h_AT_r-36.net>
date: Sun Oct 28 06:54:08 2012 +0100
files: st.c
description:
Applying the patch of Roberto Caballero to set WINDOWID and all the pwuid()
variables. Thanks! xinit() and ttynew() had to be switched in their
call-appearance. Otherwise xw.win is not set.


diff -r d61db297d6c1 -r 8804f302e638 st.c
--- a/st.c Sun Oct 28 06:32:54 2012 +0100
+++ b/st.c Sun Oct 28 06:54:08 2012 +0100
_AT_@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <locale.h>
+#include <pwd.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdio.h>
_AT_@ -881,11 +882,23 @@
 execsh(void) {
         char **args;
         char *envshell = getenv("SHELL");
+ const struct passwd *pass = getpwuid(getuid());
+ char buf[sizeof(long) * 8 + 1];
 
         unsetenv("COLUMNS");
         unsetenv("LINES");
         unsetenv("TERMCAP");
 
+ if(pass) {
+ setenv("LOGNAME", pass->pw_name, 1);
+ setenv("USER", pass->pw_name, 1);
+ setenv("SHELL", pass->pw_shell, 0);
+ setenv("HOME", pass->pw_dir, 0);
+ }
+
+ snprintf(buf, sizeof(buf), "%lu", xw.win);
+ setenv("WINDOWID", buf, 1);
+
         signal(SIGCHLD, SIG_DFL);
         signal(SIGHUP, SIG_DFL);
         signal(SIGINT, SIG_DFL);
_AT_@ -2795,8 +2808,8 @@
 run:
         setlocale(LC_CTYPE, "");
         tnew(80, 24);
+ xinit();
         ttynew();
- xinit();
         selinit();
         run();
         return 0;
Received on Sun Oct 28 2012 - 13:39:04 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 28 2012 - 13:48:25 CET