Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Apr 2014 03:24:55 +0200
From:      Mateusz Guzik <mjg@freebsd.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263981 - in head: lib/libc/gen sys/kern sys/sys
Message-ID:  <20140401012455.GA26117@dft-labs.eu>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Tue Apr  1 03:20:35 2014

New Revision: 263981
URL: http://svnweb.freebsd.org/changeset/base/263981

Log:
  Add a new errno: EMACS - Editor too big.

  Make a best-effort to detect that Emacs is about to executed and return
  the error.

  MFC after:	1 week

Modified:
  head/lib/libc/gen/errlst.c
  head/sys/kern/kern_exec.c
  head/sys/sys/errno.h

Modified: lib/libc/gen/errlst.c
===================================================================
--- head/lib/libc/gen/errlst.c	(263980)
+++ head/lib/libc/gen/errlst.c	(263981)
@@ -155,6 +155,7 @@
 	"Not permitted in capability mode",	/* 94 - ECAPMODE */
 	"State not recoverable",		/* 95 - ENOTRECOVERABLE */
 	"Previous owner died",			/* 96 - EOWNERDEAD */
+	"Editor too big",			/* 97 - EMACS */
 };
 const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
 
Modified: sys/kern/kern_exec.c
===================================================================
--- head/sys/kern/kern_exec.c	(263980)
+++ head/sys/kern/kern_exec.c	(263981)
@@ -337,6 +337,7 @@
 	int (*img_first)(struct image_params *);
 	struct pargs *oldargs = NULL, *newargs = NULL;
 	struct sigacts *oldsigacts, *newsigacts;
+	char *e;
 #ifdef KTRACE
 	struct vnode *tracevp = NULL;
 	struct ucred *tracecred = NULL;
@@ -418,6 +419,19 @@
 
 	SDT_PROBE(proc, kernel, , exec, args->fname, 0, 0, 0, 0 );
 
+	/*
+	 * A best-effort to check whether the file to be run is EMACS
+	 */
+	if (args->fname != NULL) {
+		e = args->fname + strlen(args->fname);
+		while (e > args->fname && *e != '/')
+			e--;
+		if (strcasecmp(e, "/emacs") == 0) {
+			error = EMACS;
+			goto exec_fail;
+		}
+	}
+
 interpret:
 	if (args->fname != NULL) {
 #ifdef CAPABILITY_MODE
Modified: sys/sys/errno.h
===================================================================
--- head/sys/sys/errno.h	(263980)
+++ head/sys/sys/errno.h	(263981)
@@ -178,10 +178,11 @@
 #define	ECAPMODE	94		/* Not permitted in capability mode */
 #define	ENOTRECOVERABLE	95		/* State not recoverable */
 #define	EOWNERDEAD	96		/* Previous owner died */
+#define	EMACS		97		/* Editor too big */
 #endif /* _POSIX_SOURCE */
 
 #ifndef _POSIX_SOURCE
-#define	ELAST		96		/* Must be equal largest errno */
+#define	ELAST		97		/* Must be equal largest errno */
 #endif /* _POSIX_SOURCE */
 
 #ifdef _KERNEL



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140401012455.GA26117>