aboutsummaryrefslogtreecommitdiffstats
path: root/src/Makefile
blob: fd4a4d5fac8b9217285d29ca2757c9e60c0e3f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE

PROGS=usernetctl doexec netreport testd usleep ipcalc initlog minilogd \
	getkey ppp-watch consoletype
PPPWATCH_OBJS=ppp-watch.o shvar.o
INITLOG_OBJS=initlog.o process.o
USLEEP_OBJS=usleep.o

mandir=/usr/share/man

all:	$(PROGS)

clean:
	rm -f $(PROGS) *.o

install:
	mkdir -p $(ROOT)/bin $(ROOT)/usr/sbin $(ROOT)$(mandir)/man{1,8} $(ROOT)/etc
	install -s -m 755 doexec $(ROOT)/bin/doexec
	install -s -m 755 usleep $(ROOT)/bin/usleep
	install -s -m 4755 usernetctl $(ROOT)/usr/sbin/usernetctl
	install -s -m 2755 netreport $(ROOT)/sbin/netreport
	install -s -m 755 ipcalc $(ROOT)/bin/ipcalc
	install -s -m 755 initlog $(ROOT)/sbin/initlog
	install -s -m 755 minilogd $(ROOT)/sbin/minilogd
	install -s -m 755 getkey $(ROOT)/sbin/getkey
	install -s -m 755 ppp-watch $(ROOT)/sbin/ppp-watch
	install -s -m 755 consoletype $(ROOT)/sbin/consoletype
	install -m 644 initlog.1 $(ROOT)$(mandir)/man1
	install -m 644 doexec.1 $(ROOT)$(mandir)/man1
	install -m 644 netreport.1 $(ROOT)$(mandir)/man1
	install -m 644 usleep.1 $(ROOT)$(mandir)/man1
	install -m 644 usernetctl.8 $(ROOT)$(mandir)/man8
	install -m 644 ppp-watch.8 $(ROOT)$(mandir)/man8
	install -m 644 ipcalc.1 $(ROOT)$(mandir)/man1
	install -m 644 consoletype.1 $(ROOT)$(mandir)/man1
	install -m 644 initlog.conf $(ROOT)/etc
	install -m 755 mkkerneldoth $(ROOT)/sbin
	if uname -m | grep -q s390 ; then \
	  install -m 755 mkkerneldoth.s390 $(ROOT)/sbin/mkkerneldoth ; \
	fi

# this daemon and initscript are useful for testing the up/down/status stuff
# not installed by default, only comes from sources.
install-test:
	install -s -m 755 testd $(ROOT)/usr/sbin/testd
	install -m 755 testdinit $(ROOT)/etc/init.d/testd

ipcalc: ipcalc.o
	$(CC) $(LDFLAGS) -o $@ $< /usr/lib/libpopt.a

initlog: $(INITLOG_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(INITLOG_OBJS) /usr/lib/libpopt.a

usleep: $(USLEEP_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(USLEEP_OBJS) /usr/lib/libpopt.a

ppp-watch: $(PPPWATCH_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(PPPWATCH_OBJS) /usr/lib/libglib.a
shvar.o: shvar.c
	$(CC) $(CFLAGS) `glib-config --cflags` -c shvar.c -o shvar.o
ppp-watch.o: ppp-watch.c
	$(CC) $(CFLAGS) `glib-config --cflags` -c ppp-watch.c -o ppp-watch.o
"1492", "mru", "1492", "noaccomp", "noccp", "nobsdcomp", "nodeflate", "nopcomp", "novj", "novjccomp", "user", username, "password", password, "lcp-echo-interval", "20", "lcp-echo-failure", "3", "lock", "persist", NULL }; int fd; int retries = 10; char * tty_adsl = "/dev/tty6"; enum return_type status = RETURN_ERROR; pid_t ppp_pid; snprintf(pppoe_call, sizeof(pppoe_call), "/sbin/pppoe -p /var/run/pppoe.conf-adsl.pid.pppoe -I %s -T 80 -U -m 1412", net_device); fd = open(tty_adsl, O_RDWR); if (fd == -1) { log_message("cannot open tty -- no pppd"); return RETURN_ERROR; } else if (access(pppd_launch[0], X_OK)) { log_message("cannot open pppd - %s doesn't exist", pppd_launch[0]); return RETURN_ERROR; } if (!(ppp_pid = fork())) { dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); close(fd); setsid(); if (ioctl(0, TIOCSCTTY, NULL)) log_perror("could not set new controlling tty"); printf("\t(exec of pppd)\n"); execve(pppd_launch[0], pppd_launch, grab_env()); log_message("execve of %s failed: %s", pppd_launch[0], strerror(errno)); exit(-1); } close(fd); while (retries > 0 && kill(ppp_pid, 0) == 0) { FILE * f; if ((f = fopen("/var/run/pppd.tdb", "rb"))) { while (1) { char buf[500]; if (!fgets(buf, sizeof(buf), f)) break; if (strstr(buf, "IPLOCAL=")) status = RETURN_OK; } fclose(f); if (status == RETURN_OK) { log_message("PPP: connected!"); break; } } retries--; log_message("PPP: <sleep>"); sleep(2); } if (status != RETURN_OK) { log_message("PPP: could not connect"); kill(ppp_pid, SIGTERM); sleep(1); kill(ppp_pid, SIGKILL); sleep(1); } return status; } enum return_type perform_adsl(struct interface_info * intf) { struct in_addr addr; char * questions[] = { "Username", "Password", NULL }; char * questions_auto[] = { "adsluser", "adslpass", NULL }; static char ** answers = NULL; enum return_type results; inet_aton("10.0.0.10", &addr); memcpy(&intf->ip, &addr, sizeof(addr)); inet_aton("255.255.255.0", &addr); memcpy(&intf->netmask, &addr, sizeof(addr)); *((uint32_t *) &intf->broadcast) = (*((uint32_t *) &intf->ip) & *((uint32_t *) &intf->netmask)) | ~(*((uint32_t *) &intf->netmask)); intf->is_ptp = 0; if (configure_net_device(intf)) { stg1_error_message("Could not configure.."); return RETURN_ERROR; } results = ask_from_entries_auto("Please enter the username and password for your ADSL account.\n" "(Warning! only PPPoE protocol is supported)", questions, &answers, 40, questions_auto, NULL); if (results != RETURN_OK) return results; intf->boot_proto = BOOTPROTO_ADSL_PPPOE; wait_message("Waiting for ADSL connection to show up..."); my_insmod("ppp_generic", ANY_DRIVER_TYPE, NULL); my_insmod("ppp_async", ANY_DRIVER_TYPE, NULL); my_insmod("ppp", ANY_DRIVER_TYPE, NULL); results = adsl_connect(intf->device, answers[0], answers[1]); remove_wait_message();