diff options
author | fjoe <fjoe@FreeBSD.org> | 2004-02-11 07:28:21 +0800 |
---|---|---|
committer | fjoe <fjoe@FreeBSD.org> | 2004-02-11 07:28:21 +0800 |
commit | 37cc605d4058f0b924942080f5c76a2b63a0aace (patch) | |
tree | 4afc0b46b660887c069c9b8264bb895a038d5197 /sysutils | |
parent | 0d3c4414ce7b3d62e9360e2b09ba9ddb8c6d055d (diff) | |
download | freebsd-ports-gnome-37cc605d4058f0b924942080f5c76a2b63a0aace.tar.gz freebsd-ports-gnome-37cc605d4058f0b924942080f5c76a2b63a0aace.tar.zst freebsd-ports-gnome-37cc605d4058f0b924942080f5c76a2b63a0aace.zip |
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.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/Makefile | 1 | ||||
-rw-r--r-- | sysutils/open/Makefile | 37 | ||||
-rw-r--r-- | sysutils/open/distinfo | 2 | ||||
-rw-r--r-- | sysutils/open/files/patch-Makefile | 25 | ||||
-rw-r--r-- | sysutils/open/files/patch-open.c | 108 | ||||
-rw-r--r-- | sysutils/open/files/patch-open.h | 35 | ||||
-rw-r--r-- | sysutils/open/files/pkg-message.in | 9 | ||||
-rw-r--r-- | sysutils/open/pkg-descr | 6 |
8 files changed, 223 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile index 672174a18fac..3ff14981dba0 100644 --- a/sysutils/Makefile +++ b/sysutils/Makefile @@ -228,6 +228,7 @@ SUBDIR += nwclient SUBDIR += nwclient602 SUBDIR += obliterate + SUBDIR += open SUBDIR += p5-File-Which SUBDIR += p5-Filesys-DiskFree SUBDIR += p5-Filesys-DiskSpace 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. |