You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

277 lines
7.2 KiB

  1. --- ./src/logging.c.orig 2002-12-15 16:33:04.000000000 -0800
  2. +++ ./src/logging.c 2003-06-07 21:08:52.000000000 -0700
  3. @@ -60,157 +60,7 @@
  4. void
  5. rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname)
  6. {
  7. -#ifdef HAVE_STRUCT_UTMP
  8. - struct utmp *ut = &(r->h->ut);
  9. -#endif
  10. -#ifdef HAVE_STRUCT_UTMPX
  11. - struct utmpx *utx = &(r->h->utx);
  12. -#endif
  13. -#ifdef HAVE_UTMP_PID
  14. - int i;
  15. -#endif
  16. - char ut_id[5];
  17. - struct passwd *pwent = getpwuid(getuid());
  18. -
  19. - if (!STRNCMP(pty, "/dev/", 5))
  20. - pty += 5; /* skip /dev/ prefix */
  21. -
  22. - if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) {
  23. - STRNCPY(ut_id, (pty + 3), sizeof(ut_id));
  24. - }
  25. -#ifdef HAVE_UTMP_PID
  26. - else if (sscanf(pty, "pts/%d", &i) == 1)
  27. - sprintf(ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
  28. -#endif
  29. - else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) {
  30. - rxvt_print_error("can't parse tty name \"%s\"", pty);
  31. - return;
  32. - }
  33. -
  34. -#ifdef HAVE_STRUCT_UTMP
  35. - MEMSET(ut, 0, sizeof(struct utmp));
  36. -# ifdef HAVE_UTMP_PID
  37. - setutent();
  38. - STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
  39. - ut->ut_type = DEAD_PROCESS;
  40. - getutid(ut); /* position to entry in utmp file */
  41. - STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
  42. -# endif
  43. -#endif
  44. -
  45. -#ifdef HAVE_STRUCT_UTMPX
  46. - MEMSET(utx, 0, sizeof(struct utmpx));
  47. - setutxent();
  48. - STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
  49. - utx->ut_type = DEAD_PROCESS;
  50. - getutxid(utx); /* position to entry in utmp file */
  51. - STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
  52. -#endif
  53. -
  54. -#ifdef HAVE_STRUCT_UTMP
  55. - STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
  56. - ut->ut_time = time(NULL);
  57. -# ifdef HAVE_UTMP_PID
  58. - STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
  59. - sizeof(ut->ut_user));
  60. - STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
  61. - ut->ut_time = time(NULL);
  62. - ut->ut_pid = r->h->cmd_pid;
  63. -# ifdef HAVE_UTMP_HOST
  64. - STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
  65. -# endif
  66. - ut->ut_type = USER_PROCESS;
  67. - pututline(ut);
  68. - endutent(); /* close the file */
  69. - r->h->utmp_pos = -1;
  70. -# else
  71. - STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
  72. - sizeof(ut->ut_name));
  73. -# ifdef HAVE_UTMP_HOST
  74. - STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
  75. -# endif
  76. -# endif
  77. -#endif
  78. -
  79. -#ifdef HAVE_STRUCT_UTMPX
  80. - STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line));
  81. - STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
  82. - sizeof(utx->ut_user));
  83. - STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
  84. - utx->ut_session = getsid(0);
  85. - utx->ut_tv.tv_sec = time(NULL);
  86. - utx->ut_tv.tv_usec = 0;
  87. - utx->ut_pid = r->h->cmd_pid;
  88. -# ifdef HAVE_UTMPX_HOST
  89. - STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host));
  90. -# if 0
  91. - {
  92. - char *colon;
  93. -
  94. - if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
  95. - *colon = '\0';
  96. - }
  97. -# endif
  98. -# endif
  99. - utx->ut_type = USER_PROCESS;
  100. - pututxline(utx);
  101. - endutxent(); /* close the file */
  102. - r->h->utmp_pos = -1;
  103. -#endif
  104. -
  105. -#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
  106. - {
  107. - int i;
  108. -# ifdef HAVE_TTYSLOT
  109. - i = ttyslot();
  110. - if (rxvt_write_bsd_utmp(i, ut))
  111. - r->h->utmp_pos = i;
  112. -# else
  113. - FILE *fd0;
  114. -
  115. - if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
  116. - char buf[256], name[256];
  117. -
  118. - buf[sizeof(buf) - 1] = '\0';
  119. - for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
  120. - if (*buf == '#' || sscanf(buf, "%s", name) != 1)
  121. - continue;
  122. - if (!STRCMP(ut->ut_line, name)) {
  123. - if (!rxvt_write_bsd_utmp(i, ut))
  124. - i = 0;
  125. - r->h->utmp_pos = i;
  126. - fclose(fd0);
  127. - break;
  128. - }
  129. - i++;
  130. - }
  131. - fclose(fd0);
  132. - }
  133. -# endif
  134. - }
  135. -#endif
  136. -
  137. -#ifdef WTMP_SUPPORT
  138. -# ifdef WTMP_ONLY_ON_LOGIN
  139. - if (r->Options & Opt_loginShell)
  140. -# endif
  141. - {
  142. -# ifdef HAVE_STRUCT_UTMP
  143. -# ifdef HAVE_UPDWTMP
  144. - updwtmp(RXVT_WTMP_FILE, ut);
  145. -# else
  146. - rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
  147. -# endif
  148. -# endif
  149. -# ifdef HAVE_STRUCT_UTMPX
  150. - updwtmpx(RXVT_WTMPX_FILE, utx);
  151. -# endif
  152. - }
  153. -#endif
  154. -#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
  155. - if (r->Options & Opt_loginShell)
  156. - rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
  157. -#endif
  158. + addToUtmp(pty, NULL, r->cmd_fd);
  159. }
  160. /* ------------------------------------------------------------------------- */
  161. @@ -221,85 +71,7 @@
  162. void
  163. rxvt_cleanutent(rxvt_t *r)
  164. {
  165. -#ifdef HAVE_STRUCT_UTMP
  166. - struct utmp *tmput, *ut = &(r->h->ut);
  167. -#endif
  168. -#ifdef HAVE_STRUCT_UTMPX
  169. - struct utmpx *tmputx, *utx = &(r->h->utx);
  170. -#endif
  171. -
  172. -#ifdef HAVE_STRUCT_UTMP
  173. -# ifdef HAVE_UTMP_PID
  174. - MEMSET(ut, 0, sizeof(struct utmp));
  175. - setutent();
  176. - STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
  177. - ut->ut_type = USER_PROCESS;
  178. - if ((tmput = getutid(ut))) /* position to entry in utmp file */
  179. - ut = tmput;
  180. - ut->ut_type = DEAD_PROCESS;
  181. -# else
  182. - MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
  183. -# ifdef HAVE_UTMP_HOST
  184. - MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
  185. -# endif
  186. -# endif
  187. - ut->ut_time = time(NULL);
  188. -#endif
  189. -
  190. -#ifdef HAVE_STRUCT_UTMPX
  191. - MEMSET(utx, 0, sizeof(struct utmpx));
  192. - setutxent();
  193. - STRNCPY(utx->ut_id, r->h->ut_id, sizeof(utx->ut_id));
  194. - utx->ut_type = USER_PROCESS;
  195. - if ((tmputx = getutxid(utx))) /* position to entry in utmp file */
  196. - utx = tmputx;
  197. - utx->ut_type = DEAD_PROCESS;
  198. - utx->ut_session = getsid(0);
  199. - utx->ut_tv.tv_sec = time(NULL);
  200. - utx->ut_tv.tv_usec = 0;
  201. -#endif
  202. -
  203. - /*
  204. - * Write ending wtmp entry
  205. - */
  206. -#ifdef WTMP_SUPPORT
  207. -# ifdef WTMP_ONLY_ON_LOGIN
  208. - if (r->Options & Opt_loginShell)
  209. -# endif
  210. - {
  211. -# ifdef HAVE_STRUCT_UTMP
  212. -# ifdef HAVE_UPDWTMP
  213. - updwtmp(RXVT_WTMP_FILE, ut);
  214. -# else
  215. - rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
  216. -# endif
  217. -# endif
  218. -# ifdef HAVE_STRUCT_UTMPX
  219. - updwtmpx(RXVT_WTMPX_FILE, utx);
  220. -# endif
  221. - }
  222. -#endif
  223. -
  224. - /*
  225. - * Write utmp entry
  226. - */
  227. -#ifdef HAVE_STRUCT_UTMP
  228. -# ifdef HAVE_UTMP_PID
  229. - if (ut->ut_pid == r->h->cmd_pid)
  230. - pututline(ut);
  231. - endutent();
  232. -# else
  233. - if (r->h->utmp_pos > 0) {
  234. - MEMSET(ut, 0, sizeof(struct utmp));
  235. - rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
  236. - }
  237. -# endif
  238. -#endif
  239. -#ifdef HAVE_STRUCT_UTMPX
  240. - if (utx->ut_pid == r->h->cmd_pid)
  241. - pututxline(utx);
  242. - endutxent();
  243. -#endif
  244. + removeFromUtmp();
  245. }
  246. /* ------------------------------------------------------------------------- */
  247. --- ./src/init.c.orig 2002-12-03 21:21:39.000000000 -0800
  248. +++ ./src/init.c 2003-06-07 21:09:26.000000000 -0700
  249. @@ -858,6 +858,7 @@
  250. rxvt_print_error("aborting");
  251. exit(EXIT_FAILURE);
  252. }
  253. + rxvt_privileged_utmp(r, SAVE);
  254. }
  255. /*----------------------------------------------------------------------*/
  256. @@ -1364,7 +1365,6 @@
  257. #endif
  258. r->num_fds++; /* counts from 0 */
  259. - rxvt_privileged_utmp(r, SAVE);
  260. return cfd;
  261. }
  262. --- ./autoconf/Make.common.in.orig 2001-11-29 19:22:56.000000000 -0800
  263. +++ ./autoconf/Make.common.in 2003-06-07 21:08:52.000000000 -0700
  264. @@ -68,7 +68,7 @@
  265. LIBTOOL = @LIBTOOL@
  266. COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(DEBUG) $(DINCLUDE) $(XINC) -I$(basedir) -I$(srcdir) -I.
  267. -LINK = $(CC) $(CFLAGS) $(LDFLAGS)
  268. +LINK = $(CC) $(CFLAGS) $(LDFLAGS) -lutempter -lutil
  269. # End of common section of the Makefile
  270. #-------------------------------------------------------------------------