summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/fs/specfs/specvnops.c6
-rw-r--r--usr/src/uts/common/io/sysmsg.c3
-rw-r--r--usr/src/uts/common/os/session.c52
-rw-r--r--usr/src/uts/common/os/streamio.c4
-rw-r--r--usr/src/uts/common/os/strsubr.c65
-rw-r--r--usr/src/uts/common/sys/session.h40
-rw-r--r--usr/src/uts/common/sys/strsubr.h42
7 files changed, 74 insertions, 138 deletions
diff --git a/usr/src/uts/common/fs/specfs/specvnops.c b/usr/src/uts/common/fs/specfs/specvnops.c
index fa25bb3bb4..2dd8a792b0 100644
--- a/usr/src/uts/common/fs/specfs/specvnops.c
+++ b/usr/src/uts/common/fs/specfs/specvnops.c
@@ -685,9 +685,9 @@ streams_open:
/*
* try to allocate it as a controlling terminal
*/
- if ((stp->sd_flag & STRISTTY) && !(flag & FNOCTTY)) {
- strctty(stp);
- }
+ if ((stp->sd_flag & STRISTTY) && !(flag & FNOCTTY))
+ stralloctty(stp);
+
return (0);
}
diff --git a/usr/src/uts/common/io/sysmsg.c b/usr/src/uts/common/io/sysmsg.c
index 95aad728b9..085e27e4f2 100644
--- a/usr/src/uts/common/io/sysmsg.c
+++ b/usr/src/uts/common/io/sysmsg.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -48,6 +48,7 @@
#include <sys/uio.h>
#include <sys/stat.h>
#include <sys/file.h>
+#include <sys/session.h>
#include <sys/stream.h>
#include <sys/strsubr.h>
#include <sys/poll.h>
diff --git a/usr/src/uts/common/os/session.c b/usr/src/uts/common/os/session.c
index 13a52dc7c3..972677f7dc 100644
--- a/usr/src/uts/common/os/session.c
+++ b/usr/src/uts/common/os/session.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -35,16 +35,11 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/file.h>
-#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/errno.h>
#include <sys/signal.h>
-#include <sys/pcb.h>
#include <sys/cred.h>
#include <sys/policy.h>
-#include <sys/user.h>
-#include <sys/buf.h>
-#include <sys/var.h>
#include <sys/conf.h>
#include <sys/debug.h>
#include <sys/proc.h>
@@ -55,10 +50,6 @@
sess_t session0 = {
1, /* s_ref */
- 0555, /* s_mode */
- 0, /* s_uid */
- 0, /* s_gid */
- 0, /* s_ctime */
NODEV, /* s_dev */
NULL, /* s_vp */
&pid0, /* s_sidp */
@@ -120,10 +111,8 @@ sess_create(void)
void
freectty(sess_t *sp)
{
- vnode_t *vp;
- cred_t *cred;
-
- vp = sp->s_vp;
+ vnode_t *vp = sp->s_vp;
+ cred_t *cred = sp->s_cred;
strfreectty(vp->v_stream);
@@ -134,16 +123,15 @@ freectty(sess_t *sp)
ASSERT(sp->s_cnt == 0);
ASSERT(vp->v_count >= 1);
sp->s_vp = NULL;
- cred = sp->s_cred;
+ sp->s_cred = NULL;
/*
- * It is possible for the VOP_CLOSE below to call strctty
+ * It is possible for the VOP_CLOSE below to call stralloctty()
* and reallocate a new tty vnode. To prevent that the
* session is marked as closing here.
*/
sp->s_flag = SESS_CLOSE;
- sp->s_cred = NULL;
mutex_exit(&sp->s_lock);
/*
@@ -166,14 +154,14 @@ freectty(sess_t *sp)
* Used by privileged users to give a "clean" terminal at login
*/
int
-vhangup()
+vhangup(void)
{
if (secpolicy_sys_config(CRED(), B_FALSE) != 0)
return (set_errno(EPERM));
/*
* This routine used to call freectty() under a condition that
* could never happen. So this code has never actually done
- * anything, and evidently nobody has ever noticed. 4098399.
+ * anything, and evidently nobody has ever noticed.
*/
return (0);
}
@@ -200,30 +188,4 @@ alloctty(proc_t *pp, vnode_t *vp)
crhold(crp = pp->p_cred);
mutex_exit(&pp->p_crlock);
sp->s_cred = crp;
- sp->s_uid = crgetuid(crp);
- sp->s_ctime = gethrestime_sec();
- if (session0.s_mode & VSGID)
- sp->s_gid = session0.s_gid;
- else
- sp->s_gid = crgetgid(crp);
- sp->s_mode = (0666 & ~(PTOU(pp)->u_cmask));
-}
-
-int
-hascttyperm(sess_t *sp, cred_t *cr, mode_t mode)
-{
- int shift = 0;
-
- if (crgetuid(cr) != sp->s_uid) {
- shift += 3;
- if (!groupmember(sp->s_gid, cr))
- shift += 3;
- }
-
- mode &= ~(sp->s_mode << shift);
-
- if (mode == 0)
- return (1);
-
- return (secpolicy_vnode_access(cr, sp->s_vp, sp->s_uid, mode) == 0);
}
diff --git a/usr/src/uts/common/os/streamio.c b/usr/src/uts/common/os/streamio.c
index 7c3de87018..1995c8ad34 100644
--- a/usr/src/uts/common/os/streamio.c
+++ b/usr/src/uts/common/os/streamio.c
@@ -395,7 +395,7 @@ ckreturn:
SQ_CI|SQ_CO, B_FALSE);
set_qend(qp);
- stp->sd_strtab = (struct streamtab *)fifo_getinfo();
+ stp->sd_strtab = fifo_getinfo();
_WR(qp)->q_nfsrv = _WR(qp);
qp->q_nfsrv = qp;
/*
@@ -3761,7 +3761,7 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag,
/*
* try to allocate it as a controlling terminal
*/
- strctty(stp);
+ stralloctty(stp);
}
}
diff --git a/usr/src/uts/common/os/strsubr.c b/usr/src/uts/common/os/strsubr.c
index b3826021d3..17e0cf8403 100644
--- a/usr/src/uts/common/os/strsubr.c
+++ b/usr/src/uts/common/os/strsubr.c
@@ -76,6 +76,7 @@
#include <sys/multidata.h>
#include <sys/pattr.h>
#include <sys/strft.h>
+#include <sys/fs/snode.h>
#include <sys/zone.h>
#define O_SAMESTR(q) (((q)->q_next) && \
@@ -3977,15 +3978,33 @@ strhup(stdata_t *stp)
}
void
-stralloctty(sess_t *sp, stdata_t *stp)
+stralloctty(stdata_t *stp)
{
+ proc_t *p = curproc;
+ sess_t *sp = p->p_sessp;
+
mutex_enter(&stp->sd_lock);
- mutex_enter(&pidlock);
- stp->sd_sidp = sp->s_sidp;
- stp->sd_pgidp = sp->s_sidp;
- PID_HOLD(stp->sd_pgidp);
- PID_HOLD(stp->sd_sidp);
- mutex_exit(&pidlock);
+ /*
+ * No need to hold the session lock or do a TTY_HOLD() because
+ * this is the only thread that can be the session leader and not
+ * have a controlling tty.
+ */
+ if ((stp->sd_flag &
+ (STRHUP|STRDERR|STWRERR|STPLEX|STRISTTY)) == STRISTTY &&
+ stp->sd_sidp == NULL && /* not allocated as ctty */
+ sp->s_sidp == p->p_pidp && /* session leader */
+ sp->s_flag != SESS_CLOSE && /* session is not closing */
+ sp->s_vp == NULL) { /* without ctty */
+ ASSERT(stp->sd_pgidp == NULL);
+ alloctty(p, makectty(stp->sd_vnode));
+
+ mutex_enter(&pidlock);
+ stp->sd_sidp = sp->s_sidp;
+ stp->sd_pgidp = sp->s_sidp;
+ PID_HOLD(stp->sd_pgidp);
+ PID_HOLD(stp->sd_sidp);
+ mutex_exit(&pidlock);
+ }
mutex_exit(&stp->sd_lock);
}
@@ -4004,38 +4023,8 @@ strfreectty(stdata_t *stp)
if (!(stp->sd_flag & STRHUP))
strhup(stp);
}
-
-void
-strctty(stdata_t *stp)
-{
- extern vnode_t *makectty();
- proc_t *p = curproc;
- sess_t *sp = p->p_sessp;
-
- mutex_enter(&stp->sd_lock);
- /*
- * No need to hold the session lock or do a TTYHOLD,
- * because this is the only thread that can be the
- * session leader and not have a controlling tty.
- */
- if ((stp->sd_flag & (STRHUP|STRDERR|STWRERR|STPLEX)) == 0 &&
- stp->sd_sidp == NULL && /* not allocated as ctty */
- sp->s_sidp == p->p_pidp && /* session leader */
- sp->s_flag != SESS_CLOSE && /* session is not closing */
- sp->s_vp == NULL) { /* without ctty */
- mutex_exit(&stp->sd_lock);
- ASSERT(stp->sd_pgidp == NULL);
- alloctty(p, makectty(stp->sd_vnode));
- stralloctty(sp, stp);
- mutex_enter(&stp->sd_lock);
- stp->sd_flag |= STRISTTY; /* just to be sure */
- }
- mutex_exit(&stp->sd_lock);
-}
-
/*
- * enable first back queue with svc procedure.
- * Use pri == -1 to avoid the setqback
+ * Backenable the first queue upstream from `q' with a service procedure.
*/
void
backenable(queue_t *q, uchar_t pri)
diff --git a/usr/src/uts/common/sys/session.h b/usr/src/uts/common/sys/session.h
index 26252686c4..639d6bf69d 100644
--- a/usr/src/uts/common/sys/session.h
+++ b/usr/src/uts/common/sys/session.h
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -38,36 +38,20 @@ extern "C" {
#endif
typedef struct sess {
- uint_t s_ref; /* reference count */
- mode_t s_mode; /* /sess current permissions */
- uid_t s_uid; /* /sess current user ID */
- gid_t s_gid; /* /sess current group ID */
- time_t s_ctime; /* /sess change time */
- dev_t s_dev; /* tty's device number */
- struct vnode *s_vp; /* tty's vnode */
- struct pid *s_sidp; /* session ID info */
- struct cred *s_cred; /* allocation credentials */
- kmutex_t s_lock; /* sync s_vp use with freectty */
- kcondvar_t s_wait_cv; /* Condvar for sleeping */
- int s_cnt; /* # of active users of this session */
- int s_flag; /* session state flag see below */
+ uint_t s_ref; /* reference count */
+ dev_t s_dev; /* tty's device number */
+ struct vnode *s_vp; /* tty's vnode */
+ struct pid *s_sidp; /* session ID info */
+ struct cred *s_cred; /* allocation credentials */
+ kmutex_t s_lock; /* sync s_vp use with freectty */
+ kcondvar_t s_wait_cv; /* Condvar for sleeping */
+ int s_cnt; /* # of active users of this session */
+ int s_flag; /* session state flag see below */
} sess_t;
#define SESS_CLOSE 1 /* session about to close */
#define s_sid s_sidp->pid_id
-/*
- * Enumeration of the types of access that can be requested for a
- * controlling terminal under job control.
- */
-
-enum jcaccess {
- JCREAD, /* read data on a ctty */
- JCWRITE, /* write data to a ctty */
- JCSETP, /* set ctty parameters */
- JCGETP /* get ctty parameters */
-};
-
#if defined(_KERNEL)
extern sess_t session0;
@@ -76,7 +60,7 @@ extern sess_t session0;
#define SESS_RELE(sp) sess_rele(sp)
/*
- * Used to synchronizing sessions vnode users with freectty
+ * Used to synchronize session vnode users with freectty()
*/
#define TTY_HOLD(sp) { \
@@ -94,7 +78,6 @@ extern sess_t session0;
/* forward referenced structure tags */
struct vnode;
-struct cred;
struct proc;
extern void sess_rele(sess_t *);
@@ -102,7 +85,6 @@ extern void sess_create(void);
extern void freectty(sess_t *);
extern void alloctty(struct proc *, struct vnode *);
extern dev_t cttydev(struct proc *);
-extern int hascttyperm(sess_t *, struct cred *, mode_t);
#endif /* defined(_KERNEL) */
diff --git a/usr/src/uts/common/sys/strsubr.h b/usr/src/uts/common/sys/strsubr.h
index 724cfea077..4151204cd3 100644
--- a/usr/src/uts/common/sys/strsubr.h
+++ b/usr/src/uts/common/sys/strsubr.h
@@ -42,13 +42,9 @@
*/
#include <sys/stream.h>
#include <sys/stropts.h>
-#include <sys/session.h>
#include <sys/kstat.h>
#include <sys/uio.h>
#include <sys/proc.h>
-#include <vm/as.h>
-#include <vm/page.h>
-#include <vm/anon.h>
#ifdef __cplusplus
extern "C" {
@@ -768,6 +764,17 @@ typedef struct cdevsw_impl {
} cdevsw_impl_t;
/*
+ * Enumeration of the types of access that can be requested for a
+ * controlling terminal under job control.
+ */
+enum jcaccess {
+ JCREAD, /* read data on a ctty */
+ JCWRITE, /* write data to a ctty */
+ JCSETP, /* set ctty parameters */
+ JCGETP /* get ctty parameters */
+};
+
+/*
* Finding related queues
*/
#define STREAM(q) ((q)->q_stream)
@@ -1082,7 +1089,6 @@ extern int strputmsg(vnode_t *, struct strbuf *, struct strbuf *, uchar_t,
int flag, int fmode);
extern int strstartplumb(struct stdata *, int, int);
extern void strendplumb(struct stdata *);
-extern struct streamtab *fifo_getinfo(void);
extern int stropen(struct vnode *, dev_t *, int, cred_t *);
extern int strclose(struct vnode *, int, cred_t *);
extern int strpoll(register struct stdata *, short, int, short *,
@@ -1101,8 +1107,7 @@ extern mblk_t *strrput_misc(vnode_t *, mblk_t *,
extern int getiocseqno(void);
extern int strwaitbuf(size_t, int);
extern int strwaitq(stdata_t *, int, ssize_t, int, clock_t, int *);
-extern void strctty(struct stdata *);
-extern void stralloctty(sess_t *, struct stdata *);
+extern void stralloctty(struct stdata *);
extern void strfreectty(struct stdata *);
extern struct stdata *shalloc(queue_t *);
extern void shfree(struct stdata *s);
@@ -1116,13 +1121,11 @@ extern int strcopyin(void *, void *, size_t, int);
extern int strcopyout(void *, void *, size_t, int);
extern void strsignal(struct stdata *, int, int32_t);
extern clock_t str_cv_wait(kcondvar_t *, kmutex_t *, clock_t, int);
-extern void runbuffcalls(void);
extern void disable_svc(queue_t *);
extern void remove_runlist(queue_t *);
extern void wait_svc(queue_t *);
extern void backenable(queue_t *, uchar_t);
extern void set_qend(queue_t *);
-extern void set_qnexthot(queue_t *);
extern int strgeterr(stdata_t *, int32_t, int);
extern void qenable_locked(queue_t *);
extern mblk_t *getq_noenab(queue_t *);
@@ -1142,7 +1145,6 @@ extern void claimstr(queue_t *);
extern void releasestr(queue_t *);
extern void removeq(queue_t *);
extern void insertq(struct stdata *, queue_t *);
-extern void fill_syncq(syncq_t *, queue_t *, mblk_t *, void (*)());
extern void drain_syncq(syncq_t *);
extern void qfill_syncq(syncq_t *, queue_t *, mblk_t *);
extern void qdrain_syncq(syncq_t *, queue_t *);
@@ -1179,22 +1181,22 @@ extern mblk_t *allocb_cred(size_t, cred_t *);
extern mblk_t *allocb_cred_wait(size_t, uint_t, int *, cred_t *);
extern mblk_t *allocb_tmpl(size_t, const mblk_t *);
extern void mblk_setcred(mblk_t *, cred_t *);
-void strpollwakeup(vnode_t *, short);
+extern void strpollwakeup(vnode_t *, short);
extern int putnextctl_wait(queue_t *, int);
-int kstrputmsg(struct vnode *, mblk_t *, struct uio *, ssize_t,
+extern int kstrputmsg(struct vnode *, mblk_t *, struct uio *, ssize_t,
unsigned char, int, int);
-int kstrgetmsg(struct vnode *, mblk_t **, struct uio *,
+extern int kstrgetmsg(struct vnode *, mblk_t **, struct uio *,
unsigned char *, int *, clock_t, rval_t *);
extern int kstrwritemp(struct vnode *, mblk_t *, ushort_t);
-void strsetrerror(vnode_t *, int, int, errfunc_t);
-void strsetwerror(vnode_t *, int, int, errfunc_t);
-void strseteof(vnode_t *, int);
-void strflushrq(vnode_t *, int);
-void strsetrputhooks(vnode_t *, uint_t, msgfunc_t, msgfunc_t);
-void strsetwputhooks(vnode_t *, uint_t, clock_t);
-int strwaitmark(vnode_t *);
+extern void strsetrerror(vnode_t *, int, int, errfunc_t);
+extern void strsetwerror(vnode_t *, int, int, errfunc_t);
+extern void strseteof(vnode_t *, int);
+extern void strflushrq(vnode_t *, int);
+extern void strsetrputhooks(vnode_t *, uint_t, msgfunc_t, msgfunc_t);
+extern void strsetwputhooks(vnode_t *, uint_t, clock_t);
+extern int strwaitmark(vnode_t *);
extern void strsignal_nolock(stdata_t *, int, int32_t);
struct multidata_s;