summaryrefslogtreecommitdiff
path: root/sysutils/open
diff options
context:
space:
mode:
authorMax Khon <fjoe@FreeBSD.org>2004-02-10 23:28:21 +0000
committerMax Khon <fjoe@FreeBSD.org>2004-02-10 23:28:21 +0000
commitaa292cbf824c04d77669c77eda812bf8894d60d5 (patch)
tree465fe60e7039eba1523dd118c5fcfbdd9b329665 /sysutils/open
parentUpdated p4d, add SIZE. (diff)
New port: open 1.4
Open opens a new vt and runs a command on it. It can be used as a simple way to start several console logins without having to type your passwd on each VT in turn. open can be used as a simpler to use replacement for the doshell(8) command. open is similar in functionality to the AIX/RS6000 command of the same name.
Notes
Notes: svn path=/head/; revision=100610
Diffstat (limited to 'sysutils/open')
-rw-r--r--sysutils/open/Makefile37
-rw-r--r--sysutils/open/distinfo2
-rw-r--r--sysutils/open/files/patch-Makefile25
-rw-r--r--sysutils/open/files/patch-open.c108
-rw-r--r--sysutils/open/files/patch-open.h35
-rw-r--r--sysutils/open/files/pkg-message.in9
-rw-r--r--sysutils/open/pkg-descr6
7 files changed, 222 insertions, 0 deletions
diff --git a/sysutils/open/Makefile b/sysutils/open/Makefile
new file mode 100644
index 000000000000..2fd491a43e2e
--- /dev/null
+++ b/sysutils/open/Makefile
@@ -0,0 +1,37 @@
+# New ports collection makefile for: open
+# Date created: 10 Feb 2004
+# Whom: Max Khon <fjoe@FreeBSD.org>
+#
+# $FreeBSD$
+#
+
+PORTNAME= open
+PORTVERSION= 1.4
+CATEGORIES= sysutils
+MASTER_SITES= ftp://ftp.hs-niederrhein.de/pub/linux/src/ \
+ ftp://ftp.uni-bremen.de/pub/mirrors/sunsite/utils/console/ \
+ ftp://ftp.anu.edu.au/sunsite/mnt/disk1/linux/metalab/utils/console/
+
+MAINTAINER= fjoe@FreeBSD.org
+COMMENT= Open opens a new vt and runs a command on it
+
+ALL_TARGET= open
+MAN1= open.1
+PLIST_FILES= bin/open
+OPTIONS= SETUID "Install setuid open binary" off
+PKGMESSAGE= ${WRKDIR}/pkg-message
+
+.include <bsd.port.pre.mk>
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/open ${PREFIX}/bin
+ ${INSTALL_MAN} ${WRKSRC}/open.1 ${PREFIX}/man/man1
+.if defined(WITH_SETUID)
+ ${CHMOD} u+s ${PREFIX}/bin/open
+.else
+ @${SED} -e 's|%%PREFIX%%|${PREFIX}|g' \
+ ${FILESDIR}/pkg-message.in > ${PKGMESSAGE}
+ @${CAT} ${PKGMESSAGE}
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/sysutils/open/distinfo b/sysutils/open/distinfo
new file mode 100644
index 000000000000..be7dd8f96c50
--- /dev/null
+++ b/sysutils/open/distinfo
@@ -0,0 +1,2 @@
+MD5 (open-1.4.tar.gz) = 590781ba76d9d499d7843c0b4651da70
+SIZE (open-1.4.tar.gz) = 17271
diff --git a/sysutils/open/files/patch-Makefile b/sysutils/open/files/patch-Makefile
new file mode 100644
index 000000000000..1078281e9979
--- /dev/null
+++ b/sysutils/open/files/patch-Makefile
@@ -0,0 +1,25 @@
+--- Makefile.orig Fri Jul 19 07:32:07 1996
++++ Makefile Wed Feb 11 05:18:21 2004
+@@ -1,6 +1,7 @@
+
+-CC=gcc
+-CFLAGS=-O2 -Wall -ansi
++CC?=gcc
++CFLAGS?=-O2 -Wall -ansi
++CFLAGS+=-Wall
+ LDFLAGS=$(CFLAGS) -s
+
+ SRC1=open.c
+@@ -20,10 +21,10 @@
+
+
+ open: $(OBJ1)
+- $(CC) $(LDLAGS) -o $@ $<
++ $(CC) $(LDLAGS) -o $@ $>
+
+ switchto: $(OBJ2)
+- $(CC) $(LDLAGS) -o $@ $<
++ $(CC) $(LDLAGS) -o $@ $>
+
+ open.o: open.h
+
diff --git a/sysutils/open/files/patch-open.c b/sysutils/open/files/patch-open.c
new file mode 100644
index 000000000000..ce317f5b5645
--- /dev/null
+++ b/sysutils/open/files/patch-open.c
@@ -0,0 +1,108 @@
+--- open.c.orig Fri Jul 19 22:49:03 1996
++++ open.c Wed Feb 11 05:02:34 2004
+@@ -24,7 +24,12 @@
+
+ int fd = 0;
+ int opt, pid;
++#if !defined(__FreeBSD__)
+ struct vt_stat vt;
++#define vt_active vt.v_active
++#else
++ int vt_active;
++#endif
+ struct passwd *pwnam=NULL;
+ int vtno = -1;
+ char show = FALSE;
+@@ -33,7 +38,7 @@
+ char do_wait = FALSE;
+ char as_user= FALSE;
+ char vtname[sizeof VTNAME + 2]; /* allow 999 possible VTs */
+- char *cmd, *def_cmd = NULL;
++ char *cmd = NULL, *def_cmd = NULL;
+
+ /*
+ * I don't like using getopt for this, but otherwise this gets messy.
+@@ -44,7 +49,7 @@
+ switch (opt) {
+ case 'c':
+ vtno = (int) atol(optarg);
+- if (vtno < 0 || vtno > 99) {
++ if (vtno <= 0 || vtno > 99) {
+ fprintf(stderr, "open: %s illegal vt number\n", optarg);
+ return 5;
+ }
+@@ -92,14 +97,19 @@
+ return(3);
+ }
+
++#if !defined(__FreeBSD__)
+ if (ioctl(fd, VT_GETSTATE, &vt) < 0) {
+ perror("open: can't get VTstate\n");
++#else
++ if (ioctl(fd, VT_GETACTIVE, &vt_active) < 0) {
++ perror("open: can't get active VT\n");
++#endif
+ close(fd);
+ return(4);
+ }
+ }
+
+- sprintf(vtname, VTNAME, vtno);
++ sprintf(vtname, VTNAME, vtno - 1);
+
+ /* support for Spawn_Console; running from init
+ added by Joshua Spoerri, Thu Jul 18 21:13:16 EDT 1996 */
+@@ -110,7 +120,7 @@
+ dev_t console_dev;
+ ino_t console_ino;
+ uid_t console_uid;
+- char filename[NAME_MAX+12];
++ char filename[sizeof VTNAME + 2];
+
+ if (!(dp=opendir("/proc"))) {
+ perror("/proc");
+@@ -118,7 +128,7 @@
+ }
+
+ /* get the current tty */
+- sprintf(filename,"/dev/tty%d",vt.v_active);
++ sprintf(filename,VTNAME,vt_active - 1);
+ if (stat(filename,&buf)) {
+ perror(filename);
+ exit(1);
+@@ -204,15 +214,18 @@
+ _exit (4); /* silently die */
+ }
+ dup(fd); dup(fd);
+-
++ if (ioctl(fd, TIOCSCTTY, NULL) < 0)
++ _exit(4);
+ if (show) {
+ /*
+ * Can't tell anyone if any of these fail, so throw away
+ * the return values
+ */
+- (void) ioctl(fd, VT_ACTIVATE, vtno);
++ if (ioctl(fd, VT_ACTIVATE, vtno) < 0)
++ _exit(4);
+ /* wait to be really sure we have switched */
+- (void) ioctl(fd, VT_WAITACTIVE, vtno);
++ if (ioctl(fd, VT_WAITACTIVE, vtno) < 0)
++ _exit(4);
+ }
+ if(as_user)
+ execlp("login","login","-f",pwnam->pw_name,NULL);
+@@ -230,9 +243,11 @@
+ if ( do_wait ) {
+ wait(NULL);
+ if (show) { /* Switch back... */
+- (void) ioctl(fd, VT_ACTIVATE, vt.v_active);
++ if (ioctl(fd, VT_ACTIVATE, vt_active) < 0)
++ _exit(4);
+ /* wait to be really sure we have switched */
+- (void) ioctl(fd, VT_WAITACTIVE, vt.v_active);
++ if (ioctl(fd, VT_WAITACTIVE, vt_active) < 0)
++ _exit(4);
+ }
+ }
+
diff --git a/sysutils/open/files/patch-open.h b/sysutils/open/files/patch-open.h
new file mode 100644
index 000000000000..88aaed29d3bc
--- /dev/null
+++ b/sysutils/open/files/patch-open.h
@@ -0,0 +1,35 @@
+--- open.h.orig Tue Feb 10 18:10:58 2004
++++ open.h Tue Feb 10 18:24:48 2004
+@@ -1,14 +1,21 @@
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <stdlib.h>
++#if !defined(__FreeBSD__)
+ #include <getopt.h>
++#endif
+ #include <string.h>
+ #include <fcntl.h>
+ #include <dirent.h>
+ #include <pwd.h>
++#include <errno.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
++#if defined(__FreeBSD__)
++#include <sys/consio.h>
++#else
+ #include <sys/vt.h>
++#endif
+ #include <sys/types.h>
+ #include <sys/wait.h>
+
+@@ -29,6 +36,10 @@
+ */
+ #ifdef __linux__
+ #define VTNAME "/dev/tty%d"
++#endif
++
++#ifdef __FreeBSD__
++#define VTNAME "/dev/ttyv%x"
+ #endif
+
+ #ifdef ESIX_5_3_2_D
diff --git a/sysutils/open/files/pkg-message.in b/sysutils/open/files/pkg-message.in
new file mode 100644
index 000000000000..f3ce36747f4f
--- /dev/null
+++ b/sysutils/open/files/pkg-message.in
@@ -0,0 +1,9 @@
+To use open it must be installed setuid root
+(type "chmod u+s %%PREFIX%%/bin/open")
+
+or
+
+all the VT devices that are not allocated
+to getty should be read/write by all, e.g.
+
+chmod a=rw /dev/ttyv[9abc]
diff --git a/sysutils/open/pkg-descr b/sysutils/open/pkg-descr
new file mode 100644
index 000000000000..5b23cfe11b87
--- /dev/null
+++ b/sysutils/open/pkg-descr
@@ -0,0 +1,6 @@
+Open opens a new vt and runs a command on it. It can be used as a simple
+way to start several console logins without having to type your passwd
+on each VT in turn. open can be used as a simpler to use replacement for
+the doshell(8) command.
+
+open is similar in functionality to the AIX/RS6000 command of the same name.