svn commit: r263981 - in head: lib/libc/gen sys/kern sys/sys

Mateusz Guzik mjg at freebsd.org
Tue Apr 1 01:25:01 UTC 2014


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


More information about the svn-src-head mailing list