~ubuntu-branches/ubuntu/trusty/isdnutils/trusty

« back to all changes in this revision

Viewing changes to ipppd/environ_bsd.c

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2013-11-15 00:02:58 UTC
  • mfrom: (1.1.8) (31.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131115000258-tt9v3gasgrdml07k
Tags: 1:3.25+dfsg1-3.3ubuntu1
* Merge from Debian unstable:
  - resolves licensing issues with package contents.  LP: #511988.
  - includes proper upstream fix for ipppd on ARM.  LP: #453159.
  - resolves isdnutils-base removal failures.  LP: #813771.
  - fixes capiutils init script to not try to mount obsolete capifs.
    LP: #1064347.
* Remaining changes:
  - Switch libreadline5-dev to libreadline-gplv2-dev since this package
    appears to be GPLv2
  - debian/patches/no-imake.patch: Don't build xisdnload/xmonisdn using
    xmkmf/imake.  This patch was dropped in Debian without explanation;
    it still applies and seems to still be a good idea for eventual
    upstreaming, since imake is quite obsolete.
  - capi.conf: Fix typo for fcdsl2 firmware. LP: #189132.
  - Remove dependencies on /etc/inittab.
    - Disable the installation code to modify /etc/inittab.
    - isdnutils-base: Add ttyI0 example script, which needs to be installed
      in /etc/event.d/ttyI0.
    - isdnvboxserver: Add ttyI1 example script, which needs to be installed
      in /etc/event.d/ttyI1.
    - The two upstart scripts need to be edited.
    - Further improvements and documentation welcome.
* Changes included in Debian:
  - replace calls to ./MAKEDEV with /sbin/MAKEDEV
  - Build-depend on ppp-dev.
  - Switch to newer tcl -dev.
  - update to newer automake
  - debian/rules: use autoreconf to update the autotools in the capi20
    directory
  - debian/{compat,rules,*.files,.dirs}: Convert to Multi-arch.
  - debian/libcapi20-dev.install: Remove .la files (no builds use them).
* Changes included upstream:
  - fix for ARM FTBFS.
  - fix bashisms in vboxplay.
  - debian/patches/{config_libdir,toplevel-make}.patch: add CONFIG_LIBDIR
    override to upstream build system to support Multi-arch.
* Dropped changes:
  - kick dpatch to the curb.
* Handle migrating the blacklist file from
  /etc/modprobe.d/blacklist-capiutils.conf to the path used in Debian,
  /etc/modprobe.d/capiutils.conf.
* Handle rename of /etc/ppp/ip-down.d/99-ipppd and /etc/ppp/ip-up.d/00-ipppd
  to /etc/ppp/ip-down.d/ipppd and /etc/ppp/ip-up.d/ipppd
* Handle rename of /etc/init.d/isdnutils to /etc/init.d/isdnutils-base
* Restore standard.tcl to /usr/share/isdnvboxserver/default; maintainer
  scripts must not depend on contents of /usr/share/doc.
* Apply patches that were preserved in the 3.0 (quilt) migration, but
  were inadvertently not applied:
  - debian/patches/capifax.additional_error_codes.patch
  - debian/patches/capifax.3_1kHz_audio.patch
* Drop debian/isdnutils-base.cron.d, which isn't a cronjob example at all
  but an inittab example gone astray.
* debian/dotconfig*: don't use embedded quotes for paths; this confuses
  vbox's Makefiles something fierce, and causes files to be missed from
  debian/tmp'/usr/share/man/' at install time.
* Fix isdnlog and ipppd to not ship files used in the postinst under
  /usr/share/doc.
* Modernize the upstart examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 *
 
8
 * 1. Redistributions of source code must retain the above copyright
 
9
 *    notice, this list of conditions and the following disclaimer.
 
10
 *
 
11
 * 2. Redistributions in binary form must reproduce the above copyright
 
12
 *    notice, this list of conditions and the following disclaimer in
 
13
 *    the documentation and/or other materials provided with the
 
14
 *    distribution.
 
15
 *
 
16
 * 3. The name "Carnegie Mellon University" must not be used to
 
17
 *    endorse or promote products derived from this software without
 
18
 *    prior written permission. For permission or any legal
 
19
 *    details, please contact
 
20
 *      Office of Technology Transfer
 
21
 *      Carnegie Mellon University
 
22
 *      5000 Forbes Avenue
 
23
 *      Pittsburgh, PA  15213-3890
 
24
 *      (412) 268-4387, fax: (412) 268-7395
 
25
 *      tech-transfer@andrew.cmu.edu
 
26
 *
 
27
 * 4. Redistributions of any form whatsoever must retain the following
 
28
 *    acknowledgment:
 
29
 *    "This product includes software developed by Computing Services
 
30
 *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
 
31
 *
 
32
 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
 
33
 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 
34
 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
 
35
 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
36
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
 
37
 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 
38
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
39
 *
 
40
 * Copyright (c) 1999-2004 Paul Mackerras. All rights reserved.
 
41
 *
 
42
 * Redistribution and use in source and binary forms, with or without
 
43
 * modification, are permitted provided that the following conditions
 
44
 * are met:
 
45
 *
 
46
 * 1. Redistributions of source code must retain the above copyright
 
47
 *    notice, this list of conditions and the following disclaimer.
 
48
 *
 
49
 * 2. The name(s) of the authors of this software must not be used to
 
50
 *    endorse or promote products derived from this software without
 
51
 *    prior written permission.
 
52
 *
 
53
 * 3. Redistributions of any form whatsoever must retain the following
 
54
 *    acknowledgment:
 
55
 *    "This product includes software developed by Paul Mackerras
 
56
 *     <paulus@samba.org>".
 
57
 *
 
58
 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
 
59
 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 
60
 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
 
61
 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
62
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
 
63
 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 
64
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
65
 *
 
66
 * Copyright 2010 Ben Hutchings.
 
67
 *
 
68
 * Redistribution and use in source and binary forms, with or without
 
69
 * modification, are permitted provided that the following conditions
 
70
 * are met:
 
71
 *
 
72
 * 1. Redistributions of source code must retain the above copyright
 
73
 *    notice, this list of conditions and the above disclaimer.
 
74
 *
 
75
 * 2. The name(s) of the authors of this software must not be used to
 
76
 *    endorse or promote products derived from this software without
 
77
 *    prior written permission.
 
78
 */
 
79
 
 
80
#include <stdio.h>
 
81
#include <stdlib.h>
 
82
#include <string.h>
 
83
#include "environ_bsd.h"
 
84
 
 
85
char **script_env;              /* Env. variable values for scripts */
 
86
static int s_env_nalloc;        /* # words avail at script_env */
 
87
 
 
88
/*
 
89
 * script_setenv - set an environment variable value to be used
 
90
 * for scripts that we run (e.g. ip-up, auth-up, etc.)
 
91
 */
 
92
void script_setenv(char *var, char *value)
 
93
{
 
94
    size_t varl = strlen(var);
 
95
    size_t vl = varl + strlen(value) + 2;
 
96
    int i;
 
97
    char *p, *newstring;
 
98
 
 
99
    newstring = (char *) malloc(vl);
 
100
    if (newstring == 0)
 
101
        return;
 
102
    sprintf(newstring, "%s=%s", var, value);
 
103
 
 
104
    /* check if this variable is already set */
 
105
    if (script_env != 0) {
 
106
        for (i = 0; (p = script_env[i]) != 0; ++i) {
 
107
            if (strncmp(p, var, varl) == 0 && p[varl] == '=') {
 
108
                free(p);
 
109
                script_env[i] = newstring;
 
110
                return;
 
111
            }
 
112
        }
 
113
    } else {
 
114
        /* no space allocated for script env. ptrs. yet */
 
115
        i = 0;
 
116
        script_env = (char **) malloc(16 * sizeof(char *));
 
117
        if (script_env == 0)
 
118
            return;
 
119
        s_env_nalloc = 16;
 
120
    }
 
121
 
 
122
    /* reallocate script_env with more space if needed */
 
123
    if (i + 1 >= s_env_nalloc) {
 
124
        int new_n = i + 17;
 
125
        char **newenv = (char **) realloc((void *)script_env,
 
126
                                          new_n * sizeof(char *));
 
127
        if (newenv == 0)
 
128
            return;
 
129
        script_env = newenv;
 
130
        s_env_nalloc = new_n;
 
131
    }
 
132
 
 
133
    script_env[i] = newstring;
 
134
    script_env[i+1] = 0;
 
135
}
 
136
 
 
137
/*
 
138
 * script_unsetenv - remove a variable from the environment
 
139
 * for scripts.
 
140
 */
 
141
void script_unsetenv(char *var)
 
142
{
 
143
    int vl = strlen(var);
 
144
    int i;
 
145
    char *p;
 
146
 
 
147
    if (script_env == 0)
 
148
        return;
 
149
    for (i = 0; (p = script_env[i]) != 0; ++i) {
 
150
        if (strncmp(p, var, vl) == 0 && p[vl] == '=') {
 
151
            free(p);
 
152
            while ((script_env[i] = script_env[i+1]) != 0)
 
153
                ++i;
 
154
            break;
 
155
        }
 
156
    }
 
157
}
 
158
 
 
159
/*
 
160
 * script_unsetenv_prefix - remove variables from the environment
 
161
 * for scripts.
 
162
 */
 
163
void script_unsetenv_prefix(char *prefix)
 
164
{
 
165
    int vl = strlen(prefix);
 
166
    int i, j;
 
167
    char *p;
 
168
 
 
169
    if (script_env == 0)
 
170
        return;
 
171
    j = 0;
 
172
    for (i = 0; (p = script_env[i]) != 0; ++i) {
 
173
        if (strncmp(p, prefix, vl) == 0)
 
174
            free(p);
 
175
        else
 
176
            script_env[j++] = script_env[i];
 
177
    }
 
178
    script_env[j] = 0;
 
179
}