+/*-
+ * Copyright (c) 1985, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
#ifndef lint
-static char sccsid[] = "@(#)acucntrl.c 5.10 (Berkeley) %G%";
-#endif
+static char copyright[] =
+"@(#) Copyright (c) 1985, 1986, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)acucntrl.c 8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
/* acucntrl - turn around tty line between dialin and dialout
*
* Operation:
* disable (i.e. setup for dialing out)
* (1) check input arguments
- * (2) look in /etc/utmp to check that the line is not in use by another
+ * (2) look in _PATH_UTMP to check that the line is not in use by another
* (3) disable modem control on terminal
* (4) check for carrier on device
* (5) change owner of device to real id
- * (6) edit /etc/ttys, changing the first character of the appropriate
+ * (6) edit _PATH_TTYS, changing the first character of the appropriate
* line to 0
* (7) send a hangup to process 1 to poke init to disable getty
- * (8) post uid name in capitals in /etc/utmp to let world know device has
- * been grabbed
+ * (8) post uid name in capitals in _PATH_UTMP to let world know device
+ * has been grabbed
* (9) make sure that DTR is on
*
* enable (i.e.) restore for dialin
* (1) check input arguments
- * (2) look in /etc/utmp to check that the line is not in use by another
+ * (2) look in _PATH_UTMP to check that the line is not in use by another
* (3) make sure modem control on terminal is disabled
* (4) turn off DTR to make sure line is hung up
* (5) condition line: clear exclusive use and set hangup on close modes
* (6) turn on modem control
- * (7) edit /etc/ttys, changing the first character of the appropriate
+ * (7) edit _PATH_TTYS, changing the first character of the appropriate
* line to 1
* (8) send a hangup to process 1 to poke init to enable getty
- * (9) clear uid name for /etc/utmp
+ * (9) clear uid name for _PATH_UTMP
*/
/* #define SENSECARRIER */
#include <pwd.h>
#include <stdio.h>
#include <sys/file.h>
+#include "pathnames.h"
#define NDZLINE 8 /* lines/dz */
#define NDHLINE 16 /* lines/dh */
#define ENABLE 1
#define DISABLE 0
-char Etcutmp[] = "/etc/utmp";
-char Etcttys[] = "/etc/ttys";
+char Etcttys[] = _PATH_TTYS;
#ifdef BSD4_3
FILE *ttysfile, *nttysfile;
-char NEtcttys[] = "/etc/ttys.new";
+char NEtcttys[] = _PATH_NEWTTYS;
extern long ftell();
#endif BSD4_3
-char Devhome[] = "/dev";
+char Devhome[] = _PATH_DEV;
char usage[] = "Usage: acucntrl {dis|en}able ttydX\n";
int etcutmp;
off_t utmploc;
off_t ttyslnbeg;
+extern int errno;
+extern char *sys_errlist[];
+off_t lseek();
#define NAMSIZ sizeof(utmp.ut_name)
#define LINSIZ sizeof(utmp.ut_line)
char *device;
int devfile;
int uid, gid;
- off_t lseek();
struct passwd *getpwuid();
char *rindex();
- extern int errno;
- extern char *sys_errlist[];
/* check input arguments */
- if (argc!=3) {
+ if (argc!=3 && argc != 4) {
fprintf(stderr, usage);
exit(1);
}
device = rindex(argv[2], '/');
device = (device == NULL) ? argv[2]: device+1;
- /* only recognize devices of the form ttydX */
- if (strncmp(device, "ttyd", 4)!=0) {
- fprintf(stderr, "Bad Device Name %s", device);
- exit(1);
- }
-
opnttys(device);
#ifdef vax
/* Get nlist info */
- nlist("/vmunix", nl);
+ nlist(_PATH_UNIX, nl);
#endif vax
/* Chdir to /dev */
exit(1);
}
+ if (strcmp(p, "uucp") == 0 && argc == 4)
+ p = argv[3];
+
/* to upper case */
i = 0;
do {
uname[i] = *p;
- Uname[i] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p;
- i++; p++;
- } while (*p && i<NAMSIZ);
-
+ Uname[i++] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p;
+ } while (*p++ && i<NAMSIZ);
/* check to see if line is being used */
- if( (etcutmp = open(Etcutmp, 2)) < 0) {
+ if( (etcutmp = open(_PATH_UTMP, 2)) < 0) {
fprintf(stderr, "On open %s open: %s\n",
- Etcutmp, sys_errlist[errno]);
+ _PATH_UTMP, sys_errlist[errno]);
exit(1);
}
strncpy(utmp.ut_line, device, LINSIZ);
strncpy(utmp.ut_name, name, NAMSIZ);
if (lseek(etcutmp, utmploc, 0) < 0)
- fprintf(stderr, "on lseek in /etc/utmp: %s",
- sys_errlist[errno]);
+ fprintf(stderr, "on lseek in %s: %s",
+ _PATH_UTMP, sys_errlist[errno]);
if (write(etcutmp, (char *)&utmp, sizeof(utmp)) < 0)
- fprintf(stderr, "on write in /etc/utmp: %s",
- sys_errlist[errno]);
+ fprintf(stderr, "on write in %s: %s",
+ _PATH_UTMP, sys_errlist[errno]);
}
/* poke process 1 and wait for it to do its thing */
do {
sleep(1);
if (lseek(etcutmp, utmploc, 0) < 0)
- fprintf(stderr, "On lseek in /etc/utmp: %s",
- sys_errlist[errno]);
+ fprintf(stderr, "On lseek in %s: %s",
+ _PATH_UTMP, sys_errlist[errno]);
if (read(etcutmp, (char *)&utmp, sizeof utmp) < 0)
- fprintf(stderr, "On read from /etc/utmp: %s",
- sys_errlist[errno]);
+ fprintf(stderr, "On read from %s: %s",
+ _PATH_UTMP, sys_errlist[errno]);
} while (utmp.ut_name[0] != '\0' && --i > 0);
}
exit(1);
}
-/* modify appropriate line in /etc/ttys to turn on/off the device */
+/* modify appropriate line in _PATH_TTYS to turn on/off the device */
settys(enable)
int enable;
{
cp++;
}
if (*cp == '\0') {
- fprintf(stderr,"Badly formatted line in /etc/ttys:\n%s", lbuf);
+ fprintf(stderr,"Badly formatted line in %s:\n%s",
+ _PATH_TTYS, lbuf);
exit(1);
}
c1 = *--cp;
while (*cp && *cp != ' ' && *cp != '\t' && *cp != '\n')
cp++;
if (*cp == '\0') {
- fprintf(stderr,"Badly formatted line in /etc/ttys:\n%s", lbuf);
+ fprintf(stderr,"Badly formatted line in %s:\n%s",
+ _PATH_TTYS, lbuf);
exit(1);
}
c2 = *cp;
exit(1);
}
-/* modify appropriate line in /etc/ttys to turn on/off the device */
+/* modify appropriate line in _PATH_TTYS to turn on/off the device */
settys(enable)
int enable;
{
return(-1);
}
- if((kmem = open("/dev/kmem", 2)) < 0) {
- fprintf(stderr, "/dev/kmem open: %s\n", sys_errlist[errno]);
+ if((kmem = open(_PATH_KMEM, 2)) < 0) {
+ fprintf(stderr, "%s open: %s\n", _PATH_KMEM,
+ sys_errlist[errno]);
return(-1);
}
}
cflags = flags;
(void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0);
- (void)write(kmem, (char *) &flags, sizeof cflags);
+ (void)write(kmem, (char *) &cflags, sizeof cflags);
break;
default:
fprintf(stderr, "Unknown device type\n");
return (1);
return (c == '\0');
}
-#endif /* DIALINOUT */
+#else /* !DIALINOUT */
+main()
+{
+ fprintf(stderr,"acucntrl is not supported on this system\n");
+}
+#endif /* !DIALINOUT */