summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
committerYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
commit4dd1f56f29fc598a8339a345c2f8945250600602 (patch)
treeaf341efedffe027e533b1bcc0dbf270532e48285 /lib-src
parent4c49ec7f865bdad1629d2f125f71f4e506b258f2 (diff)
parent810fa21d26453f898de9747ece7205dfe6de9d08 (diff)
downloademacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.gz
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/Makefile.in1
-rw-r--r--lib-src/emacsclient.c33
-rw-r--r--lib-src/etags.c2
-rw-r--r--lib-src/ntlib.c6
-rw-r--r--lib-src/seccomp-filter.c11
5 files changed, 34 insertions, 19 deletions
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index 7af89eb380d..e6cda733679 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -52,6 +52,7 @@ top_builddir = @top_builddir@
# Location to install Emacs.app under GNUstep / macOS.
# Later values may use this.
ns_appbindir=@ns_appbindir@
+ns_applibexecdir=@ns_applibexecdir@
# The default location for installation. Everything is placed in
# subdirectories of this directory. The default values for many of
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 8fa571fd4ef..1f3e72f81db 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -80,9 +80,6 @@ char *w32_getenv (const char *);
#include <sys/stat.h>
#include <unistd.h>
-#ifndef WINDOWSNT
-# include <acl.h>
-#endif
#include <filename.h>
#include <intprops.h>
#include <min-max.h>
@@ -94,10 +91,6 @@ char *w32_getenv (const char *);
# pragma GCC diagnostic ignored "-Wformat-truncation=2"
#endif
-#if !defined O_PATH && !defined WINDOWSNT
-# define O_PATH O_SEARCH
-#endif
-
/* Name used to invoke this program. */
static char const *progname;
@@ -123,6 +116,9 @@ static bool eval;
/* True means open a new frame. --create-frame etc. */
static bool create_frame;
+/* True means reuse a frame if it already exists. */
+static bool reuse_frame;
+
/* The display on which Emacs should work. --display. */
static char const *display;
@@ -172,6 +168,7 @@ static struct option const longopts[] =
{ "tty", no_argument, NULL, 't' },
{ "nw", no_argument, NULL, 't' },
{ "create-frame", no_argument, NULL, 'c' },
+ { "reuse-frame", no_argument, NULL, 'r' },
{ "alternate-editor", required_argument, NULL, 'a' },
{ "frame-parameters", required_argument, NULL, 'F' },
#ifdef SOCKETS_IN_FILE_SYSTEM
@@ -558,6 +555,11 @@ decode_options (int argc, char **argv)
create_frame = true;
break;
+ case 'r':
+ create_frame = true;
+ reuse_frame = true;
+ break;
+
case 'p':
parent_id = optarg;
create_frame = true;
@@ -659,6 +661,8 @@ The following OPTIONS are accepted:\n\
-nw, -t, --tty Open a new Emacs frame on the current terminal\n\
-c, --create-frame Create a new frame instead of trying to\n\
use the current Emacs frame\n\
+-r, --reuse-frame Create a new frame if none exists, otherwise\n\
+ use the current Emacs frame\n\
", "\
-F ALIST, --frame-parameters=ALIST\n\
Set the parameters of a new frame\n\
@@ -1140,6 +1144,12 @@ process_grouping (void)
#ifdef SOCKETS_IN_FILE_SYSTEM
+# include <acl.h>
+
+# ifndef O_PATH
+# define O_PATH O_SEARCH
+# endif
+
/* A local socket address. The union avoids the need to cast. */
union local_sockaddr
{
@@ -1406,10 +1416,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen,
/* Put the full address name into the buffer, since the caller might
need it for diagnostics. But don't overrun the buffer. */
uintmax_t uidmax = uid;
- int emacsdirlen;
int suffixlen = snprintf (sockname + tmpdirlen, socknamesize - tmpdirlen,
- "/emacs%"PRIuMAX"%n/%s", uidmax, &emacsdirlen,
- server_name);
+ "/emacs%"PRIuMAX"/%s", uidmax, server_name);
if (! (0 <= suffixlen && suffixlen < socknamesize - tmpdirlen))
return ENAMETOOLONG;
@@ -1417,7 +1425,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen,
this user's directory and does not let others write to it; this
fends off some symlink attacks. To avoid races, keep the parent
directory open while checking. */
- char *emacsdirend = sockname + tmpdirlen + emacsdirlen;
+ char *emacsdirend = sockname + tmpdirlen + suffixlen -
+ strlen(server_name) - 1;
*emacsdirend = '\0';
int dir = openat (AT_FDCWD, sockname,
O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
@@ -1948,7 +1957,7 @@ main (int argc, char **argv)
if (nowait)
send_to_emacs (emacs_socket, "-nowait ");
- if (!create_frame)
+ if (!create_frame || reuse_frame)
send_to_emacs (emacs_socket, "-current-frame ");
if (display)
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 88b49f803e9..bd4d4fcf53a 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -6259,7 +6259,7 @@ test_objc_is_mercury (char *this_file, language **lang)
}
}
- /* Fallback heuristic test. Not failsafe but errless in pratice. */
+ /* Fallback heuristic test. Not failsafe but errless in practice. */
ratio = ((float) rule_signs + percentage_signs + mercury_dots) / lines;
out:
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index bcbc0064318..c8bcf742fea 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -20,6 +20,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
+#define DEFER_MS_W32_H
+#include <config.h>
+
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
@@ -287,9 +290,6 @@ is_exec (const char * name)
stricmp (p, ".cmd") == 0));
}
-/* FIXME? This is in configure.ac now - is this still needed? */
-#define IS_DIRECTORY_SEP(x) ((x) == '/' || (x) == '\\')
-
/* We need stat/fsfat below because nt/inc/sys/stat.h defines struct
stat that is incompatible with the MS run-time libraries. */
int
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index dc568e035b5..e7496053a86 100644
--- a/lib-src/seccomp-filter.c
+++ b/lib-src/seccomp-filter.c
@@ -131,9 +131,12 @@ export_filter (const char *file,
int (*function) (const scmp_filter_ctx, int),
const char *name)
{
- int fd = TEMP_FAILURE_RETRY (
- open (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC,
- 0644));
+ int fd;
+ do
+ fd = open (file,
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC,
+ 0644);
+ while (fd < 0 && errno == EINTR);
if (fd < 0)
fail (errno, "open %s", file);
int status = function (ctx, fd);
@@ -348,6 +351,8 @@ main (int argc, char **argv)
calls at startup time to set up thread-local storage. */
RULE (SCMP_ACT_ALLOW, SCMP_SYS (execve));
RULE (SCMP_ACT_ALLOW, SCMP_SYS (set_tid_address));
+ RULE (SCMP_ACT_ERRNO (EINVAL), SCMP_SYS (prctl),
+ SCMP_A0_32 (SCMP_CMP_EQ, PR_CAPBSET_READ));
RULE (SCMP_ACT_ALLOW, SCMP_SYS (arch_prctl),
SCMP_A0_32 (SCMP_CMP_EQ, ARCH_SET_FS));
RULE (SCMP_ACT_ERRNO (EINVAL), SCMP_SYS (arch_prctl),