summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-09-19 03:37:07 +0000
committerache <ache@FreeBSD.org>1995-09-19 03:37:07 +0000
commit32649c9af4e7665a35b701d473475979368555b9 (patch)
treece1a5248c86f110d2b6be4ada400b4826a9ceb18 /sbin
parentf7ecd9bbc1b953679440037145370481bc848100 (diff)
downloadFreeBSD-src-32649c9af4e7665a35b701d473475979368555b9.zip
FreeBSD-src-32649c9af4e7665a35b701d473475979368555b9.tar.gz
Fix uucp locking
Remove unnecesary TIOCSETD Move SLIO* before startup script call
Diffstat (limited to 'sbin')
-rw-r--r--sbin/startslip/startslip.c34
-rw-r--r--sbin/startslip/uucplock.c33
2 files changed, 29 insertions, 38 deletions
diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c
index 7da0fd7..3ff364f 100644
--- a/sbin/startslip/startslip.c
+++ b/sbin/startslip/startslip.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: startslip.c,v 1.14 1995/09/17 21:47:24 ache Exp $
+ * $Id: startslip.c,v 1.15 1995/09/18 14:01:11 ache Exp $
*/
#ifndef lint
@@ -292,18 +292,6 @@ restart:
}
printd(" %d", fd);
signal(SIGHUP, sighup);
- if (debug) {
- if (ioctl(fd, TIOCGETD, &disc) < 0)
- syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
- else
- printd(" (disc was %d)", disc);
- }
- disc = TTYDISC;
- if (ioctl(fd, TIOCSETD, &disc) < 0) {
- syslog(LOG_ERR, "%s: ioctl (TIOCSETD 0): %m\n",
- devicename);
- down(2);
- }
if (ioctl(fd, TIOCSCTTY, 0) < 0) {
syslog(LOG_ERR, "ioctl (TIOCSCTTY): %m");
down(2);
@@ -430,17 +418,12 @@ restart:
syslog(LOG_ERR, "ioctl(SLIOCSUNIT): %m");
down(2);
}
- if (ioctl(fd, SLIOCGUNIT, (caddr_t)&unitnum) < 0) {
+ if (ioctl(fd, SLIOCGUNIT, &unitnum) < 0) {
syslog(LOG_ERR, "ioctl(SLIOCGUNIT): %m");
down(2);
}
sprintf(unitname, "sl%d", unitnum);
- sprintf(buf, "LINE=%d %s %s up",
- diali ? (dialc - 1) % diali : 0,
- upscript ? upscript : "/sbin/ifconfig" , unitname);
- (void) system(buf);
-
if (keepal > 0) {
signal(SIGURG, sigurg);
if (ioctl(fd, SLIOCSKEEPAL, &keepal) < 0) {
@@ -452,6 +435,12 @@ restart:
syslog(LOG_ERR, "ioctl(SLIOCSOUTFILL): %m");
down(2);
}
+
+ sprintf(buf, "LINE=%d %s %s up",
+ diali ? (dialc - 1) % diali : 0,
+ upscript ? upscript : "/sbin/ifconfig" , unitname);
+ (void) system(buf);
+
printd(", ready\n");
if (!first)
syslog(LOG_INFO, "reconnected on %s (%d tries).\n", unitname, tries);
@@ -565,11 +554,8 @@ carrier()
down(code)
{
- int disc = TTYDISC;
-
- if (fd > -1 && ioctl(fd, TIOCSETD, &disc) < 0)
- syslog(LOG_ERR, "%s: ioctl (TIOCSETD 0): %m",
- devicename);
+ if (fd > -1)
+ close(fd);
if (pfd)
unlink(pidfile);
if (locked)
diff --git a/sbin/startslip/uucplock.c b/sbin/startslip/uucplock.c
index 18ce24c..fb0f7c0 100644
--- a/sbin/startslip/uucplock.c
+++ b/sbin/startslip/uucplock.c
@@ -40,12 +40,16 @@ static char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
#include <sys/dir.h>
#include <errno.h>
#include <syslog.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
#define _PATH_LOCKDIRNAME "/var/spool/lock/LCK..%s"
/* Forward declarations */
-static int put_pid (int fd, int pid);
-static int get_pid (int fd);
+static int put_pid (int fd, pid_t pid);
+static pid_t get_pid (int fd);
/*
* uucp style locking routines
@@ -53,11 +57,11 @@ static int get_pid (int fd);
* -1 - failure
*/
-uu_lock (char *ttyname)
+int uu_lock (char *ttyname)
{
- int fd, pid;
+ int fd;
+ pid_t pid;
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
- off_t lseek();
(void)sprintf(tbuf, _PATH_LOCKDIRNAME, ttyname);
fd = open(tbuf, O_RDWR|O_CREAT|O_EXCL, 0660);
@@ -71,9 +75,9 @@ uu_lock (char *ttyname)
syslog(LOG_ERR, "lock open: %m");
return(-1);
}
- if (get_pid (fd) == -1) {
- (void)close(fd);
+ if ((pid = get_pid (fd)) == -1) {
syslog(LOG_ERR, "lock read: %m");
+ (void)close(fd);
return(-1);
}
@@ -86,24 +90,24 @@ uu_lock (char *ttyname)
* we'll lock it ourselves
*/
if (lseek(fd, 0L, L_SET) < 0) {
- (void)close(fd);
syslog(LOG_ERR, "lock lseek: %m");
+ (void)close(fd);
return(-1);
}
/* fall out and finish the locking process */
}
pid = getpid();
if (!put_pid (fd, pid)) {
+ syslog(LOG_ERR, "lock write: %m");
(void)close(fd);
(void)unlink(tbuf);
- syslog(LOG_ERR, "lock write: %m");
return(-1);
}
(void)close(fd);
return(0);
}
-uu_unlock (char *ttyname)
+int uu_unlock (char *ttyname)
{
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
@@ -111,19 +115,20 @@ uu_unlock (char *ttyname)
return(unlink(tbuf));
}
-static int put_pid (int fd, int pid)
+static int put_pid (int fd, pid_t pid)
{
char buf [32];
int len;
- len = sprintf (buf, "%10ld\n", (long) pid);
+ len = sprintf (buf, "%10ld\n", pid);
return write (fd, buf, len) == len;
}
-static int get_pid (int fd)
+static pid_t get_pid (int fd)
{
- int bytes_read, pid;
+ int bytes_read;
char buf [32];
+ pid_t pid;
bytes_read = read (fd, buf, sizeof (buf) - 1);
if (bytes_read > 0) {
OpenPOWER on IntegriCloud