[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
I have attached a couple more drawterm patches that may be of
interest, and a Make.alsa configuration file
the alsa patches change devaudio.c a little bit to add audiodevread
support which (only) devaudio-alsa.c uses
the bindflags patch adds -R and -C options to not bind /mnt/term/root
and /mnt/term/cmd respectively for a slightly more secure drawterm
session. I tried to do the same for -I with /mnt/term/net to disallow
using drawterm's networking but then it just wouldn't connect at all
[-- Attachment #2: drawterm.bindflags.patch --]
[-- Type: text/x-patch, Size: 2442 bytes --]
diff --git a/cpu.c b/cpu.c
index 9cb2a2f..58bdd7a 100644
--- a/cpu.c
+++ b/cpu.c
@@ -243,7 +243,7 @@ ncpu(char *host, char *cmd)
void
usage(void)
{
- fprint(2, "usage: %s [-GBO] "
+ fprint(2, "usage: %s [-GBORC] "
"[-h host] [-u user] [-a authserver] [-s secstore] "
"[-e 'crypt hash'] [-k keypattern] "
"[-p] [-t timeout] "
@@ -260,7 +260,12 @@ extern void cpubody(void);
void
cpumain(int argc, char **argv)
{
- char *s;
+ char *s, *root;
+ int bindcmd, bindroot;
+
+ bindroot = 1;
+ root = nil;
+ bindcmd = 1;
user = getenv("USER");
if((pass = getenv("PASS")) != nil)
@@ -305,11 +310,8 @@ cpumain(int argc, char **argv)
user = EARGF(usage());
break;
case 'r':
- s = smprint("/root/%s", EARGF(usage()));
- cleanname(s);
- if(bind(s, "/root", MREPL) < 0)
- panic("bind /root: %r");
- free(s);
+ root = smprint("/root/%s", EARGF(usage()));
+ cleanname(root);
break;
case 'c':
cmd = estrdup(EARGF(usage()));
@@ -325,10 +327,29 @@ cpumain(int argc, char **argv)
*/
geometry = EARGF(usage());
break;
+ case 'R':
+ bindroot = 0;
+ break;
+ case 'C':
+ bindcmd = 0;
+ break;
default:
usage();
}ARGEND;
+ if (bindcmd)
+ bind("#C", "/", MAFTER);
+
+ if (bindroot || (root != nil))
+ if(bind("#U", "/root", MREPL) < 0)
+ panic("bind #U: %r");
+
+ if (root != nil) {
+ if(bind(root, "/root", MREPL) < 0)
+ panic("bind /root: %r");
+ free(root);
+ }
+
if(argc != 0)
usage();
diff --git a/drawterm.1 b/drawterm.1
index 4113738..c7d1443 100644
--- a/drawterm.1
+++ b/drawterm.1
@@ -6,7 +6,7 @@ drawterm \- connection to cpu, fs, and auth servers
.SH SYNOPSIS
.B drawterm
[
-.B -GBO
+.B -GBORC
] [
.B -h
.I host
@@ -65,6 +65,22 @@ Use the old
to connect to the cpu server rather than
.IR rcpu (1)\fR.
+.TP
+.B -R
+Do not bind terminal root at
+.I /mnt/term/root
+unless
+.B -r \fIroot
+is also specified.
+
+.TP
+.B -C
+Do not bind
+.I /mnt/term/cmd
+for
+.IR os (1)
+command.
+
.TP
.B -h \fIhost
Connect to \fIhost\fR for cpu.
diff --git a/main.c b/main.c
index e66c81a..889704f 100644
--- a/main.c
+++ b/main.c
@@ -51,11 +51,8 @@ main(int argc, char **argv)
panic("bind #e: %r");
if(bind("#I", "/net", MBEFORE) < 0)
panic("bind #I: %r");
- if(bind("#U", "/root", MREPL) < 0)
- panic("bind #U: %r");
bind("#A", "/dev", MAFTER);
bind("#N", "/dev", MAFTER);
- bind("#C", "/", MAFTER);
if(open("/dev/cons", OREAD) != 0)
panic("open0: %r");
[-- Attachment #3: drawterm.alsa.patch --]
[-- Type: text/x-patch, Size: 2864 bytes --]
diff --git a/kern/devaudio-alsa.c b/kern/devaudio-alsa.c
index 30dfd60..9c0405b 100644
--- a/kern/devaudio-alsa.c
+++ b/kern/devaudio-alsa.c
@@ -25,22 +25,22 @@ void
audiodevopen(void)
{
if(snd_pcm_open(&playback, "default", SND_PCM_STREAM_PLAYBACK, 0) < 0)
- error("snd_pcm_open playback");
+ error("snd_pcm_open(playback)");
if(snd_pcm_set_params(playback, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 2, speed, 1, 500000) < 0)
- error("snd_pcm_set_params playback");
+ error("snd_pcm_set_params(playback)");
if(snd_pcm_prepare(playback) < 0)
- error("snd_pcm_prepare playback");
+ error("snd_pcm_prepare(playback)");
if(snd_pcm_open(&capture, "default", SND_PCM_STREAM_CAPTURE, 0) < 0)
- error("snd_pcm_open capture");
+ error("snd_pcm_open(capture)");
if(snd_pcm_set_params(capture, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 2, speed, 1, 500000) < 0)
- error("snd_pcm_set_params capture");
+ error("snd_pcm_set_params(capture)");
if(snd_pcm_prepare(capture) < 0)
- error("snd_pcm_prepare capture");
+ error("snd_pcm_prepare(capture)");
}
void
@@ -85,7 +85,7 @@ audiodevwrite(void *v, int n)
if (frames < 0)
frames = snd_pcm_recover(playback, frames, 0);
if (frames < 0)
- error((char*)snd_strerror(frames));
+ error("snd_pcm_writei");
m = frames*4;
}
@@ -100,9 +100,11 @@ audiodevread(void *v, int n)
do {
frames = snd_pcm_readi(capture, v, n/4);
} while(frames == -EAGAIN);
-
if (frames < 0)
- error((char*)snd_strerror(frames));
+ frames = snd_pcm_recover(capture, frames, 0);
+ if (frames < 0)
+ error("snd_pcm_readi");
return frames*4;
}
+
diff --git a/kern/devaudio.c b/kern/devaudio.c
index 1655262..0009994 100644
--- a/kern/devaudio.c
+++ b/kern/devaudio.c
@@ -14,6 +14,7 @@ enum
Aclosed = 0,
Aread,
Awrite,
+ Ardwr,
Speed = 44100,
Ncmd = 50, /* max volume command words */
@@ -31,7 +32,7 @@ static struct
{
QLock lk;
Rendez vous;
- int amode; /* Aclosed/Aread/Awrite for /audio */
+ int amode; /* Aclosed/Aread/Awrite/Ardwr for /audio */
} audio;
#define aqlock(a) qlock(&(a)->lk)
@@ -114,6 +115,8 @@ audioopen(Chan *c, int omode)
amode = Awrite;
if((omode&7) == OREAD)
amode = Aread;
+ else if((omode&7) == ORDWR)
+ amode = Ardwr;
aqlock(&audio);
if(waserror()){
aqunlock(&audio);
@@ -178,7 +181,7 @@ audioread(Chan *c, void *v, long n, vlong off)
return devdirread(c, a, n, audiodir, nelem(audiodir), devgen);
case Qaudio:
- if(audio.amode != Aread)
+ if(audio.amode != Aread && audio.amode != Ardwr)
error(Emode);
aqlock(&audio);
if(waserror()){
@@ -324,7 +327,7 @@ audiowrite(Chan *c, void *vp, long n, vlong off)
break;
case Qaudio:
- if(audio.amode != Awrite)
+ if(audio.amode != Awrite && audio.amode != Ardwr)
error(Emode);
aqlock(&audio);
if(waserror()){
[-- Attachment #4.1: Type: text/plain, Size: 367 bytes --]
from postmaster@4ess:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Type: application/octet-stream; name="Make.alsa"
Content-Disposition: attachment; filename="Make.alsa"
Content-Transfer-Encoding: base64
Content-ID: <f_kyxmxisx2>
[-- Attachment #4.2: Make.alsa.suspect --]
[-- Type: application/octet-stream, Size: 536 bytes --]
# Unix
#PTHREAD= # for Mac
PTHREAD=-pthread
AR=ar
AS=as
RANLIB=ranlib
X11=/usr/X11R6
CC=gcc
CFLAGS=-Wall -Wno-missing-braces -ggdb -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -I$(X11)/include -D_THREAD_SAFE $(PTHREAD) -O2
O=o
OS=posix
GUI=x11
LDADD=-L$(X11)/lib64 -L$(X11)/lib -lX11 -ggdb -lm -lasound
LDFLAGS=$(PTHREAD)
TARG=drawterm
# AUDIO=none
AUDIO=alsa
all: default
libmachdep.a:
arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/; s/x86_64/amd64/; s/armv[567].*/arm/; s/aarch64/arm64/'`; \
(cd posix-$$arch && make)