diff --git a/gpm-1.20.1-weak-wgetch.patch b/gpm-1.20.1-weak-wgetch.patch new file mode 100644 index 0000000000000000000000000000000000000000..e1901a6cd3694eea76dacf710570b42547ce1b26 --- /dev/null +++ b/gpm-1.20.1-weak-wgetch.patch @@ -0,0 +1,26 @@ +--- gpm-1.20.1/src/lib/libcurses.c.weak-wgetch 2002-12-24 17:57:16.000000000 -0500 ++++ gpm-1.20.1/src/lib/libcurses.c 2004-03-22 15:51:24.000000000 -0500 +@@ -41,7 +41,12 @@ + #endif /* HAVE_NCURSES_CURSES_H */ + #endif /* HAVE_NCURSES_H */ + +-#define GET(win) ((win) ? wgetch(win) : getch()) ++/* If win != NULL, it must have been created by ncurses anyway. ++ Avoid circular library dependencies. */ ++#pragma weak wgetch ++#pragma weak stdscr ++ ++#define GET(win) ((win && wgetch) ? wgetch(win) : getch()) + + int Gpm_Wgetch(WINDOW *win) + { +--- gpm-1.20.1/configure.ac.weak-wgetch 2004-03-22 15:49:51.000000000 -0500 ++++ gpm-1.20.1/configure.ac.footer 2004-03-22 15:51:24.000000000 -0500 +@@ -115,7 +115,7 @@ + AC_CHECK_LIB($i, wgetch,,,$TERMLIBS) + else :; fi + done +- SHARED_LIBS="$LIBS $TERMLIBS -lc" ++ SHARED_LIBS="-lc" + LIBS=$SAVELIBS ;; + esac diff --git a/gpm-1.20.5-close-fds.patch b/gpm-1.20.5-close-fds.patch new file mode 100644 index 0000000000000000000000000000000000000000..f33f07c55a82dab3d21f673663a50d6575b89893 --- /dev/null +++ b/gpm-1.20.5-close-fds.patch @@ -0,0 +1,17 @@ +diff -up gpm-1.20.5/src/daemon/startup.c.close-fds gpm-1.20.5/src/daemon/startup.c +--- gpm-1.20.5/src/daemon/startup.c.close-fds 2008-06-13 10:08:19.000000000 +0200 ++++ gpm-1.20.5/src/daemon/startup.c 2008-12-02 10:11:12.000000000 +0100 +@@ -135,6 +135,13 @@ void startup(int argc, char **argv) + check_uniqueness(); + gpm_report(GPM_PR_INFO,GPM_MESS_STARTED); + ++ // close extra fds ++ if (option.run_status == GPM_RUN_STARTUP ) { ++ close(0); ++ close(1); ++ close(2); ++ } ++ + //return mouse_table[1].fd; /* the second is handled in the main() */ + + /****************** OLD CODE from gpn.c END ***********************/ diff --git a/gpm-1.20.6-multilib.patch b/gpm-1.20.6-multilib.patch new file mode 100644 index 0000000000000000000000000000000000000000..820db88479338203bedf3854f1d964d51243200c --- /dev/null +++ b/gpm-1.20.6-multilib.patch @@ -0,0 +1,45 @@ +diff -up gpm-1.20.6/contrib/Makefile.in.multilib gpm-1.20.6/contrib/Makefile.in +--- gpm-1.20.6/contrib/Makefile.in.multilib 2008-06-19 07:48:48.000000000 +0200 ++++ gpm-1.20.6/contrib/Makefile.in 2009-02-24 10:36:09.000000000 +0100 +@@ -9,10 +9,10 @@ top_builddir = .. + + include $(top_builddir)/Makefile.include + +-all: $(srcdir)/$(ELISP) ++all: $(filter-out %.elc,$(srcdir)/$(ELISP)) + + install: all +- if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ ++ if [ -n "$(filter-out %.elc,$(ELISP))" ]; then for i in `echo $(filter-out %.elc,$(ELISP))`; do \ + $(INSTALL_DATA) $(srcdir)/$$i $(lispdir)/`basename $$i` ;\ + done; fi + +@@ -20,7 +20,7 @@ install: all + $(EMACS) -batch -l $(srcdir)/emacs/exec.el -exec '(byte-compile-file "$<")' + + uninstall: +- if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ ++ if [ -n "$(filter-out %.elc,$(ELISP))" ]; then for i in `echo $(filter-out %.elc,$(ELISP))`; do \ + rm -f $(lispdir)/$$i ;\ + done; fi + +@@ -28,4 +28,4 @@ dist: + $(CP) -r $(srcdir) $(top_builddir)/gpm-$(release)/ + + clean distclean: +- $(RM) -f $(srcdir)/emacs/*.elc Makefile ++ $(RM) $(srcdir)/emacs/*.elc Makefile +diff -up gpm-1.20.6/doc/Makefile.in.multilib gpm-1.20.6/doc/Makefile.in +--- gpm-1.20.6/doc/Makefile.in.multilib 2009-02-09 10:58:53.000000000 +0100 ++++ gpm-1.20.6/doc/Makefile.in 2009-02-24 10:36:09.000000000 +0100 +@@ -130,8 +130,8 @@ install: all installdirs + #i keep all my infopages compressed and i'm tired to do it by + #hand, so check if there are any compressed pages and do this + #one too +- -ls $(infodir)/*[-.]info.gz >/dev/null 2>&1 \ +- && gzip -f $(infodir)/gpm.info ++ #-ls $(infodir)/*[-.]info.gz >/dev/null 2>&1 \ ++ # && gzip -f $(infodir)/gpm.info + # Hmm.... shouldn't man pages be compressed too? + # maybe they should, but at least at my system they are not. + diff --git a/gpm-1.20.7-covscan.patch b/gpm-1.20.7-covscan.patch new file mode 100644 index 0000000000000000000000000000000000000000..f10e66ace5c74b3ead63cc9aac081eed2f8c36d9 --- /dev/null +++ b/gpm-1.20.7-covscan.patch @@ -0,0 +1,115 @@ +diff --git a/src/daemon/check_uniqueness.c b/src/daemon/check_uniqueness.c +index 4972413..d0eb4e4 100644 +--- a/src/daemon/check_uniqueness.c ++++ b/src/daemon/check_uniqueness.c +@@ -36,6 +36,7 @@ void check_uniqueness(void) + + if((fp = fopen(GPM_NODE_PID, "r")) != NULL) { + fscanf(fp, "%d", &old_pid); ++ fclose(fp); + if (kill(old_pid,0) == -1) { + gpm_report(GPM_PR_INFO,GPM_MESS_STALE_PID, GPM_NODE_PID); + unlink(GPM_NODE_PID); +diff --git a/src/lib/liblow.c b/src/lib/liblow.c +index 8b40b71..d197dae 100644 +--- a/src/lib/liblow.c ++++ b/src/lib/liblow.c +@@ -250,9 +250,9 @@ int Gpm_Open(Gpm_Connect *conn, int flag) + memcpy(tty, consolename, strlen(consolename)-1); + sprintf(&tty[strlen(consolename) - 1], "%i", flag); + } else if (flag==0) { /* use your current vc */ +- if (isatty(0)) tty = ttyname(0); /* stdin */ +- if (!tty && isatty(1)) tty = ttyname(1); /* stdout */ +- if (!tty && isatty(2)) tty = ttyname(2); /* stderr */ ++ if (isatty(0) && ttyname(0)) tty = strdup(ttyname(0)); /* stdin */ ++ if (!tty && isatty(1) && ttyname(1)) tty = strdup(ttyname(1)); /* stdout */ ++ if (!tty && isatty(2) && ttyname(2)) tty = strdup(ttyname(2)); /* stderr */ + if (tty == NULL) { + gpm_report(GPM_PR_ERR,"checking tty name failed"); + goto err; +@@ -373,10 +373,12 @@ int Gpm_Open(Gpm_Connect *conn, int flag) + #endif + + } ++ if (tty) free(tty); + return gpm_fd; + + /*....................................... Error: free all memory */ + err: ++ if (tty) free(tty); + if (gpm_is_disabled < 2) /* be quiet if no gpmctl socket found */ + gpm_report(GPM_PR_ERR,"Oh, oh, it's an error! possibly I die! "); + while(gpm_stack) { +diff --git a/src/lib/report-lib.c b/src/lib/report-lib.c +index 03230b4..ff74b8c 100644 +--- a/src/lib/report-lib.c ++++ b/src/lib/report-lib.c +@@ -63,5 +63,6 @@ void gpm_report(int line, const char *file, int stat, const char *text, ... ) + fprintf(stderr,"\n"); + #endif + ++ va_end(ap); + if(stat == GPM_STAT_OOPS) exit(1); /* may a lib function call exit ???? */ + } +diff --git a/src/mice.c b/src/mice.c +index 6cbd491..090dfed 100644 +--- a/src/mice.c ++++ b/src/mice.c +@@ -905,7 +905,7 @@ static int M_wacom(Gpm_Event *state, unsigned char *data) + } else { /* Relative Mode */ + /* Treshold; if greather then treat tool as first time in proximity */ + if( abs(x-ox)>(wmaxx/wcmodell[WacomModell].treshold) +- || abs(y-oy)>(wmaxy/wcmodell[WacomModell].treshold) ) ox=x; oy=y; ++ || abs(y-oy)>(wmaxy/wcmodell[WacomModell].treshold) ) { ox=x; oy=y; } + + state->dx= (x-ox) / (wmaxx / win.ws_col / wcmodell[WacomModell].treshold); + state->dy= (y-oy) / (wmaxy / win.ws_row / wcmodell[WacomModell].treshold); +diff --git a/src/prog/gpm-root.y b/src/prog/gpm-root.y +index 76c896c..ded326a 100644 +--- a/src/prog/gpm-root.y ++++ b/src/prog/gpm-root.y +@@ -555,12 +555,15 @@ int f_jptty(int mode, DrawItem *self, int uid) + } /*if*/ + if (ioctl(fd, VT_ACTIVATE, i)<0) { + gpm_report(GPM_PR_ERR, "%s: %s", consolename,strerror(errno)); ++ close(fd); + return 1; + } /*if*/ + if (ioctl(fd, VT_WAITACTIVE, i)<0) { + gpm_report(GPM_PR_ERR, "%s: %s", consolename,strerror(errno)); ++ close(fd); + return 1; + } ++ close(fd); + default: return 0; + } + return 0; /* silly gcc -Wall */ +@@ -586,14 +589,17 @@ int f_mktty(int mode, DrawItem *self, int uid) + } /*if*/ + if (ioctl(fd, VT_OPENQRY, &vc)<0) { + gpm_report(GPM_PR_ERR, "%s: %s",consolename, strerror(errno)); ++ close(fd); + return 1; + } /*if*/ + switch(pid=fork()) { + case -1: + gpm_report(GPM_PR_ERR, "fork(): %s", strerror(errno)); ++ close(fd); + return 1; + case 0: /* child: exec getty */ + sprintf(name,"tty%i",vc); ++ close(fd); + execl("/sbin/mingetty","mingetty",name,(char *)NULL); + exit(1); /* shouldn't happen */ + default: /* father: jump to the tty */ +@@ -601,8 +607,10 @@ int f_mktty(int mode, DrawItem *self, int uid) + ,pid,vc); + consolepids[vc]=pid; + sprintf(self->arg,"%i",vc); ++ close(fd); + return f_jptty(mode,self,uid); + } ++ close(fd); + default: return 0; + } + return 0; diff --git a/gpm-1.20.7-rhbz-668480-gpm-types-7-manpage-fixes.patch b/gpm-1.20.7-rhbz-668480-gpm-types-7-manpage-fixes.patch new file mode 100644 index 0000000000000000000000000000000000000000..61994628ce11d3e83ef4def21a4f99570e29a3c7 --- /dev/null +++ b/gpm-1.20.7-rhbz-668480-gpm-types-7-manpage-fixes.patch @@ -0,0 +1,30 @@ +diff -Naur gpm-1.20.7.orig/doc/doc.gpm.in gpm-1.20.7/doc/doc.gpm.in +--- gpm-1.20.7.orig/doc/doc.gpm.in 2012-10-26 23:21:38.000000000 +0200 ++++ gpm-1.20.7/doc/doc.gpm.in 2013-07-19 19:40:33.374213536 +0200 +@@ -600,7 +600,7 @@ + that one of @t{\-o dtr}, @t{\-o rts}, @t{\-o both} can be specified to + toggle the control lines of the serial port. + +-The following mouse type are corrently recognized: ++The following mouse type are currently recognized: + + @table @code + @item bare Microsoft +@@ -621,7 +621,7 @@ + this is your case, use the @samp{bare} mouse type. Some new + two-button devices are ``plug and play'', and they don't play + fair at all; in this case try @t{\-t pnp}. Many (most) +- three-button devices that use the microsoft protocol fail to ++ three-button devices that use the Microsoft protocol fail to + report some middle-button events during mouse motion. Since + the protocol does not distinguish between the middle button + going up and the middle button going down it would be liable +@@ -649,7 +649,7 @@ + decoder gets into a confused state where it thinks the middle + button is up when it's down and vice versa. (If you get sick + of having to do this, please don't blame gpm; blame your buggy +- mouse! Note that most three-button mice that do the microsoft ++ mouse! Note that most three-button mice that do the Microsoft + protocol can be made to do the MouseSystems protocol + instead. The ``3 Button Serial Mouse mini-HOWTO'' has + information about this.) This mouse decoder accepts standard diff --git a/gpm-1.20.7.tar.xz b/gpm-1.20.7.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..9afc73c51a43cf6429a391e21df0ad66dac1d651 Binary files /dev/null and b/gpm-1.20.7.tar.xz differ diff --git a/gpm.service b/gpm.service index 7ae0120ed6d3b4d7e23693e58941beffe15d5787..23007fc1965b83aede9fa4c25b1f28e49fcdb6e7 100644 --- a/gpm.service +++ b/gpm.service @@ -1,5 +1,5 @@ [Unit] -Description=Console Mouse Manager +Description=Console Mouse manager ConditionVirtualization=!container # This could probably benefit from socket activation, but honestly I think it @@ -7,27 +7,9 @@ ConditionVirtualization=!container # to add socket activation here. [Service] -ExecStart=gpm -m /dev/input/mice -t exps2 +ExecStart=/usr/sbin/gpm -m /dev/input/mice -t exps2 Type=forking PIDFile=/run/gpm.pid -ProtectSystem=full -ProtectHome=yes -ProtectProc=invisible -ProtectControlGroups=yes -ProtectKernelTunables=yes -PrivateNetwork=yes -CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_SYS_ADMIN -DeviceAllow=char-tty -DeviceAllow=char-input -# See also https://github.com/systemd/systemd/pull/21350 -SystemCallFilter=@basic-io @io-event @network-io @file-system @process @signal ioctl mprotect setsid -SystemCallArchitectures=native -SystemCallErrorNumber=EPERM -RestrictAddressFamilies=AF_UNIX - -# Note that "special commands" are disallowed by default. -# To enable, add '-S' to ExecStart= line, and tweak the SystemCallFilter= as appropriate. - [Install] WantedBy=multi-user.target diff --git a/gpm.spec b/gpm.spec index 019e6c67fa9b1454cdc33b3e24600f8811b4012d..84d77c8bfb5da8f1b9ee22ee0325ccd09f75d43f 100644 --- a/gpm.spec +++ b/gpm.spec @@ -1,15 +1,15 @@ -%define anolis_release 5 +%define anolis_release 6 %global LIBVER 2.1.0 Name: gpm -Version: 1.20.7 +Version: 1.20.7 Release: %{anolis_release}%{?dist} Summary: A mouse server for the Linux console License: GPLv2 and OFSFDL URL: http://www.nico.schottelius.org/software/gpm/ -Source0: https://github.com/telmich/gpm/archive/refs/tags/1.20.7.tar.gz -Source1: gpm.service +Source0: gpm-1.20.7.tar.xz +Source1: gpm.service Patch1: 0001-typo-1.20.5-should-have-been-1.20.6.patch Patch2: 0002-switch-to-xz.patch @@ -39,6 +39,11 @@ Patch25: 0025-Add-include-string.h.patch Patch26: 0026-Update-liblow.c-for-musl-compatible.patch Patch27: 0027-Aligned-comments.patch Patch28: 0028-src-headers-daemon.h-avoid-redefinition-of-last_sele.patch +Patch29: gpm-1.20.7-covscan.patch +Patch30: gpm-1.20.7-rhbz-668480-gpm-types-7-manpage-fixes.patch +Patch31: gpm-1.20.1-weak-wgetch.patch +Patch32: gpm-1.20.6-multilib.patch +Patch33: gpm-1.20.5-close-fds.patch Requires(post): info Requires(preun): info @@ -46,6 +51,8 @@ Requires(preun): info BuildRequires: sed gawk texinfo bison ncurses-devel libtool libcap-ng-devel BuildRequires: systemd-rpm-macros BuildRequires: gcc gcc-c++ make autoconf +BuildRequires: automake +BuildRequires: systemd Requires: linuxconsoletools Requires: %{name}-libs = %{version}-%{release} @@ -152,6 +159,12 @@ rm -rf %{buildroot}%{_initrddir} %changelog +* Wed Sep 17 2025 wenyuzifang - 1.20.7-6 +- Fix resource leaks, prevent undefined behavior, and ensure correct logic in critical paths +- Fix documentation errors and improve clarity by correcting spelling and capitalization +- Fix library linkage issues, avoid circular dependencies, and enable optional curses support +- Fix build instability by excluding .elc files and remove unreliable doc compression +- Ensure clean daemon startup by closing standard file descriptors to prevent leaks and improve system reliability * Thu Dec 28 2023 happy_orange - 1.20.7-5 - fix the source error