Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jul 2015 23:10:00 +0000 (UTC)
From:      Jamie Gritton <jamie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r285344 - stable/9/usr.sbin/jls
Message-ID:  <201507092310.t69NA0Sg047306@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jamie
Date: Thu Jul  9 23:09:59 2015
New Revision: 285344
URL: https://svnweb.freebsd.org/changeset/base/285344

Log:
  MFC r279081:
  
    Allow parameters listed on the command line to override the -v option,
    instead of crashing.
  
  MFC r279083:
  
    Fix the logic for skipping parameters (with -s) that have "jailsys"
    parents (such as host.hostname); these were being skipped all the time.
    That it went this long without anyone noticing is a sign that this feature
    isn't actually used by anyone, but it's there so it might as well work.
  
  MFC r279123:
  
    Allow for parameters added with the JP_OPT flag to not exist.
    That's why the flag exists in the first place.

Modified:
  stable/9/usr.sbin/jls/jls.8
  stable/9/usr.sbin/jls/jls.c
Directory Properties:
  stable/9/usr.sbin/jls/   (props changed)

Modified: stable/9/usr.sbin/jls/jls.8
==============================================================================
--- stable/9/usr.sbin/jls/jls.8	Thu Jul  9 22:55:43 2015	(r285343)
+++ stable/9/usr.sbin/jls/jls.8	Thu Jul  9 23:09:59 2015	(r285344)
@@ -92,7 +92,8 @@ skipping read-only and unused parameters
 Implies
 .Fl nq .
 .It Fl v
-Print a multiple-line summary per jail, with the following parameters:
+Extend the standard display with a multiple-line summary per jail,
+containing the following parameters:
 jail identifier (jid), hostname (host.hostname), path (path),
 jail name (name), jail state (dying), cpuset ID (cpuset),
 IP address(es) (ip4.addr and ip6.addr).

Modified: stable/9/usr.sbin/jls/jls.c
==============================================================================
--- stable/9/usr.sbin/jls/jls.c	Thu Jul  9 22:55:43 2015	(r285343)
+++ stable/9/usr.sbin/jls/jls.c	Thu Jul  9 23:09:59 2015	(r285344)
@@ -78,7 +78,7 @@ static void quoted_print(char *str);
 int
 main(int argc, char **argv)
 {
-	char *dot, *ep, *jname;
+	char *dot, *ep, *jname, *pname;
 	int c, i, jflags, jid, lastjid, pflags, spc;
 
 	jname = NULL;
@@ -166,20 +166,23 @@ main(int argc, char **argv)
 			    JP_USER);
 			add_param("path", NULL, (size_t)0, NULL, JP_USER);
 		}
-	} else
+	} else {
+		pflags &= ~PRINT_VERBOSE;
 		while (optind < argc)
 			add_param(argv[optind++], NULL, (size_t)0, NULL,
 			    JP_USER);
+	}
 
 	if (pflags & PRINT_SKIP) {
 		/* Check for parameters with jailsys parents. */
 		for (i = 0; i < nparams; i++) {
 			if ((params[i].jp_flags & JP_USER) &&
 			    (dot = strchr(params[i].jp_name, '.'))) {
-				*dot = 0;
-				param_parent[i] = add_param(params[i].jp_name,
+				pname = alloca((dot - params[i].jp_name) + 1);
+				strlcpy(pname, params[i].jp_name,
+				    (dot - params[i].jp_name) + 1);
+				param_parent[i] = add_param(pname,
 				    NULL, (size_t)0, NULL, JP_OPT);
-				*dot = '.';
 			}
 		}
 	}
@@ -291,10 +294,8 @@ add_param(const char *name, void *value,
 		param->jp_flags |= flags;
 		return param - params;
 	}
-	if (jailparam_init(param, name) < 0)
-		errx(1, "%s", jail_errmsg);
-	param->jp_flags = flags;
-	if ((value != NULL ? jailparam_import_raw(param, value, valuelen)
+	if (jailparam_init(param, name) < 0 ||
+	    (value != NULL ? jailparam_import_raw(param, value, valuelen)
 	     : jailparam_import(param, value)) < 0) {
 		if (flags & JP_OPT) {
 			nparams--;
@@ -302,6 +303,7 @@ add_param(const char *name, void *value,
 		}
 		errx(1, "%s", jail_errmsg);
 	}
+	param->jp_flags = flags;
 	return param - params;
 }
 



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