diff options
author | brian <brian@FreeBSD.org> | 1998-05-28 23:15:40 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1998-05-28 23:15:40 +0000 |
commit | f0bbc1adc545f86776a2ecc51a460599ad4bbc9a (patch) | |
tree | 3c7ad7f867e874884f178d616f0c4e2ec2306802 /usr.sbin/ppp | |
parent | 88e95865abce6c3049d5a704fdc844d6a83d53e4 (diff) | |
download | FreeBSD-src-f0bbc1adc545f86776a2ecc51a460599ad4bbc9a.zip FreeBSD-src-f0bbc1adc545f86776a2ecc51a460599ad4bbc9a.tar.gz |
o Don't forget to close our transfer socket if we cannot
generate the data to transfer.
o Transfer uucp lock ownership for the transferred device.
o Don't assume we know the correct values of dev_is_modem and
mbits after the transfer.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/bundle.c | 14 | ||||
-rw-r--r-- | usr.sbin/ppp/datalink.c | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/datalink.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/id.c | 15 | ||||
-rw-r--r-- | usr.sbin/ppp/id.h | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 21 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.h | 5 |
7 files changed, 50 insertions, 19 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index e06517a..15e0cfe 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.7 1998/05/25 02:22:30 brian Exp $ + * $Id: bundle.c,v 1.8 1998/05/25 10:37:00 brian Exp $ */ #include <sys/types.h> @@ -1344,6 +1344,7 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s, struct sockaddr_un *sun) struct iovec iov[SCATTER_SEGMENTS]; struct datalink *dl; int niov, link_fd, expect, f; + pid_t pid; log_Printf(LogPHASE, "Receiving datalink\n"); @@ -1351,11 +1352,14 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s, struct sockaddr_un *sun) niov = 1; iov[0].iov_len = strlen(Version) + 1; iov[0].iov_base = (char *)malloc(iov[0].iov_len); - if (datalink2iov(NULL, iov, &niov, sizeof iov / sizeof *iov) == -1) { + if (datalink2iov(NULL, iov, &niov, sizeof iov / sizeof *iov, 0) == -1) { close(s); return; } + pid = getpid(); + write(s, &pid, sizeof pid); + for (f = expect = 0; f < niov; f++) expect += iov[f].iov_len; @@ -1429,6 +1433,7 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun) struct msghdr msg; struct iovec iov[SCATTER_SEGMENTS]; int niov, link_fd, f, expect; + pid_t newpid; log_Printf(LogPHASE, "Transmitting datalink %s\n", dl->name); @@ -1440,7 +1445,8 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun) iov[0].iov_base = strdup(Version); niov = 1; - link_fd = datalink2iov(dl, iov, &niov, sizeof iov / sizeof *iov); + read(s, &newpid, sizeof newpid); + link_fd = datalink2iov(dl, iov, &niov, sizeof iov / sizeof *iov, newpid); if (link_fd != -1) { memset(&msg, '\0', sizeof msg); @@ -1542,9 +1548,9 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun) break; } } - close(s); close(link_fd); } + close(s); while (niov--) free(iov[niov].iov_base); diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index a41e93b..c7eafab 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.4 1998/05/23 22:24:33 brian Exp $ + * $Id: datalink.c,v 1.5 1998/05/25 02:22:32 brian Exp $ */ #include <sys/types.h> @@ -1022,7 +1022,8 @@ iov2datalink(struct bundle *bundle, struct iovec *iov, int *niov, int maxiov, } int -datalink2iov(struct datalink *dl, struct iovec *iov, int *niov, int maxiov) +datalink2iov(struct datalink *dl, struct iovec *iov, int *niov, int maxiov, + pid_t newpid) { /* If `dl' is NULL, we're allocating before a Fromiov() */ int link_fd; @@ -1048,7 +1049,7 @@ datalink2iov(struct datalink *dl, struct iovec *iov, int *niov, int maxiov) dl ? realloc(dl->name, DATALINK_MAXNAME) : malloc(DATALINK_MAXNAME); iov[(*niov)++].iov_len = DATALINK_MAXNAME; - link_fd = modem2iov(dl ? dl->physical : NULL, iov, niov, maxiov); + link_fd = modem2iov(dl ? dl->physical : NULL, iov, niov, maxiov, newpid); if (link_fd == -1 && dl) { free(dl->name); diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h index 93a5ef2..9fbc67d 100644 --- a/usr.sbin/ppp/datalink.h +++ b/usr.sbin/ppp/datalink.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.h,v 1.1.2.26 1998/05/16 23:47:25 brian Exp $ + * $Id: datalink.h,v 1.2 1998/05/21 21:44:57 brian Exp $ */ #define DATALINK_CLOSED (0) @@ -110,7 +110,7 @@ extern struct datalink *datalink_Create(const char *name, struct bundle *, int); extern struct datalink *datalink_Clone(struct datalink *, const char *); extern struct datalink *iov2datalink(struct bundle *, struct iovec *, int *, int, int); -extern int datalink2iov(struct datalink *, struct iovec *, int *, int); +extern int datalink2iov(struct datalink *, struct iovec *, int *, int, pid_t); extern struct datalink *datalink_Destroy(struct datalink *); extern void datalink_GotAuthname(struct datalink *, const char *, int); extern void datalink_Up(struct datalink *, int, int); diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c index 2e4072c..4ac474e 100644 --- a/usr.sbin/ppp/id.c +++ b/usr.sbin/ppp/id.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.c,v 1.6.4.10 1998/05/01 19:24:41 brian Exp $ + * $Id: id.c,v 1.8 1998/05/21 21:45:32 brian Exp $ */ #include <sys/types.h> @@ -170,6 +170,19 @@ ID0uu_lock(const char *basettyname) } int +ID0uu_lock_txfr(const char *basettyname, pid_t newpid) +{ + int ret; + + ID0set0(); + ret = uu_lock_txfr(basettyname, newpid); + log_Printf(LogID0, "%d = uu_lock_txfr(\"%s\", %d)\n", ret, basettyname, + (int)newpid); + ID0setuser(); + return ret; +} + +int ID0uu_unlock(const char *basettyname) { int ret; diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h index af55d58..ca747c0 100644 --- a/usr.sbin/ppp/id.h +++ b/usr.sbin/ppp/id.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.h,v 1.3.4.4 1998/04/30 23:53:40 brian Exp $ + * $Id: id.h,v 1.5 1998/05/21 21:45:34 brian Exp $ */ struct utmp; @@ -38,6 +38,7 @@ extern FILE *ID0fopen(const char *, const char *); extern int ID0open(const char *, int, ...); extern int ID0write(int, const void *, size_t); extern int ID0uu_lock(const char *); +extern int ID0uu_lock_txfr(const char *, pid_t); extern int ID0uu_unlock(const char *); extern void ID0login(struct utmp *); extern void ID0logout(const char *); diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 01bdab0..f8bf5f4 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.84 1998/05/25 02:22:37 brian Exp $ + * $Id: modem.c,v 1.85 1998/05/25 10:37:02 brian Exp $ * * TODO: */ @@ -991,8 +991,6 @@ iov2modem(struct datalink *dl, struct iovec *iov, int *niov, int maxiov, int fd) len = strlen(_PATH_DEV); p->name.base = strncmp(p->name.full, _PATH_DEV, len) ? p->name.full : p->name.full + len; - p->mbits = 0; - p->dev_is_modem = 1; p->out = NULL; p->connect_count = 1; @@ -1031,14 +1029,13 @@ iov2modem(struct datalink *dl, struct iovec *iov, int *niov, int maxiov, int fd) p->Timer.state = TIMER_STOPPED; /* Special - see modem2iov() */ modem_StartTimer(dl->bundle, p); } - /* Don't need to lock the device in -direct mode */ - /* XXX: What if it's not a -direct link ! */ return p; } int -modem2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov) +modem2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov, + pid_t newpid) { if (p) { hdlc_StopTimer(&p->hdlc); @@ -1055,6 +1052,7 @@ modem2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov) p->Timer.state = TIMER_RUNNING; /* Special - see iov2modem() */ } timer_Stop(&p->link.throughput.Timer); + modem_ChangedPid(p, newpid); } if (*niov >= maxiov) { @@ -1070,3 +1068,14 @@ modem2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov) return p ? p->fd : 0; } + +void +modem_ChangedPid(struct physical *p, pid_t newpid) +{ + if (p->type != PHYS_DIRECT) { + int res; + + if ((res = ID0uu_lock_txfr(p->name.base, newpid)) != UU_LOCK_OK) + log_Printf(LogPHASE, "uu_lock_txfr: %s\n", uu_lockerr(res)); + } +} diff --git a/usr.sbin/ppp/modem.h b/usr.sbin/ppp/modem.h index f85a475..58f54dd 100644 --- a/usr.sbin/ppp/modem.h +++ b/usr.sbin/ppp/modem.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.h,v 1.16.2.17 1998/05/02 21:57:49 brian Exp $ + * $Id: modem.h,v 1.17 1998/05/21 21:47:02 brian Exp $ * * TODO: */ @@ -39,4 +39,5 @@ extern void modem_Offline(struct physical *); extern void modem_Destroy(struct physical *); extern struct physical *iov2modem(struct datalink *, struct iovec *, int *, int, int); -extern int modem2iov(struct physical *, struct iovec *, int *, int); +extern int modem2iov(struct physical *, struct iovec *, int *, int, pid_t); +extern void modem_ChangedPid(struct physical *, pid_t); |