chat/Makefile.linux | 6 +- chat/chat.8 | 2 +- etc.ppp/options | 3 + linux/Makefile.top | 8 ++- pppd/Makefile.linux | 17 ++--- pppd/auth.c | 6 ++- pppd/chap-new.c | 8 ++ pppd/demand.c | 102 ++++++++++++++++++++++++++++- pppd/ipcp.c | 9 ++- pppd/ipv6cp.c | 7 ++- pppd/ipv6cp.h | 3 +- pppd/main.c | 89 ++++++++++++++----------- pppd/options.c | 21 ++++++ pppd/pathnames.h | 14 +++-- pppd/plugins/Makefile.linux | 7 +- pppd/plugins/pppoatm/Makefile.linux | 6 +- pppd/plugins/pppol2tp/Makefile.linux | 2 +- pppd/plugins/radius/Makefile.linux | 17 ++--- pppd/plugins/radius/clientid.c | 4 +- pppd/plugins/rp-pppoe/Makefile.linux | 13 ++-- pppd/plugins/rp-pppoe/plugin.c | 6 ++ pppd/plugins/rp-pppoe/pppoe-discovery.8 | 86 ++++++++++++++++++++++++ pppd/plugins/winbind.c | 11 +++- pppd/pppd.8 | 13 ++++- pppd/pppd.h | 24 ++++++- pppd/sha1.c | 1 + pppd/sys-linux.c | 109 +++++++++---------------------- pppd/utils.c | 4 +- pppdump/Makefile.linux | 4 +- pppstats/Makefile.linux | 6 +- 30 files changed, 427 insertions(+), 181 deletions(-) diff --git a/chat/Makefile.linux b/chat/Makefile.linux index 1065ac5..011ced6 100644 --- a/chat/Makefile.linux +++ b/chat/Makefile.linux @@ -18,15 +18,15 @@ INSTALL= install all: chat chat: chat.o - $(CC) -o chat chat.o + $(CC) -pie -o chat chat.o chat.o: chat.c $(CC) -c $(CFLAGS) -o chat.o chat.c install: chat mkdir -p $(BINDIR) $(MANDIR) - $(INSTALL) -s -c chat $(BINDIR) - $(INSTALL) -c -m 644 chat.8 $(MANDIR) + $(INSTALL) -m 755 chat $(BINDIR) + $(INSTALL) -m 644 chat.8 $(MANDIR) clean: rm -f chat.o chat *~ diff --git a/chat/chat.8 b/chat/chat.8 index b532292..03f6507 100644 --- a/chat/chat.8 +++ b/chat/chat.8 @@ -200,7 +200,7 @@ The \fBSAY\fR directive allows the script to send strings to the user at the terminal via standard error. If \fBchat\fR is being run by pppd, and pppd is running as a daemon (detached from its controlling terminal), standard error will normally be redirected to the file -/etc/ppp/connect\-errors. +/var/log/ppp/connect\-errors. .LP \fBSAY\fR strings must be enclosed in single or double quotes. If carriage return and line feed are needed in the string to be output, diff --git a/etc.ppp/options b/etc.ppp/options index 4b67b6a..b1671cc 100644 --- a/etc.ppp/options +++ b/etc.ppp/options @@ -1 +1,4 @@ lock +noipdefault +noauth +replacedefaultroute diff --git a/linux/Makefile.top b/linux/Makefile.top index f63d45e..f42efd5 100644 --- a/linux/Makefile.top +++ b/linux/Makefile.top @@ -5,6 +5,8 @@ BINDIR = $(DESTDIR)/sbin INCDIR = $(DESTDIR)/include MANDIR = $(DESTDIR)/share/man ETCDIR = $(INSTROOT)@SYSCONF@/ppp +RUNDIR = $(DESTDIR)/var/run/ppp +LOGDIR = $(DESTDIR)/var/log/ppp # uid 0 = root INSTALL= install @@ -16,7 +18,7 @@ all: cd pppstats; $(MAKE) $(MFLAGS) all cd pppdump; $(MAKE) $(MFLAGS) all -install: $(BINDIR) $(MANDIR)/man8 install-progs install-devel +install: $(BINDIR) $(RUNDIR) $(LOGDIR) $(MANDIR)/man8 install-progs install-devel install-progs: cd chat; $(MAKE) $(MFLAGS) install @@ -44,6 +46,10 @@ $(MANDIR)/man8: $(INSTALL) -d -m 755 $@ $(ETCDIR): $(INSTALL) -d -m 755 $@ +$(RUNDIR): + $(INSTALL) -d -m 755 $@ +$(LOGDIR): + $(INSTALL) -d -m 755 $@ clean: rm -f `find . -name '*.[oas]' -print` diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux index 060db6a..3a43820 100644 --- a/pppd/Makefile.linux +++ b/pppd/Makefile.linux @@ -8,6 +8,7 @@ DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin MANDIR = $(DESTDIR)/share/man/man8 INCDIR = $(DESTDIR)/include +LIBDIR = $(DESTDIR)/$(libdir) TARGETS = pppd @@ -33,7 +34,7 @@ endif # CC = gcc # COPTS = -O2 -pipe -Wall -g -LIBS = +LIBS = -lutil # Uncomment the next 2 lines to include support for Microsoft's # MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux. @@ -79,7 +80,7 @@ INCLUDE_DIRS= -I../include COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP -CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"' +CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"' '-DLIBDIR="$(libdir)"' ifdef CHAPMS CFLAGS += -DCHAPMS=1 @@ -135,7 +136,7 @@ endif # For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/. ifdef USE_PAM CFLAGS += -DUSE_PAM -LIBS += -lpam -ldl +LIBS += -lpam endif # Multi-linnk @@ -200,20 +201,18 @@ all: $(TARGETS) install: pppd mkdir -p $(BINDIR) $(MANDIR) $(EXTRAINSTALL) - $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd - if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \ - chmod o-rx,u+s $(BINDIR)/pppd; fi - $(INSTALL) -c -m 444 pppd.8 $(MANDIR) + $(INSTALL) -m 755 pppd $(BINDIR)/pppd + $(INSTALL) -m 644 pppd.8 $(MANDIR) pppd: $(PPPDOBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS) + $(CC) $(CFLAGS) -pie $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS) srp-entry: srp-entry.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS) install-devel: mkdir -p $(INCDIR)/pppd - $(INSTALL) -c -m 644 $(HEADERS) $(INCDIR)/pppd + $(INSTALL) -m 644 $(HEADERS) $(INCDIR)/pppd clean: rm -f $(PPPDOBJS) $(EXTRACLEAN) $(TARGETS) *~ #* core diff --git a/pppd/auth.c b/pppd/auth.c index fb71944..c0bdc50 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -227,6 +227,7 @@ bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ #ifdef CHAPMS bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +bool ms_ignore_domain = 0; /* Ignore any MS domain prefix */ #else bool refuse_mschap = 1; /* Don't wanna auth. ourselves with MS-CHAP */ bool refuse_mschap_v2 = 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ @@ -314,6 +315,8 @@ option_t auth_options[] = { "Require MS-CHAPv2 authentication from peer", OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT_V2, &lcp_wantoptions[0].chap_mdtype }, + { "ms-ignore-domain", o_bool, &ms_ignore_domain, + "Ignore any MS domain prefix in the username", 1 }, #endif { "refuse-pap", o_bool, &refuse_pap, @@ -2354,7 +2357,8 @@ auth_script(script) argv[3] = user_name; argv[4] = devnam; argv[5] = strspeed; - argv[6] = NULL; + argv[6] = ipparam; + argv[7] = NULL; auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0); } diff --git a/pppd/chap-new.c b/pppd/chap-new.c index 1386486..2b97a67 100644 --- a/pppd/chap-new.c +++ b/pppd/chap-new.c @@ -414,6 +414,14 @@ chap_verify_response(char *name, char *ourname, int id, int ok; unsigned char secret[MAXSECRETLEN]; int secret_len; +#ifdef CHAPMS + char nametmp[MAXNAMELEN]; + + if (ms_ignore_domain && strrchr(name, '\\')) { + strcpy(nametmp, strrchr(name, '\\') + 1); + strcpy(name, nametmp); + } +#endif /* Get the secret that the peer is supposed to know */ if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) { diff --git a/pppd/demand.c b/pppd/demand.c index 5e57658..4490677 100644 --- a/pppd/demand.c +++ b/pppd/demand.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,8 +45,11 @@ #include #include #include +#include +#include #ifdef PPP_FILTER #include +#include #endif #include "pppd.h" @@ -221,6 +226,14 @@ loop_chars(p, n) int c, rv; rv = 0; + +/* check for synchronous connection... */ + + if ( (p[0] == 0xFF) && (p[1] == 0x03) ) { + rv = loop_frame(p,n); + return rv; + } + for (; n > 0; --n) { c = *p++; if (c == PPP_FLAG) { @@ -299,17 +312,102 @@ loop_frame(frame, len) * loopback, now that the real serial link is up. */ void -demand_rexmit(proto) +demand_rexmit(proto, newip) int proto; + u_int32_t newip; { struct packet *pkt, *prev, *nextpkt; + unsigned short checksum; + unsigned short pkt_checksum = 0; + unsigned iphdr; + struct timeval tv; + char cv = 0; + char ipstr[16]; prev = NULL; pkt = pend_q; pend_q = NULL; + tv.tv_sec = 1; + tv.tv_usec = 0; + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */ for (; pkt != NULL; pkt = nextpkt) { nextpkt = pkt->next; if (PPP_PROTOCOL(pkt->data) == proto) { + if ( (proto == PPP_IP) && newip ) { + /* Get old checksum */ + + iphdr = (pkt->data[4] & 15) << 2; + checksum = *((unsigned short *) (pkt->data+14)); + if (checksum == 0xFFFF) { + checksum = 0; + } + + + if (pkt->data[13] == 17) { + pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr)); + if (pkt_checksum) { + cv = 1; + if (pkt_checksum == 0xFFFF) { + pkt_checksum = 0; + } + } + else { + cv = 0; + } + } + + if (pkt->data[13] == 6) { + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr)); + cv = 1; + if (pkt_checksum == 0xFFFF) { + pkt_checksum = 0; + } + } + + /* Delete old Source-IP-Address */ + checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + + /* Change Source-IP-Address */ + * ((u_int32_t *) (pkt->data + 16)) = newip; + + /* Add new Source-IP-Address */ + checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + + pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + + /* Write new checksum */ + if (!checksum) { + checksum = 0xFFFF; + } + *((unsigned short *) (pkt->data+14)) = checksum; + if (pkt->data[13] == 6) { + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum; + } + if (cv && (pkt->data[13] == 17) ) { + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum; + } + + /* Log Packet */ + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16)))); + if (pkt->data[13] == 1) { + syslog(LOG_INFO,"Open ICMP %s -> %s\n", + ipstr, + inet_ntoa(*( (struct in_addr *) (pkt->data+20)))); + } else { + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n", + pkt->data[13] == 6 ? "TCP" : "UDP", + ipstr, + ntohs(*( (short *) (pkt->data+iphdr+4))), + inet_ntoa(*( (struct in_addr *) (pkt->data+20))), + ntohs(*( (short *) (pkt->data+iphdr+6)))); + } + } output(0, pkt->data, pkt->length); free(pkt); } else { @@ -341,6 +439,7 @@ active_packet(p, len) return 0; proto = PPP_PROTOCOL(p); #ifdef PPP_FILTER + *p = 1; /* set outbound for the filter rule */ p[0] = 1; /* outbound packet indicator */ if ((pass_filter.bf_len != 0 && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) @@ -350,6 +449,7 @@ active_packet(p, len) return 0; } p[0] = 0xff; + *p = 0xff; /* restore original ppp header */ #endif for (i = 0; (protp = protocols[i]) != NULL; ++i) { if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 12bcc61..46121ff 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -91,6 +91,7 @@ struct notifier *ip_down_notifier = NULL; static int default_route_set[NUM_PPP]; /* Have set up a default route */ static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ static bool usepeerdns; /* Ask peer for DNS addrs */ +static bool noresolvconf; /* Don't modify /etc/resolv.conf */ static int ipcp_is_up; /* have called np_up() */ static int ipcp_is_open; /* haven't called np_finished() */ static bool ask_for_local; /* request our address from peer */ @@ -207,6 +208,9 @@ static option_t ipcp_option_list[] = { "disable proxyarp option", OPT_ALIAS | OPT_A2CLR, &ipcp_wantoptions[0].proxy_arp }, + { "noresolvconf", o_bool, &noresolvconf, + "Don't modify /etc/resolv.conf when ask peer for DNS address(es)", 1 }, + { "usepeerdns", o_bool, &usepeerdns, "Ask peer for DNS address(es)", 1 }, @@ -1808,7 +1812,8 @@ ipcp_up(f) script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); if (usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { script_setenv("USEPEERDNS", "1", 0); - create_resolv(go->dnsaddr[0], go->dnsaddr[1]); + if (!noresolvconf) + create_resolv(go->dnsaddr[0], go->dnsaddr[1]); } /* @@ -1864,7 +1869,7 @@ ipcp_up(f) proxy_arp_set[f->unit] = 1; } - demand_rexmit(PPP_IP); + demand_rexmit(PPP_IP,go->ouraddr); sifnpmode(f->unit, PPP_IP, NPMODE_PASS); } else { diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c index 4a09c9a..0d615d4 100644 --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c @@ -234,6 +234,8 @@ static option_t ipv6cp_option_list[] = { { "ipv6cp-accept-local", o_bool, &ipv6cp_allowoptions[0].accept_local, "Accept peer's interface identifier for us", 1 }, + { "ipv6cp-accept-remote", o_bool, &ipv6cp_allowoptions[0].accept_remote, + "Accept peer's interface identifier for itself", 1 }, { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip, "Use (default) IPv4 address as interface identifier", 1 }, @@ -426,6 +428,7 @@ ipv6cp_init(unit) memset(ao, 0, sizeof(*ao)); wo->accept_local = 1; + wo->accept_remote = 1; wo->neg_ifaceid = 1; ao->neg_ifaceid = 1; @@ -951,7 +954,7 @@ ipv6cp_reqci(f, inp, len, reject_if_disagree) orc = CONFREJ; /* Reject CI */ break; } - if (!eui64_iszero(wo->hisid) && + if (!eui64_iszero(wo->hisid) && !wo->accept_remote && !eui64_equals(ifaceid, wo->hisid) && eui64_iszero(go->hisid)) { @@ -1232,7 +1235,7 @@ ipv6cp_up(f) } } - demand_rexmit(PPP_IPV6); + demand_rexmit(PPP_IPV6,0); sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); } else { diff --git a/pppd/ipv6cp.h b/pppd/ipv6cp.h index cc4568d..8c7552e 100644 --- a/pppd/ipv6cp.h +++ b/pppd/ipv6cp.h @@ -150,7 +150,8 @@ typedef struct ipv6cp_options { int neg_ifaceid; /* Negotiate interface identifier? */ int req_ifaceid; /* Ask peer to send interface identifier? */ - int accept_local; /* accept peer's value for iface id? */ + int accept_local; /* accept peer's value for our iface id? */ + int accept_remote; /* accept peer's value for his iface id? */ int opt_local; /* ourtoken set by option */ int opt_remote; /* histoken set by option */ int use_ip; /* use IP as interface identifier */ diff --git a/pppd/main.c b/pppd/main.c index 014d614..9cdb2b6 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -124,7 +124,7 @@ static const char rcsid[] = RCSID; /* interface vars */ -char ifname[32]; /* Interface name */ +char ifname[MAXIFNAMELEN]; /* Interface name */ int ifunit; /* Interface unit number */ struct channel *the_channel; @@ -298,13 +298,6 @@ struct protent *protocols[] = { NULL }; -/* - * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name. - */ -#if !defined(PPP_DRV_NAME) -#define PPP_DRV_NAME "ppp" -#endif /* !defined(PPP_DRV_NAME) */ - int main(argc, argv) int argc; @@ -737,8 +730,11 @@ void set_ifunit(iskey) int iskey; { - info("Using interface %s%d", PPP_DRV_NAME, ifunit); + if (req_ifname[0] != '\0') + slprintf(ifname, sizeof(ifname), req_ifname); + else slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit); + info("Using interface %s", ifname); script_setenv("IFNAME", ifname, iskey); if (iskey) { create_pidfile(getpid()); /* write pid to file */ @@ -815,6 +811,11 @@ create_pidfile(pid) if ((pidfile = fopen(pidfilename, "w")) != NULL) { fprintf(pidfile, "%d\n", pid); (void) fclose(pidfile); + if (getuid() != geteuid()) { + if ((chown(pidfilename, getuid(), -1)) < 0) { + error("Failed to chown pid file %s: %m", pidfilename); + } + } } else { error("Failed to create pid file %s: %m", pidfilename); pidfilename[0] = 0; @@ -837,6 +838,11 @@ create_linkpidfile(pid) if (ifname[0]) fprintf(pidfile, "%s\n", ifname); (void) fclose(pidfile); + if (getuid() != geteuid()) { + if ((chown(linkpidfile, getuid(), -1)) < 0) { + error("Failed to chown pid file %s: %m", linkpidfile); + } + } } else { error("Failed to create pid file %s: %m", linkpidfile); linkpidfile[0] = 0; @@ -1544,14 +1550,6 @@ safe_fork(int infd, int outfd, int errfd) int fd, pipefd[2]; char buf[1]; - /* make sure fds 0, 1, 2 are occupied (probably not necessary) */ - while ((fd = dup(fd_devnull)) >= 0) { - if (fd > 2) { - close(fd); - break; - } - } - if (pipe(pipefd) == -1) pipefd[0] = pipefd[1] = -1; pid = fork(); @@ -1574,25 +1572,32 @@ safe_fork(int infd, int outfd, int errfd) tdb_close(pppdb); #endif - /* make sure infd, outfd and errfd won't get tromped on below */ - if (infd == 1 || infd == 2) + /* make sure fds 0, 1, 2 are occupied, so the duplicated fds always > 2 */ + while ((fd = dup(fd_devnull)) >= 0) { + if (fd > 2) { + close(fd); + break; + } + } + + /* always copy fd's to avoid to use a already closed fd later */ + { + int fdi = infd, fdo = outfd; + infd = dup(infd); - if (outfd == 0 || outfd == 2) outfd = dup(outfd); - if (errfd == 0 || errfd == 1) - errfd = dup(errfd); + if (errfd >= 0) { + fd = errfd; + errfd = dup(errfd); + close(fd); + } + close(fdi); + close(fdo); + } closelog(); - /* dup the in, out, err fds to 0, 1, 2 */ - if (infd != 0) - dup2(infd, 0); - if (outfd != 1) - dup2(outfd, 1); - if (errfd != 2) - dup2(errfd, 2); - - if (log_to_fd > 2) + if (log_to_fd >= 0) close(log_to_fd); if (the_channel->close) (*the_channel->close)(); @@ -1600,12 +1605,18 @@ safe_fork(int infd, int outfd, int errfd) close(devfd); /* some plugins don't have a close function */ close(fd_ppp); close(fd_devnull); - if (infd != 0) - close(infd); - if (outfd != 1) - close(outfd); - if (errfd != 2) + + close(0); + dup2(infd, 0); + close(infd); + close(1); + dup2(outfd, 1); + close(outfd); + if (errfd >= 0) { + close(2); + dup2(errfd, 2); close(errfd); + } notify(fork_notifier, 0); close(pipefd[0]); @@ -1633,7 +1644,7 @@ device_script(program, in, out, dont_wait) if (log_to_fd >= 0) errfd = log_to_fd; else - errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600); + errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0644); ++conn_running; pid = safe_fork(in, out, errfd); @@ -1826,8 +1837,8 @@ forget_child(pid, status) if (WIFSIGNALED(status)) { warn("Child process %s (pid %d) terminated with signal %d", (chp? chp->prog: "??"), pid, WTERMSIG(status)); - } else if (debug) - dbglog("Script %s finished (pid %d), status = 0x%x", + } else + info("Script %s finished (pid %d), status = 0x%x", (chp? chp->prog: "??"), pid, WIFEXITED(status) ? WEXITSTATUS(status) : status); if (chp && chp->done) diff --git a/pppd/options.c b/pppd/options.c index 482eab9..3da9eea 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -113,6 +113,8 @@ char linkname[MAXPATHLEN]; /* logical name for link */ bool tune_kernel; /* may alter kernel settings */ int connect_delay = 1000; /* wait this many ms after connect script */ int req_unit = -1; /* requested interface unit */ +int req_minunit = -1; /* requested minimal interface unit */ +char req_ifname[MAXIFNAMELEN]; /* requested interface name */ bool multilink = 0; /* Enable multilink operation */ char *bundle_name = NULL; /* bundle name for multilink */ bool dump_options; /* print out option values */ @@ -271,6 +273,13 @@ option_t general_options[] = { { "unit", o_int, &req_unit, "PPP interface unit number to use if possible", OPT_PRIO | OPT_LLIMIT, 0, 0 }, + { "minunit", o_int, &req_minunit, + "PPP interface minimal unit number", + OPT_PRIO | OPT_LLIMIT, 0, 0 }, + + { "ifname", o_string, req_ifname, + "Set PPP interface name", + OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN }, { "dump", o_bool, &dump_options, "Print out option values after parsing all options", 1 }, @@ -735,6 +744,7 @@ process_option(opt, cmd, argv) return 0; } } + if(!strcmp(opt->name, "holdoff")) holdoff_specified = 1; *(int *)(opt->addr) = iv; if (opt->addr2 && (opt->flags & OPT_A2COPY)) *(int *)(opt->addr2) = iv; @@ -989,6 +999,8 @@ print_option_list(opt, printer, arg) void (*printer) __P((void *, char *, ...)); void *arg; { + if(!opt) return; + while (opt->name != NULL) { if (opt->priority != OPRIO_DEFAULT && opt->winner != (short int) -1) @@ -1466,6 +1478,10 @@ setpassfilter(argv) int ret = 1; pc = pcap_open_dead(DLT_PPP_PPPD, 65535); + if (!pc) { + option_error("error in pass-filter expression: pcap_open_dead failed\n"); + return 0; + } if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) { option_error("error in pass-filter expression: %s\n", pcap_geterr(pc)); @@ -1487,6 +1503,11 @@ setactivefilter(argv) int ret = 1; pc = pcap_open_dead(DLT_PPP_PPPD, 65535); + if (!pc) { + option_error("error in active-filter expression: pcap_open_dead failed\n"); + return 0; + } + if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) { option_error("error in active-filter expression: %s\n", pcap_geterr(pc)); diff --git a/pppd/pathnames.h b/pppd/pathnames.h index a33f046..2d2cb44 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -7,9 +7,13 @@ #ifdef HAVE_PATHS_H #include +#define _SUBPATH_PPP "ppp/" #else /* HAVE_PATHS_H */ #ifndef _PATH_VARRUN #define _PATH_VARRUN "/etc/ppp/" +#define _SUBPATH_PPP +#else +#define _SUBPATH_PPP "ppp/" #endif #define _PATH_DEVNULL "/dev/null" #endif /* HAVE_PATHS_H */ @@ -28,9 +32,9 @@ #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up" #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down" #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options." -#define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors" +#define _PATH_CONNERRS _ROOT_PATH "/var/log/ppp/connect-errors" #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/" -#define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf" +#define _PATH_RESOLV _ROOT_PATH "/var/run/ppp/resolv.conf" #define _PATH_USEROPT ".ppprc" #define _PATH_PSEUDONYM ".ppp_pseudonym" @@ -46,10 +50,10 @@ #endif /* IPX_CHANGE */ #ifdef __STDC__ -#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd2.tdb" +#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN _SUBPATH_PPP "pppd2.tdb" #else /* __STDC__ */ #ifdef HAVE_PATHS_H -#define _PATH_PPPDB "/var/run/pppd2.tdb" +#define _PATH_PPPDB "/var/run/ppp/pppd2.tdb" #else #define _PATH_PPPDB "/etc/ppp/pppd2.tdb" #endif @@ -57,7 +61,7 @@ #ifdef PLUGIN #ifdef __STDC__ -#define _PATH_PLUGIN DESTDIR "/lib/pppd/" VERSION +#define _PATH_PLUGIN LIBDIR "/pppd/" VERSION #else /* __STDC__ */ #define _PATH_PLUGIN "/usr/lib/pppd" #endif /* __STDC__ */ diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux index 0a7ec7b..da3aa05 100644 --- a/pppd/plugins/Makefile.linux +++ b/pppd/plugins/Makefile.linux @@ -7,7 +7,8 @@ INSTALL = install DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin MANDIR = $(DESTDIR)/share/man/man8 -LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) +VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h) +LIBDIR = $(DESTDIR)/$(libdir)/pppd/$(VERSION) SUBDIRS := rp-pppoe pppoatm pppol2tp # Uncomment the next line to include the radius authentication plugin @@ -25,10 +26,8 @@ all: $(PLUGINS) %.so: %.c $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ -VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h) - install: $(PLUGINS) - $(INSTALL) -d $(LIBDIR) + mkdir -p $(LIBDIR) $(INSTALL) $? $(LIBDIR) for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d install; done diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux index 20f62e6..b052d2f 100644 --- a/pppd/plugins/pppoatm/Makefile.linux +++ b/pppd/plugins/pppoatm/Makefile.linux @@ -7,7 +7,7 @@ INSTALL = install #*********************************************************************** DESTDIR = $(INSTROOT)@DESTDIR@ -LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) +LIBDIR = $(DESTDIR)/$(libdir)/pppd/$(VERSION) VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) @@ -36,8 +36,8 @@ $(PLUGIN): $(PLUGIN_OBJS) $(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS) install: all - $(INSTALL) -d -m 755 $(LIBDIR) - $(INSTALL) -c -m 4550 $(PLUGIN) $(LIBDIR) + mkdir -p $(LIBDIR) + $(INSTALL) -m 755 $(PLUGIN) $(LIBDIR) clean: rm -f *.o *.so diff --git a/pppd/plugins/pppol2tp/Makefile.linux b/pppd/plugins/pppol2tp/Makefile.linux index 19eff67..d8a8f5a 100644 --- a/pppd/plugins/pppol2tp/Makefile.linux +++ b/pppd/plugins/pppol2tp/Makefile.linux @@ -7,9 +7,9 @@ INSTALL = install #*********************************************************************** DESTDIR = @DESTDIR@ -LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) +LIBDIR = $(DESTDIR)/$(libdir)/pppd/$(VERSION) PLUGINS := pppol2tp.so openl2tp.so diff --git a/pppd/plugins/radius/Makefile.linux b/pppd/plugins/radius/Makefile.linux index 24ed3e5..e7e3f0c 100644 --- a/pppd/plugins/radius/Makefile.linux +++ b/pppd/plugins/radius/Makefile.linux @@ -5,14 +5,13 @@ DESTDIR = $(INSTROOT)@DESTDIR@ MANDIR = $(DESTDIR)/share/man/man8 -LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) - VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) +LIBDIR = $(DESTDIR)/$(libdir)/pppd/$(VERSION) INSTALL = install PLUGIN=radius.so radattr.so radrealms.so -CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON +CFLAGS= $(COPTS) -I. -I../.. -I../../../include -DRC_LOG_FACILITY=LOG_DAEMON # Uncomment the next line to include support for Microsoft's # MS-CHAP authentication protocol. @@ -35,12 +34,12 @@ endif all: $(PLUGIN) install: all - $(INSTALL) -d -m 755 $(LIBDIR) - $(INSTALL) -s -c -m 755 radius.so $(LIBDIR) - $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR) - $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR) - $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR) - $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR) + mkdir -p $(LIBDIR) + $(INSTALL) -m 755 radius.so $(LIBDIR) + $(INSTALL) -m 755 radattr.so $(LIBDIR) + $(INSTALL) -m 755 radrealms.so $(LIBDIR) + $(INSTALL) -m 644 pppd-radius.8 $(MANDIR) + $(INSTALL) -m 644 pppd-radattr.8 $(MANDIR) radius.so: radius.o libradiusclient.a $(CC) -o radius.so -shared radius.o libradiusclient.a diff --git a/pppd/plugins/radius/clientid.c b/pppd/plugins/radius/clientid.c index d49579c..91201b0 100644 --- a/pppd/plugins/radius/clientid.c +++ b/pppd/plugins/radius/clientid.c @@ -104,13 +104,13 @@ int rc_read_mapfile(char *filename) UINT4 rc_map2id(char *name) { struct map2id_s *p; - char ttyname[PATH_MAX]; + char ttyname[PATH_MAX + 1]; *ttyname = '\0'; if (*name != '/') strcpy(ttyname, "/dev/"); - strncat(ttyname, name, sizeof(ttyname)); + strlcat(ttyname, name, sizeof(ttyname)); for(p = map2id_list; p; p = p->next) if (!strcmp(ttyname, p->name)) return p->id; diff --git a/pppd/plugins/rp-pppoe/Makefile.linux b/pppd/plugins/rp-pppoe/Makefile.linux index 5d7a271..0364011 100644 --- a/pppd/plugins/rp-pppoe/Makefile.linux +++ b/pppd/plugins/rp-pppoe/Makefile.linux @@ -16,9 +16,9 @@ DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin -LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION) - +MANDIR = $(DESTDIR)/share/man/man8 PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) +LIBDIR = $(DESTDIR)/$(libdir)/pppd/$(PPPDVERSION) INSTALL = install @@ -42,10 +42,11 @@ rp-pppoe.so: plugin.o discovery.o if.o common.o $(CC) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o install: all - $(INSTALL) -d -m 755 $(LIBDIR) - $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR) - $(INSTALL) -d -m 755 $(BINDIR) - $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR) + mkdir -p $(LIBDIR) + $(INSTALL) -m 755 rp-pppoe.so $(LIBDIR) + mkdir -p $(BINDIR) + $(INSTALL) -m 755 pppoe-discovery $(BINDIR) + $(INSTALL) -c -m 644 pppoe-discovery.8 $(MANDIR) clean: rm -f *.o *.so pppoe-discovery diff --git a/pppd/plugins/rp-pppoe/plugin.c b/pppd/plugins/rp-pppoe/plugin.c index e94494b..3263f41 100644 --- a/pppd/plugins/rp-pppoe/plugin.c +++ b/pppd/plugins/rp-pppoe/plugin.c @@ -49,6 +49,12 @@ static char const RCSID[] = #include #include #include + +#ifndef aligned_u64 +#warning ugly hack: aligned_u64 must be defined in linux/types.h +#define aligned_u64 __u64 __attribute__((aligned(8))) +#endif + #include #include diff --git a/pppd/plugins/rp-pppoe/pppoe-discovery.8 b/pppd/plugins/rp-pppoe/pppoe-discovery.8 new file mode 100644 index 0000000..d0a93db --- /dev/null +++ b/pppd/plugins/rp-pppoe/pppoe-discovery.8 @@ -0,0 +1,86 @@ +.\" pppoe-discovery.8 written by +.\" Ben Hutchings , based on pppoe.8. +.\" Licenced under the GPL version 2 or later. +.TH PPPOE-DISCOVERY 8 +.SH NAME +pppoe\-discovery \- perform PPPoE discovery +.SH SYNOPSIS +.B pppoe\-discovery +[ +.I options +] +.br +.BR pppoe\-discovery " { " \-V " | " \-h " }" +.SH DESCRIPTION +.LP +\fBpppoe\-discovery\fR performs the same discovery process as +\fBpppoe\fR, but does not initiate a session. +It sends a PADI packet and then prints the names of access +concentrators in each PADO packet it receives. +.SH OPTIONS +.TP +.BI \-I " interface" +.RS +The \fB\-I\fR option specifies the Ethernet interface to use. +Under Linux, it is typically eth0 or eth1. +The interface should be \(lqup\(rq before you start +\fBpppoe\-discovery\fR, but should \fInot\fR be configured to have an +IP address. +The default interface is eth0. +.RE +.TP +.BI \-D " file_name" +.RS +The \fB\-D\fR option causes every packet to be dumped to the specified +\fIfile_name\fR. +This is intended for debugging only. +.RE +.TP +.B \-U +.RS +Causes \fBpppoe\-discovery\fR to use the Host-Uniq tag in its discovery +packets. +This lets you run multiple instances of \fBpppoe\-discovery\fR and/or +\fBpppoe\fR without having their discovery packets interfere with one +another. +You must supply this option to \fIall\fR instances that you intend to +run simultaneously. +.RE +.TP +.BI \-S " service_name" +.RS +Specifies the desired service name. +\fBpppoe\-discovery\fR will only accept access concentrators which can +provide the specified service. +In most cases, you should \fInot\fR specify this option. +Use it only if you know that there are multiple access concentrators +or know that you need a specific service name. +.RE +.TP +.BI \-C " ac_name" +.RS +Specifies the desired access concentrator name. +\fBpppoe\-discovery\fR will only accept the specified access +concentrator. +In most cases, you should \fInot\fR specify this option. +Use it only if you know that there are multiple access concentrators. +If both the \fB\-S\fR and \fB\-C\fR options are specified, they must +\fIboth\fR match. +.RE +.TP +.B \-A +.RS +This option is accepted for compatibility with \fBpppoe\fR, but has no +effect. +.RE +.TP +.BR \-V " | " \-h +.RS +Either of these options causes \fBpppoe\-discovery\fR to print its +version number and usage information, then exit. +.RE +.SH AUTHORS +\fBpppoe\-discovery\fR was written by Marco d'Itri , +based on \fBpppoe\fR by David F. Skoll . +.SH SEE ALSO +pppoe(8), pppoe-sniff(8) diff --git a/pppd/plugins/winbind.c b/pppd/plugins/winbind.c index bb05acd..597394e 100644 --- a/pppd/plugins/winbind.c +++ b/pppd/plugins/winbind.c @@ -296,16 +296,23 @@ unsigned int run_ntlm_auth(const char *username, if (forkret == 0) { /* child process */ - uid_t uid; + uid_t uid = getuid(); close(child_out[0]); close(child_in[1]); /* run winbind as the user that invoked pppd */ setgid(getgid()); - uid = getuid(); if (setuid(uid) == -1 || getuid() != uid) + { fatal("pppd/winbind: could not setuid to %d: %m", uid); + exit(1); + } + if (getuid() != uid) { + perror("pppd/winbind: could not setuid to orig uid"); + exit(1); + } + execl("/bin/sh", "sh", "-c", ntlm_auth, NULL); fatal("pppd/winbind: could not exec /bin/sh: %m"); } diff --git a/pppd/pppd.8 b/pppd/pppd.8 index 8ea8200..cbe83bb 100644 --- a/pppd/pppd.8 +++ b/pppd/pppd.8 @@ -1048,7 +1048,18 @@ under Linux and FreeBSD 2.2.8 and later. .TP .B unit \fInum Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound -connections. +connections. If the unit is already in use a dynamically allocated will be +used. +.TP +.B ifname \fIstring +Set the ppp interface name for outbound connections. A failure to set the +name will terminate the pppd. +.TP +.B minunit \fInum +Such as unit, but always select bigger interface +.TP +.B minunit \fInum +PPP interface minimal unit number. Such as unit, but always select bigger interface .TP .B updetach With this option, pppd will detach from its controlling terminal once diff --git a/pppd/pppd.h b/pppd/pppd.h index cf9840a..743f7a6 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -57,14 +57,17 @@ #include #include "patchlevel.h" +#undef __P #if defined(__STDC__) #include #define __V(x) x +#define __P(args) args #else #include #define __V(x) (va_alist) va_dcl #define const #define volatile +#define __P(args) #endif #ifdef INET6 @@ -80,6 +83,17 @@ #define MAXARGS 1 /* max # args to a command */ #define MAXNAMELEN 256 /* max length of hostname or name for auth */ #define MAXSECRETLEN 256 /* max length of password or secret */ +#define MAXUNIT 255 /* max ppp interface */ +#define MAXIFNAMELEN 32 /* max length of interface name; or use IFNAMSIZ, can we + always include net/if.h? */ + +/* + * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name. + * Where should PPP_DRV_NAME come from? Do we include it here? + */ +#if !defined(PPP_DRV_NAME) +#define PPP_DRV_NAME "ppp" +#endif /* !defined(PPP_DRV_NAME) */ /* * Option descriptor structure. @@ -313,6 +327,8 @@ extern bool tune_kernel; /* May alter kernel settings as necessary */ extern int connect_delay; /* Time to delay after connect script */ extern int max_data_rate; /* max bytes/sec through charshunt */ extern int req_unit; /* interface unit number to use */ +extern int req_minunit; /* interface minimal unit number to use */ +extern char req_ifname[MAXIFNAMELEN]; /* interface name to use */ extern bool multilink; /* enable multilink operation */ extern bool noendpoint; /* don't send or accept endpt. discrim. */ extern char *bundle_name; /* bundle name for multilink */ @@ -320,6 +336,10 @@ extern bool dump_options; /* print out option values */ extern bool dryrun; /* check everything, print options, exit */ extern int child_wait; /* # seconds to wait for children at end */ +#ifdef CHAPMS +extern bool ms_ignore_domain; /* Ignore any MS domain prefix */ +#endif + #ifdef MAXOCTETS extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ extern int maxoctets_dir; /* Direction : @@ -564,7 +584,7 @@ void demand_conf __P((void)); /* config interface(s) for demand-dial */ void demand_block __P((void)); /* set all NPs to queue up packets */ void demand_unblock __P((void)); /* set all NPs to pass packets */ void demand_discard __P((void)); /* set all NPs to discard packets */ -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */ +void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/ int loop_chars __P((unsigned char *, int)); /* process chars from loopback */ int loop_frame __P((unsigned char *, int)); /* should we bring link up? */ @@ -655,8 +675,6 @@ u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */ int lock __P((char *)); /* Create lock file for device */ int relock __P((int)); /* Rewrite lock file with new pid */ void unlock __P((void)); /* Delete previously-created lock file */ -void logwtmp __P((const char *, const char *, const char *)); - /* Write entry to wtmp file */ int get_host_seed __P((void)); /* Get host-dependent random number seed */ int have_route_to __P((u_int32_t)); /* Check if route to addr exists */ #ifdef PPP_FILTER diff --git a/pppd/sha1.c b/pppd/sha1.c index f4f975c..a11ae1b 100644 --- a/pppd/sha1.c +++ b/pppd/sha1.c @@ -18,6 +18,7 @@ #include #include /* htonl() */ +#include /* u_int32_t */ #include #include "sha1.h" diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index b675c97..876863c 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -627,15 +627,43 @@ static int make_ppp_unit() || fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1) warn("Couldn't set /dev/ppp to nonblock: %m"); - ifunit = req_unit; - x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); - if (x < 0 && req_unit >= 0 && errno == EEXIST) { + if (req_minunit > -1) { + for(ifunit = req_minunit;req_minunit < MAXUNIT; ifunit = ++req_minunit) { + x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + if (x < 0 && errno == EEXIST) { + warn("Couldn't allocate PPP unit %d as it is already in use try to attempt next", req_minunit); + } + if (x >= 0) + break; + } + } + if ((x < 0) || (req_minunit == -1)) { + ifunit = req_unit; + x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + if (x < 0 && req_unit >= 0 && errno == EEXIST) { warn("Couldn't allocate PPP unit %d as it is already in use", req_unit); ifunit = -1; x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + } } + if (x < 0) error("Couldn't create new ppp unit: %m"); + + if (x == 0 && req_ifname[0] != '\0') { + struct ifreq ifr; + char t[MAXIFNAMELEN]; + memset(&ifr, 0, sizeof(struct ifreq)); + slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit); + strncpy(ifr.ifr_name, t, IF_NAMESIZE); + strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE); + x = ioctl(sock_fd, SIOCSIFNAME, &ifr); + if (x < 0) + error("Couldn't rename interface %s to %s: %m", t, req_ifname); + else + info("Renamed interface %s to %s", t, req_ifname); + } + return x; } @@ -2150,81 +2178,6 @@ int ppp_available(void) /******************************************************************** * - * Update the wtmp file with the appropriate user name and tty device. - */ - -void logwtmp (const char *line, const char *name, const char *host) -{ - struct utmp ut, *utp; - pid_t mypid = getpid(); -#if __GLIBC__ < 2 - int wtmp; -#endif - -/* - * Update the signon database for users. - * Christoph Lameter: Copied from poeigl-1.36 Jan 3, 1996 - */ - utmpname(_PATH_UTMP); - setutent(); - while ((utp = getutent()) && (utp->ut_pid != mypid)) - /* nothing */; - - if (utp) - memcpy(&ut, utp, sizeof(ut)); - else - /* some gettys/telnetds don't initialize utmp... */ - memset(&ut, 0, sizeof(ut)); - - if (ut.ut_id[0] == 0) - strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id)); - - strncpy(ut.ut_user, name, sizeof(ut.ut_user)); - strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - - time(&ut.ut_time); - - ut.ut_type = USER_PROCESS; - ut.ut_pid = mypid; - - /* Insert the host name if one is supplied */ - if (*host) - strncpy (ut.ut_host, host, sizeof(ut.ut_host)); - - /* Insert the IP address of the remote system if IP is enabled */ - if (ipcp_protent.enabled_flag && ipcp_hisoptions[0].neg_addr) - memcpy(&ut.ut_addr, (char *) &ipcp_hisoptions[0].hisaddr, - sizeof(ut.ut_addr)); - - /* CL: Makes sure that the logout works */ - if (*host == 0 && *name==0) - ut.ut_host[0]=0; - - pututline(&ut); - endutent(); -/* - * Update the wtmp file. - */ -#if __GLIBC__ >= 2 - updwtmp(_PATH_WTMP, &ut); -#else - wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY); - if (wtmp >= 0) { - flock(wtmp, LOCK_EX); - - if (write (wtmp, (char *)&ut, sizeof(ut)) != sizeof(ut)) - warn("error writing %s: %m", _PATH_WTMP); - - flock(wtmp, LOCK_UN); - - close (wtmp); - } -#endif -} - - -/******************************************************************** - * * sifvjcomp - config tcp header compression */ diff --git a/pppd/utils.c b/pppd/utils.c index 062b17e..6356bb5 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -290,7 +290,7 @@ vslprintf(buf, buflen, fmt, args) #if 0 /* not used, and breaks on S/390, apparently */ case 'r': f = va_arg(args, char *); -#ifndef __powerpc__ +#if !defined(__powerpc__) && !defined(__s390__) && !defined(__s390x__) && !defined(__x86_64__) n = vslprintf(buf, buflen + 1, f, va_arg(args, va_list)); #else /* On the powerpc, a va_list is an array of 1 structure */ @@ -859,7 +859,7 @@ complete_read(int fd, void *buf, size_t count) /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR #ifdef __linux__ -#define LOCK_DIR "/var/lock" +#define LOCK_DIR "/var/lock/serial" #else #ifdef SVR4 #define LOCK_DIR "/var/spool/locks" diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux index ac028f6..867891d 100644 --- a/pppdump/Makefile.linux +++ b/pppdump/Makefile.linux @@ -17,5 +17,5 @@ clean: install: mkdir -p $(BINDIR) $(MANDIR) - $(INSTALL) -s -c pppdump $(BINDIR) - $(INSTALL) -c -m 444 pppdump.8 $(MANDIR) + $(INSTALL) -m 755 pppdump $(BINDIR) + $(INSTALL) -m 644 pppdump.8 $(MANDIR) diff --git a/pppstats/Makefile.linux b/pppstats/Makefile.linux index cca6f0f..c075857 100644 --- a/pppstats/Makefile.linux +++ b/pppstats/Makefile.linux @@ -21,9 +21,9 @@ CFLAGS = $(COPTS) $(COMPILE_FLAGS) all: pppstats install: pppstats - -mkdir -p $(MANDIR) - $(INSTALL) -s -c pppstats $(BINDIR) - $(INSTALL) -c -m 444 pppstats.8 $(MANDIR) + mkdir -p $(MANDIR) + $(INSTALL) -m 755 pppstats $(BINDIR) + $(INSTALL) -m 644 pppstats.8 $(MANDIR) pppstats: $(PPPSTATSRCS) $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)