summaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-ppp
blob: 2931940abc112f9086a9e87c74b0394283262eea (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin

cd /etc/sysconfig/network-scripts
. network-functions
. /etc/rc.d/init.d/functions


# ifup-post for PPP is handled through /etc/ppp/ip-up

if [ "${1}" = daemon ] ; then
  # we've been called from ppp-watch, so don't invoke it for persistence
  shift
else
  # just in case a full path to the configuration file is passed in
  CONFIG=$(basename $1)
  [ -f "${CONFIG}" ] || CONFIG=ifcfg-${1}
  source_config
  if [ "${DEMAND}" != yes ] ; then
    # let ppp-watch do the right thing
    shift
    exec /sbin/ppp-watch "${DEVICE}" "$@"
  fi
fi

CONFIG=$1
[ -f "${CONFIG}" ] || CONFIG=ifcfg-${1}
source_config

if [ -z "${DISCONNECTTIMEOUT}" ]; then
  DISCONNECTTIMEOUT=2
fi

if [ -z "${RETRYTIMEOUT}" ]; then
  RETRYTIMEOUT=30
fi

if [ -z "${IDLETIMEOUT}" ]; then
  IDLETIMEOUT=600
fi

if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then
  exit
fi

[ -x /usr/sbin/pppd ] || {
  echo $"/usr/sbin/pppd does not exist or is not executable"
  echo $"ifup-ppp for ${DEVICE} exiting"
  logger -p daemon.info -t ifup-ppp \
    $"/usr/sbin/pppd does not exist or is not executable for ${DEVICE}"
  exit 1
}

[ -n "${WVDIALSECT}" -o -f /etc/sysconfig/network-scripts/chat-${DEVICE} ] || {
  echo $"/etc/sysconfig/network-scripts/chat-${DEVICE} does not exist"
  echo $"ifup-ppp for ${DEVICE} exiting"
  logger -p daemon.info -t ifup-ppp \
    $"/etc/sysconfig/network-scripts/chat-${DEVICE} does not exist for ${DEVICE}"
  exit 1
}

opts="lock"
if [ "${HARDFLOWCTL}" != no ] ; then
  opts="$opts modem crtscts"
fi
if [ "${ESCAPECHARS}" != yes ] ; then
  opts="$opts asyncmap 00000000"
fi
if [ "${DEFROUTE}" != no ] ; then
  # pppd will no longer delete an existing default route
  # so we have to help it out a little here.
  route del default >/dev/null 2>&1
  opts="$opts defaultroute"
fi
if [ "${PEERDNS}" != no ] ; then
  opts="$opts usepeerdns"
fi
if [ -n "${MRU}" ] ; then
  opts="$opts mru ${MRU}"
fi
if [ -n "${MTU}" ] ; then
  opts="$opts mtu ${MTU}"
fi
if [ -n "${IPADDR}${REMIP}" ] ; then
  # if either IP address is set, the following will work.
  opts="$opts ${IPADDR}:${REMIP}"
fi
if [ -n "${PAPNAME}" ] ; then
  opts="$opts user ${PAPNAME} remotename ${DEVNAME}"
fi
if [ "${DEBUG}" = yes ] ; then
  opts="$opts debug"
  chatdbg="-v"
fi

if [ ${DEMAND} = yes ] ; then
  opts="$opts demand ktune idle ${IDLETIMEOUT} holdoff ${RETRYTIMEOUT}"
else
  opts="$opts nodetach"
fi

if [ -z "${WVDIALSECT}" ] ; then
  CHATSCRIPT=/etc/sysconfig/network-scripts/chat-${DEVNAME}
  [ -f "${CHATSCRIPT}" ] || {
    CHATSCRIPT=/etc/sysconfig/network-scripts/chat-${PARENTDEVNAME}
  }
else
  CHATSCRIPT=
fi

(logger -p daemon.info -t ifup-ppp \
  $"pppd started for ${DEVICE} on ${MODEMPORT} at ${LINESPEED}" &)&

if [ -n "${WVDIALSECT}" ] ; then
  exec /usr/sbin/pppd $opts ${MODEMPORT} ${LINESPEED} \
    ipparam ${DEVICE} linkname ${DEVICE} \
    noauth \
    ${PPPOPTIONS} \
    connect "/usr/bin/wvdial --remotename ${DEVICE} --chat ${WVDIALSECT}"
else
  exec /usr/sbin/pppd $opts ${MODEMPORT} ${LINESPEED} \
    ipparam ${DEVICE} linkname ${DEVICE} \
    noauth \
    ${PPPOPTIONS} \
    connect "/usr/sbin/chat $chatdbg -f ${CHATSCRIPT}"
fi
='n203' href='#n203'>203 204 205 206 207 208
/*
   SSSD

   Fail over helper functions.

   Authors:
        Martin Nagy <mnagy@redhat.com>

   Copyright (C) Red Hat, Inc 2009

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __FAIL_OVER_H__
#define __FAIL_OVER_H__

#include <stdbool.h>
#include <talloc.h>

#include "resolv/async_resolv.h"
#include "providers/fail_over_srv.h"

#define FO_PROTO_TCP "tcp"
#define FO_PROTO_UDP "udp"

/* Some forward declarations that don't have to do anything with fail over. */
struct hostent;
struct tevent_context;
struct tevent_req;

enum port_status {
    PORT_NEUTRAL,    /* We didn't try this port yet. */
    PORT_WORKING,    /* This port was reported to work. */
    PORT_NOT_WORKING /* This port was reported to not work. */
};

enum server_status {
    SERVER_NAME_NOT_RESOLVED, /* We didn't yet resolved the host name. */
    SERVER_RESOLVING_NAME,    /* Name resolving is in progress. */
    SERVER_NAME_RESOLVED,     /* We resolved the host name but didn't try to connect. */
    SERVER_WORKING,           /* We successfully connected to the server. */
    SERVER_NOT_WORKING        /* We tried and failed to connect to the server. */
};

struct fo_ctx;
struct fo_service;
struct fo_server;

/*
 * Failover settings.
 *
 * The 'retry_timeout' member specifies the
 * duration in seconds of how long a server or port will be considered
 * non-working after being marked as such.
 *
 * The 'service_resolv_timeout' member specifies how long we wait for
 * service resolution. When this timeout is reached, the resolve request
 * is cancelled with an error
 *
 * The 'srv_retry_timeout' member specifies how long a SRV lookup
 * is considered valid until we ask the server again.
 *
 * The family_order member specifies the order of address families to
 * try when looking up the service.
 */
struct fo_options {
    time_t srv_retry_timeout;
    time_t retry_timeout;
    int service_resolv_timeout;
    enum restrict_family family_order;
};

/*
 * Create a new fail over context based on options passed in the
 * opts parameter
 */
struct fo_ctx *fo_context_init(TALLOC_CTX *mem_ctx,
                               struct fo_options *opts);

typedef int (*datacmp_fn)(void*, void*);

/*
 * Create a new service structure for 'ctx', saving it to the location pointed
 * to by '_service'. The needed memory will be allocated from 'ctx'.
 * Service name will be set to 'name'.
 *
 * Function pointed by user_data_cmp returns 0 if user_data is equal
 * or nonzero value if not. Set to NULL if no user data comparison
 * is needed in fail over duplicate servers detection.
 */
int fo_new_service(struct fo_ctx *ctx,
                   const char *name,
                   datacmp_fn user_data_cmp,
                   struct fo_service **_service);

/*
 * Look up service named 'name' from the 'ctx' service list. Target of
 * '_service' will be set to the service if it was found.
 */
int fo_get_service(struct fo_ctx *ctx,
                   const char *name,