mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-28 05:29:48 +00:00
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.
This commit is contained in:
parent
0c1dae5ebb
commit
aa292cbf82
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=100610
@ -228,6 +228,7 @@
|
||||
SUBDIR += nwclient
|
||||
SUBDIR += nwclient602
|
||||
SUBDIR += obliterate
|
||||
SUBDIR += open
|
||||
SUBDIR += p5-File-Which
|
||||
SUBDIR += p5-Filesys-DiskFree
|
||||
SUBDIR += p5-Filesys-DiskSpace
|
||||
|
37
sysutils/open/Makefile
Normal file
37
sysutils/open/Makefile
Normal file
@ -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>
|
2
sysutils/open/distinfo
Normal file
2
sysutils/open/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
MD5 (open-1.4.tar.gz) = 590781ba76d9d499d7843c0b4651da70
|
||||
SIZE (open-1.4.tar.gz) = 17271
|
25
sysutils/open/files/patch-Makefile
Normal file
25
sysutils/open/files/patch-Makefile
Normal file
@ -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
|
||||
|
108
sysutils/open/files/patch-open.c
Normal file
108
sysutils/open/files/patch-open.c
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
|
35
sysutils/open/files/patch-open.h
Normal file
35
sysutils/open/files/patch-open.h
Normal file
@ -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
|
9
sysutils/open/files/pkg-message.in
Normal file
9
sysutils/open/files/pkg-message.in
Normal file
@ -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]
|
6
sysutils/open/pkg-descr
Normal file
6
sysutils/open/pkg-descr
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user