1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

DtTerm: Add libutempter support for utmp/wtmp updates.

This commit is contained in:
Liang Chang 2021-04-25 00:06:33 +08:00 committed by Jon Trulson
parent 3c4e5b3124
commit 8f52a65638
4 changed files with 31 additions and 3 deletions

View file

@ -53,7 +53,6 @@ TERMPRIM_OBJS = \
TermPrim/TermPrimScroll.o \ TermPrim/TermPrimScroll.o \
TermPrim/TermPrimSelect.o \ TermPrim/TermPrimSelect.o \
TermPrim/TermPrimSetPty.o \ TermPrim/TermPrimSetPty.o \
TermPrim/TermPrimSetUtmp.o \
TermPrim/TermPrimSubproc.o \ TermPrim/TermPrimSubproc.o \
TermPrim/TermPrimUtil.o \ TermPrim/TermPrimUtil.o \
TermPrim/TermPrimVersion.o \ TermPrim/TermPrimVersion.o \
@ -78,6 +77,12 @@ TERMVIEW_OBJS = \
TermView/TermViewGlobalDialog.o \ TermView/TermViewGlobalDialog.o \
TermView/TermViewTerminalDialog.o TermView/TermViewTerminalDialog.o
#if defined(HasUtempterLibrary) && HasUtempterLibrary
REQUIREDLIBS += -lutempter
#else
TERMPRIM_OBJS += TermPrim/TermPrimSetUtmp.o
#endif
OBJS = \ OBJS = \
$(TERMPRIM_OBJS) \ $(TERMPRIM_OBJS) \
$(TERM_OBJS) \ $(TERM_OBJS) \

View file

@ -40,7 +40,6 @@ SRCS = \
TermPrimScroll.c \ TermPrimScroll.c \
TermPrimSelect.c \ TermPrimSelect.c \
TermPrimSetPty.c \ TermPrimSetPty.c \
TermPrimSetUtmp.c \
TermPrimSubproc.c \ TermPrimSubproc.c \
TermPrimUtil.c \ TermPrimUtil.c \
TermPrimVersion.c \ TermPrimVersion.c \
@ -69,12 +68,18 @@ OBJS = \
TermPrimScroll.o \ TermPrimScroll.o \
TermPrimSelect.o \ TermPrimSelect.o \
TermPrimSetPty.o \ TermPrimSetPty.o \
TermPrimSetUtmp.o \
TermPrimSubproc.o \ TermPrimSubproc.o \
TermPrimUtil.o \ TermPrimUtil.o \
TermPrimVersion.o \ TermPrimVersion.o \
TermPrimWMProtocols.o TermPrimWMProtocols.o
#if defined(HasUtempterLibrary) && HasUtempterLibrary
EXTRA_DEFINES = -DHAS_UTEMPTER_LIBRARY
#else
SRCS += TermPrimSetUtmp.c
OBJS += TermPrimSetUtmp.o
#endif
#include <Library.tmpl> #include <Library.tmpl>
#if defined(HasPtsDriver) && HasPtsDriver #if defined(HasPtsDriver) && HasPtsDriver

View file

@ -82,6 +82,10 @@ extern char * _DtTermPrimGetMessage( char *filename, int set, int n, char *s );
# include <sys/select.h> # include <sys/select.h>
#endif #endif
#ifdef HAS_UTEMPTER_LIBRARY
#include <utempter.h>
#endif
extern void TermReadKey(Widget w, XEvent *event, String *params, extern void TermReadKey(Widget w, XEvent *event, String *params,
Cardinal *num_params); Cardinal *num_params);
static void ClassInitialize(void); static void ClassInitialize(void);
@ -1068,7 +1072,9 @@ Initialize(Widget ref_w, Widget w, Arg *args, Cardinal *num_args)
/* /*
** Initialize the utmp stuff... ** Initialize the utmp stuff...
*/ */
#ifndef HAS_UTEMPTER_LIBRARY
_DtTermPrimUtmpInit(w); _DtTermPrimUtmpInit(w);
#endif
/* /*
** Initialize the selection inforamtion ** Initialize the selection inforamtion
@ -2478,8 +2484,12 @@ Realize(Widget w, XtValueMask *p_valueMask, XSetWindowAttributes *attributes)
/* get the utmp line name to use for searching later... */ /* get the utmp line name to use for searching later... */
if (tw->term.pty >= 0) { if (tw->term.pty >= 0) {
#ifdef HAS_UTEMPTER_LIBRARY
utempter_add_record(tw->term.pty, DisplayString(XtDisplay(w)));
#else
tw->term.tpd->utmpId = _DtTermPrimUtmpGetUtLine(-1, tw->term.tpd->utmpId = _DtTermPrimUtmpGetUtLine(-1,
tw->term.ptySlaveName); tw->term.ptySlaveName);
#endif
} }
/* /*
@ -2620,11 +2630,15 @@ Destroy(Widget w)
_DtTermPrimToggleSuidRoot(False); _DtTermPrimToggleSuidRoot(False);
/* clean up our utmp entry... */ /* clean up our utmp entry... */
#ifdef HAS_UTEMPTER_LIBRARY
utempter_remove_added_record();
#else
if (tw->term.tpd && tw->term.tpd->utmpId && *tw->term.tpd->utmpId) { if (tw->term.tpd && tw->term.tpd->utmpId && *tw->term.tpd->utmpId) {
_DtTermPrimUtmpEntryDestroy(w, tw->term.tpd->utmpId); _DtTermPrimUtmpEntryDestroy(w, tw->term.tpd->utmpId);
(void) XtFree(tw->term.tpd->utmpId); (void) XtFree(tw->term.tpd->utmpId);
tw->term.tpd->utmpId = (char *) 0; tw->term.tpd->utmpId = (char *) 0;
} }
#endif
/* close and release the... /* close and release the...
*/ */

View file

@ -573,8 +573,10 @@ _DtTermPrimSubprocExec(Widget w,
} }
/* set our utmp entry... */ /* set our utmp entry... */
#ifndef HAS_UTEMPTER_LIBRARY
(void) _DtTermPrimUtmpEntryCreate(w, getpid(), (void) _DtTermPrimUtmpEntryCreate(w, getpid(),
((DtTermPrimitiveWidget)w)->term.tpd->utmpId); ((DtTermPrimitiveWidget)w)->term.tpd->utmpId);
#endif
if (isDebugSet('T')) { if (isDebugSet('T')) {
#ifdef BBA #ifdef BBA
@ -652,7 +654,9 @@ _DtTermPrimSubprocExec(Widget w,
/* assume that our child set up a utmp entry (since we have no way /* assume that our child set up a utmp entry (since we have no way
* for it to report to us) and add it to the list to cleanup)... * for it to report to us) and add it to the list to cleanup)...
*/ */
#ifndef HAS_UTEMPTER_LIBRARY
_DtTermPrimUtmpAddEntry(((DtTermPrimitiveWidget)w)->term.tpd->utmpId); _DtTermPrimUtmpAddEntry(((DtTermPrimitiveWidget)w)->term.tpd->utmpId);
#endif
return(pid); return(pid);
} }