summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2016-01-05 13:20:09 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2016-01-05 13:20:09 +0000
commitda23f36f016ed51e3d1707664da2172a46799961 (patch)
tree542401bd36939ac36823a0e2f606e2bda92b3144 /usr/src
parent868cd820b6534e45f39de361588679b937996b01 (diff)
parentf285096a3146a243a565abdce1ba710a9ce24b0b (diff)
downloadillumos-joyent-da23f36f016ed51e3d1707664da2172a46799961.tar.gz
[illumos-gate merge]
commit f285096a3146a243a565abdce1ba710a9ce24b0b 6535 Add pbind -e commit 3970ef31ccf022ca6d11dfb49d296ee0cbcd45a6 6540 pam_unix_session needs to support nowarn option
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/pbind/pbind.c73
-rw-r--r--usr/src/lib/pam_modules/unix_session/unix_session.c7
-rw-r--r--usr/src/man/man1m/pbind.1m67
-rw-r--r--usr/src/man/man5/pam_unix_session.512
4 files changed, 130 insertions, 29 deletions
diff --git a/usr/src/cmd/pbind/pbind.c b/usr/src/cmd/pbind/pbind.c
index bc58cde6ad..1e9d5e2efb 100644
--- a/usr/src/cmd/pbind/pbind.c
+++ b/usr/src/cmd/pbind/pbind.c
@@ -20,12 +20,11 @@
* CDDL HEADER END
*/
/*
+ * Copyright 2015 Ryan Zezeski
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* pbind - bind a process to a processor (non-exclusively)
*/
@@ -54,6 +53,7 @@
static char *progname;
static char bflag;
+static char eflag;
static char qflag;
static char Qflag;
static char uflag;
@@ -165,17 +165,17 @@ bind_out(id_t pid, id_t lwpid, processorid_t old, processorid_t new)
if (old == PBIND_NONE) {
if (new == PBIND_NONE)
(void) printf(gettext("%s id %s: was not bound, "
- "now not bound\n"), proclwp, pidstr);
+ "now not bound\n"), proclwp, pidstr);
else
(void) printf(gettext("%s id %s: was not bound, "
- "now %d\n"), proclwp, pidstr, new);
+ "now %d\n"), proclwp, pidstr, new);
} else {
if (new == PBIND_NONE)
(void) printf(gettext("%s id %s: was %d, "
- "now not bound\n"), proclwp, pidstr, old);
+ "now not bound\n"), proclwp, pidstr, old);
else
(void) printf(gettext("%s id %s: was %d, "
- "now %d\n"), proclwp, pidstr, old, new);
+ "now %d\n"), proclwp, pidstr, old, new);
}
}
@@ -345,11 +345,45 @@ query_all_lwp(psinfo_t *psinfo, lwpsinfo_t *lwpsinfo, void *arg)
return (0);
}
+/*
+ * Execute the cmd with args while bound to cpu. Does not return:
+ * either executes cmd successfully or dies trying.
+ */
+static void
+exec_cmd(processorid_t cpu, char *cmd, char **args)
+{
+ if (processor_bind(P_PID, P_MYID, cpu, NULL) == -1) {
+ bind_err(cpu, getpid(), -1, errno);
+ exit(ERR_FAIL);
+ }
+
+ if (execvp(cmd, args) == -1)
+ die(gettext("failed to exec %s\n"), cmd);
+}
+
+/*
+ * Attempt to parse str as a CPU identifier. Return the identifier or
+ * die.
+ */
+static processorid_t
+parse_cpu(char *str)
+{
+ processorid_t cpu;
+ char *endstr;
+
+ cpu = strtol(str, &endstr, 10);
+ if (endstr != NULL && *endstr != '\0' || cpu < 0)
+ die(gettext("invalid processor ID %s\n"), optarg);
+
+ return (cpu);
+}
+
static int
usage(void)
{
(void) fprintf(stderr,
gettext("usage: \n\t%1$s -b processor_id pid[/lwpids] ...\n"
+ "\t%1$s -e processor_id cmd [args...]\n"
"\t%1$s -U [processor_id] ...\n"
"\t%1$s -Q [processor_id] ...\n"
"\t%1$s -u pid[/lwpids] ...\n"
@@ -372,15 +406,17 @@ main(int argc, char *argv[])
(void) setlocale(LC_ALL, ""); /* setup localization */
(void) textdomain(TEXT_DOMAIN);
- while ((c = getopt(argc, argv, "b:qQuU")) != EOF) {
+ while ((c = getopt(argc, argv, "b:e:qQuU")) != EOF) {
switch (c) {
case 'b':
bflag = 1;
- cpu = strtol(optarg, &endstr, 10);
- if (endstr != NULL && *endstr != '\0' || cpu < 0)
- die(gettext("invalid processor ID %s\n"),
- optarg);
+ cpu = parse_cpu(optarg);
+ break;
+
+ case 'e':
+ eflag = 1;
+ cpu = parse_cpu(optarg);
break;
case 'q':
@@ -409,15 +445,15 @@ main(int argc, char *argv[])
/*
- * Make sure that at most one of the options b, q, Q, u, or U
- * was specified.
+ * Make sure that at most one of the options b, e, q, Q, u, or
+ * U was specified.
*/
- c = bflag + qflag + Qflag + uflag + Uflag;
+ c = bflag + eflag + qflag + Qflag + uflag + Uflag;
if (c < 1) { /* nothing specified */
qflag = 1; /* default to query */
cpu = PBIND_QUERY;
} else if (c > 1) {
- warn(gettext("options -b, -q, -Q, -u and -U "
+ warn(gettext("options -b, -e, -q, -Q, -u and -U "
"are mutually exclusive\n"));
return (usage());
}
@@ -434,6 +470,10 @@ main(int argc, char *argv[])
warn(gettext("must specify at least one pid\n"));
return (usage());
}
+ if (eflag) {
+ warn(gettext("must specify command\n"));
+ return (usage());
+ }
if (Uflag) {
if (processor_bind(P_ALL, 0, PBIND_NONE, &old_cpu) != 0)
die(gettext("failed to unbind some LWPs"));
@@ -447,6 +487,9 @@ main(int argc, char *argv[])
}
}
+ if (eflag)
+ exec_cmd(cpu, argv[0], argv);
+
if (Qflag || Uflag) {
/*
* Go through listed processor IDs.
diff --git a/usr/src/lib/pam_modules/unix_session/unix_session.c b/usr/src/lib/pam_modules/unix_session/unix_session.c
index 862730dd86..b121b26a1b 100644
--- a/usr/src/lib/pam_modules/unix_session/unix_session.c
+++ b/usr/src/lib/pam_modules/unix_session/unix_session.c
@@ -23,6 +23,7 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Lauri Tirkkonen.
+ * Copyright 2016 Toomas Soome <tsoome@me.com>
*/
#include <strings.h>
@@ -70,7 +71,7 @@ struct lastlog_legacy {
/*ARGSUSED*/
int
pam_sm_close_session(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
+ const char **argv)
{
int i;
int debug = 0;
@@ -201,7 +202,7 @@ rewrite:
/*ARGSUSED*/
int
pam_sm_open_session(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
+ const char **argv)
{
int error;
char *ttyn, *rhost, *user;
@@ -219,6 +220,8 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc,
for (i = 0; i < argc; i++) {
if (strcasecmp(argv[i], "debug") == 0)
debug = 1;
+ else if (strcasecmp(argv[i], "nowarn") == 0)
+ flags = flags | PAM_SILENT;
else
syslog(LOG_ERR, "illegal option %s", argv[i]);
}
diff --git a/usr/src/man/man1m/pbind.1m b/usr/src/man/man1m/pbind.1m
index bcedec12f4..92ddfe5933 100644
--- a/usr/src/man/man1m/pbind.1m
+++ b/usr/src/man/man1m/pbind.1m
@@ -1,4 +1,5 @@
'\" te
+.\" Copyright 2015 Ryan Zezeski
.\" Copyright (c) 2008, Sun Microsystems, Inc.
.\" All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
@@ -15,6 +16,11 @@ pbind \- control and query bindings of processes or LWPs
.LP
.nf
+\fBpbind\fR \fB-e\fR \fIprocessor_id\fR \fIcmd\fR [\fIargs\fR...]
+.fi
+
+.LP
+.nf
\fBpbind\fR [\fB-q\fR] [\fIpid\fR [\fI/lwpid\fR]]...
.fi
@@ -34,7 +40,6 @@ pbind \- control and query bindings of processes or LWPs
.fi
.SH DESCRIPTION
-.sp
.LP
\fBpbind\fR controls and queries bindings of processes and LWPs (lightweight
processes) to processors. \fBpbind\fR can also remove processor bindings that
@@ -52,11 +57,15 @@ have the same binding. Binding an interactive shell to a processor, for
example, binds all commands executed by the shell.
.sp
.LP
+The \fIprocessor_id\fR must be present and on-line. Use the
+\fBpsrinfo(1M)\fR command to determine which processors are
+available.
+.sp
+.LP
Superusers may bind or unbind any process or LWP, while other users can bind or
unbind any process or LWP for which they have permission to signal, that is,
any process that has the same effective user ID as the user.
.SH OPTIONS
-.sp
.LP
The following options are supported:
.sp
@@ -66,11 +75,18 @@ The following options are supported:
.ad
.sp .6
.RS 4n
-Binds all or a subset of the LWPs of the specified processes to the processor
-\fIprocessor_id\fR. Specify \fIprocessor_id\fR as the processor \fBID\fR of the
-processor to be controlled or queried. \fIprocessor_id\fR must be present and
-on-line. Use the \fBpsrinfo\fR command to determine whether or not
-\fIprocessor_id\fR is present and on-line. See \fBpsrinfo\fR(1M).
+Binds all or a subset of the LWPs of the specified processes to
+\fIprocessor_id\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB-e\fR \fIprocessor_id\fR
+.ad
+.sp .6
+.RS 4n
+Execute a command while bound to \fIprocessor_id\fR.
.RE
.sp
@@ -123,7 +139,6 @@ to any processor if no argument is specified.
.RE
.SH OPERANDS
-.sp
.LP
The following operands are supported:
.sp
@@ -166,6 +181,16 @@ syntax for selecting \fBLWP\fR \fBID\fRs is as follows:
The processor \fBID\fR of the processor to be controlled or queried.
.RE
+.sp
+.ne 2
+.na
+\fB\fIcmd\fR \fI[args...]\fR
+.ad
+.sp .6
+.RS 4n
+The command to execute along with optional arguments.
+.RE
+
.SH EXAMPLES
.LP
\fBExample 1 \fRBinding Processes
@@ -249,9 +274,22 @@ lwp id 149/5: 2
.in -2
.sp
-.SH EXIT STATUS
+.LP
+\fBExample 6 \fRExecuting a bound command:
.sp
.LP
+The following example executes ls while bound to processor 6:
+
+.sp
+.in +2
+.nf
+example% \fBpbind -e 6 ls -la
+.fi
+.in -2
+.sp
+
+.SH EXIT STATUS
+.LP
The following exit values are returned:
.sp
.ne 2
@@ -274,12 +312,10 @@ An error occurred.
.RE
.SH SEE ALSO
-.sp
.LP
\fBpsradm\fR(1M), \fBpsrinfo\fR(1M), \fBpsrset\fR(1M), \fBprocessor_bind\fR(2),
\fBprocessor_info\fR(2), \fBsysconf\fR(3C), \fBattributes\fR(5)
.SH DIAGNOSTICS
-.sp
.ne 2
.na
\fB\fBpbind: cannot query pid 31: No such process\fR\fR
@@ -309,3 +345,12 @@ The user does not have permission to bind the process.
The specified processor is not on-line.
.RE
+.sp
+.ne 2
+.na
+\fBpbind: failed to exec\fR \fIcmd\fR
+.ad
+.sp .6
+.RS 4n
+Could not resolve the \fIcmd\fR from \fBPATH\fR.
+.RE
diff --git a/usr/src/man/man5/pam_unix_session.5 b/usr/src/man/man5/pam_unix_session.5
index 73c8dd07a8..c9598ac1f5 100644
--- a/usr/src/man/man5/pam_unix_session.5
+++ b/usr/src/man/man5/pam_unix_session.5
@@ -1,10 +1,11 @@
'\" te
+.\" Copyright 2016 Toomas Soome <tsoome@me.com>
.\" Copyright (C) 2002, Sun Microsystems, Inc.
.\" All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH PAM_UNIX_SESSION 5 "Nov 9, 2015"
+.TH PAM_UNIX_SESSION 5 "Jan 3, 2016"
.SH NAME
pam_unix_session \- session management PAM module for UNIX
.SH SYNOPSIS
@@ -39,6 +40,15 @@ The following options can be passed to the module:
\fBsyslog\fR(3C) debugging information at the \fBLOG_DEBUG\fR level
.RE
+.sp
+.ne 2
+.na
+\fB\fBnowarn\fR\fR
+.ad
+.RS 9n
+Turn off last login PAM_TEXT_INFO message.
+.RE
+
.SH ERRORS
.LP
Upon successful completion, \fBPAM_SUCCESS\fR is returned. The following error