[minicom/f14/master] updated rh patch to support unix socket (#592355)

Jan Görig jgorig at fedoraproject.org
Fri Sep 17 10:44:10 UTC 2010


commit 340b6d43f6ffd1fae3cad00ba318b67436b5d0e1
Author: Jan Görig <jgorig at redhat.com>
Date:   Fri Sep 17 12:38:37 2010 +0200

    updated rh patch to support unix socket (#592355)

 minicom-2.4-rh.patch |  129 +++++++++++++++++++++++++++++++++-----------------
 minicom.spec         |    5 ++-
 2 files changed, 90 insertions(+), 44 deletions(-)
---
diff --git a/minicom-2.4-rh.patch b/minicom-2.4-rh.patch
index 173aa2b..6221347 100644
--- a/minicom-2.4-rh.patch
+++ b/minicom-2.4-rh.patch
@@ -1,7 +1,8 @@
-diff -up minicom-2.4/src/main.c.orig minicom-2.4/src/main.c
---- minicom-2.4/src/main.c.orig	2009-12-12 16:47:47.000000000 +0100
-+++ minicom-2.4/src/main.c	2010-03-10 11:43:12.588243671 +0100
-@@ -154,13 +154,18 @@ void term_socket_close(void)
+diff --git a/src/main.c b/src/main.c
+index e3f6e45..8009c6e 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -154,13 +154,19 @@ void term_socket_close(void)
  int open_term(int doinit, int show_win_on_error)
  {
    struct stat stt;
@@ -11,6 +12,7 @@ diff -up minicom-2.4/src/main.c.orig minicom-2.4/src/main.c
 +  int fd;
    int pid;
 +#endif
++  int rc;
 +  int n = 0;
  #ifdef HAVE_ERRNO_H
    int s_errno;
@@ -21,92 +23,133 @@ diff -up minicom-2.4/src/main.c.orig minicom-2.4/src/main.c
    /* First see if the lock file directory is present. */
    if (P_LOCK[0] && stat(P_LOCK, &stt) == 0) {
  
-@@ -212,6 +217,29 @@ int open_term(int doinit, int show_win_o
+@@ -212,6 +218,44 @@ int open_term(int doinit, int show_win_on_error)
    if (doinit > 0)
      lockfile_create();
  
 +#else
 +  lockfile[0] = 0;
 +  if (doinit > 0) {
-+       int rc = ttylock(dial_tty);
-+       if (rc < 0) {
-+               if (access(dial_tty, W_OK) == -1)
-+                       fprintf(stderr, _("Device %s access failed: %s.\n"),
-+                               dial_tty, strerror(errno));
-+               else
-+                       fprintf(stderr, _("Device %s lock failed: %s.\n"),
-+                               dial_tty, strerror(-rc));
-+       } else if (rc > 0) {
-+               fprintf(stderr, _("Device %s is locked.\n"), dial_tty);
-+       } else if (rc == 0) {
-+               snprintf(lockfile, sizeof(lockfile), "%s", dial_tty);
-+       }
-+       if (rc) {
-+               if (stdwin) mc_wclose(stdwin, 1);
-+               return(-1);
-+       }
++#ifdef USE_SOCKET
++    if (strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) == 0) {
++      if (stat(dial_tty+strlen(SOCKET_PREFIX), &stt) == 0 &&
++         S_ISSOCK(stt.st_mode)) {
++        rc = 0;
++      } else {
++        rc = 1;
++        fprintf(stderr, _("File %s is not a socket.\n"),
++                dial_tty+strlen(SOCKET_PREFIX));
++      }
++    } else {
++#endif
++      rc = ttylock(dial_tty);
++      if (rc < 0) {
++        if (access(dial_tty, W_OK) == -1)
++          fprintf(stderr, _("Device %s access failed: %s.\n"),
++                  dial_tty, strerror(errno));
++        else
++          fprintf(stderr, _("Device %s lock failed: %s.\n"),
++                  dial_tty, strerror(-rc));
++      } else if (rc > 0) {
++        fprintf(stderr, _("Device %s is locked.\n"), dial_tty);
++      }
++#ifdef USE_SOCKET
++    }
++#endif
++    if (rc == 0) {
++      snprintf(lockfile, sizeof(lockfile), "%s", dial_tty);
++    } else {
++      if (stdwin) mc_wclose(stdwin, 1);
++      return(-1);
++    }
 +  }
 +#endif
 +
    /* Run a special program to disable callin if needed. */
      if (doinit > 0 && P_CALLOUT[0]) {
        if (fastsystem(P_CALLOUT, NULL, NULL, NULL) < 0) {
-diff -up minicom-2.4/src/minicom.c.orig minicom-2.4/src/minicom.c
---- minicom-2.4/src/minicom.c.orig	2009-12-12 16:47:47.000000000 +0100
-+++ minicom-2.4/src/minicom.c	2010-03-10 11:39:32.406244215 +0100
-@@ -1555,7 +1555,7 @@ dirty_goto:
+@@ -229,7 +273,6 @@ int open_term(int doinit, int show_win_on_error)
+     signal(SIGALRM, get_alrm);
+     alarm(4);
+ #ifdef USE_SOCKET
+-#define SOCKET_PREFIX "unix#"
+     portfd_is_socket = portfd_is_connected = 0;
+     if (strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) == 0) {
+       portfd_is_socket = 1;
+diff --git a/src/minicom.c b/src/minicom.c
+index 2960112..4d4d22d 100644
+--- a/src/minicom.c
++++ b/src/minicom.c
+@@ -1554,8 +1554,7 @@ dirty_goto:
+   mc_wclose(st, 0);
    mc_wclose(stdwin, 1);
    keyboard(KUNINSTALL, 0);
-   if (lockfile[0])
+-  if (lockfile[0])
 -    unlink(lockfile);
-+    ttyunlock(lockfile);
++  lockfile_remove();
    close(portfd);
  
    if (quit != NORESET && P_CALLIN[0])
-diff -up minicom-2.4/src/minicom.h.orig minicom-2.4/src/minicom.h
---- minicom-2.4/src/minicom.h.orig	2009-12-12 16:47:47.000000000 +0100
-+++ minicom-2.4/src/minicom.h	2010-03-10 11:39:32.406244215 +0100
-@@ -35,6 +35,8 @@
+diff --git a/src/minicom.h b/src/minicom.h
+index b361dce..e8029e9 100644
+--- a/src/minicom.h
++++ b/src/minicom.h
+@@ -34,10 +34,14 @@
+ #include "libport.h"
  
  #include <time.h>
- 
++#include <limits.h>
 +#include <baudboy.h>
-+
+ 
  #ifdef USE_SOCKET
  #include <sys/socket.h>
  #include <sys/un.h>
-@@ -82,7 +84,7 @@ EXTERN int tempst;	/* Status line is tem
++
++#define SOCKET_PREFIX "unix#"
+ #endif
+ 
+ /*
+@@ -82,7 +86,7 @@ EXTERN int tempst;	/* Status line is temporary */
  EXTERN int escape;	/* Escape code. */
  EXTERN int disable_online_time; /* disable online time display */
  
 -EXTERN char lockfile[128]; /* UUCP lock file of terminal */
-+EXTERN char lockfile[1024]; /* UUCP lock file of terminal */
++EXTERN char lockfile[PATH_MAX]; /* UUCP lock file of terminal */
  EXTERN char homedir[256];  /* Home directory of user */
  EXTERN char logfname[PARS_VAL_LEN]; /* Name of the logfile */
  EXTERN char username[16];  /* Who is using minicom? */
-diff -up minicom-2.4/src/updown.c.orig minicom-2.4/src/updown.c
---- minicom-2.4/src/updown.c.orig	2009-12-13 16:20:34.000000000 +0100
-+++ minicom-2.4/src/updown.c	2010-03-10 11:54:05.519368852 +0100
-@@ -378,11 +378,12 @@ void updown(int what, int nr)
+diff --git a/src/updown.c b/src/updown.c
+index 507717a..ee94978 100644
+--- a/src/updown.c
++++ b/src/updown.c
+@@ -377,12 +377,14 @@ void updown(int what, int nr)
+ 
  void lockfile_remove(void)
  {
-   if (lockfile[0])
+-  if (lockfile[0])
 -    unlink(lockfile);
++  if (lockfile[0] && strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) != 0)
 +    ttyunlock(lockfile);
  }
  
  void lockfile_create(void)
  {
++  int rc;
 +#ifdef NOTNOW
    int fd, n;
    char buf[81];
  
-@@ -399,6 +400,9 @@ void lockfile_create(void)
+@@ -399,6 +401,14 @@ void lockfile_create(void)
      close(fd);
    }
    umask(n);
 +#else
-+  ttylock(lockfile);
++  if (strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) != 0) {
++    rc = ttylock(lockfile);
++    if (rc) {
++      werror(_("Cannot lock device!"));
++    }
++  }
 +#endif
  }
  
diff --git a/minicom.spec b/minicom.spec
index dafa4c9..838cb0e 100644
--- a/minicom.spec
+++ b/minicom.spec
@@ -1,7 +1,7 @@
 Summary: A text-based modem control and terminal emulation program
 Name: minicom
 Version: 2.4
-Release: 1%{?dist}
+Release: 2%{?dist}
 URL: http://alioth.debian.org/projects/minicom/
 License: GPLv2+
 Group: Applications/Communications
@@ -64,6 +64,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/*
 
 %changelog
+* Fri Sep 17 2010 Jan Görig <jgorig at redhat.com> 2.4-2
+- updated rh patch to support unix socket (#592355)
+
 * Tue Mar 9 2010 Jan Görig <jgorig at redhat.com> 2.4-1
 - update to 2.4
 - /etc/minicom.users removed by upstream


More information about the scm-commits mailing list