Codebase list netcfg / 9e8321e
Merge branch 'debian' into kali/master Raphaƫl Hertzog 8 years ago
5 changed file(s) with 92 addition(s) and 117 deletion(s). Raw diff Collapse all Expand all
0 netcfg (1.137) unstable; urgency=medium
1
2 [ Colin Watson ]
3 * Use HTTPS for Vcs-* URLs, and link to cgit rather than gitweb.
4
5 -- Christian Perrier <[email protected]> Tue, 02 Feb 2016 07:02:48 +0100
6
7 netcfg (1.136) unstable; urgency=medium
8
9 * Fix confusing indentation pointed out by GCC 6 (closes: #811589).
10
11 -- Colin Watson <[email protected]> Wed, 20 Jan 2016 13:43:39 +0000
12
013 netcfg (1.135+kali1) kali-dev; urgency=medium
114
215 * Import new version from Debian.
55 Christian Perrier <[email protected]>,
66 Philipp Kern <[email protected]>
77 Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.9.0), libdebconfclient0-dev (>= 0.46), libdebian-installer4-dev (>= 0.41), po-debconf (>= 0.5.0), libiw-dev (>= 27+28pre9) [!s390 !s390x !sparc !kfreebsd-any !hurd-any], check, libsubunit-dev
8 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=d-i/netcfg.git
9 Vcs-Git: git://anonscm.debian.org/d-i/netcfg.git
8 Vcs-Browser: https://anonscm.debian.org/cgit/d-i/netcfg.git
9 Vcs-Git: https://anonscm.debian.org/git/d-i/netcfg.git
1010
1111 Package: netcfg
1212 Package-Type: udeb
0 #include <arpa/inet.h>
1 #include <ctype.h>
2 #include <errno.h>
3 #include <netinet/in.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <sys/socket.h>
7 #include <sys/stat.h>
8
9 #ifdef WIRELESS
10 #include <iwlib.h>
11 #endif
12
13 #include <debian-installer.h>
014
115 #include "nm-conf.h"
2 #include <sys/stat.h>
3 #include <errno.h>
416
517 /* Linux provides a lightweight facility that can generate UUIDs for us. */
618 static void get_uuid(char* target)
1729
1830 /* Functions for printing informations in Network Manager format. */
1931
20 void nm_write_connection(FILE *config_file, nm_connection connection)
32 static void nm_write_connection(FILE *config_file, nm_connection connection)
2133 {
2234 fprintf(config_file, "\n%s\n", NM_SETTINGS_CONNECTION);
2335 fprintf(config_file, "id=%s\n", connection.id);
2739 }
2840
2941 #ifdef WIRELESS
30 void nm_write_wireless_specific_options(FILE *config_file,
42 static void nm_write_wireless_specific_options(FILE *config_file,
3143 struct nm_config_info *nmconf)
3244 {
3345 nm_wireless wireless = nmconf->wireless;
4658 }
4759 #endif
4860
49 void nm_write_wired_specific_options(FILE *config_file,
61 static void nm_write_wired_specific_options(FILE *config_file,
5062 struct nm_config_info *nmconf)
5163 {
5264 nm_wired wired = nmconf->wired;
5971 }
6072
6173 #ifdef WIRELESS
62 void nm_write_wireless_security(FILE *config_file, nm_wireless_security
74 static void nm_write_wireless_security(FILE *config_file, nm_wireless_security
6375 wireless_security)
6476 {
6577 fprintf(config_file, "\n%s\n", NM_SETTINGS_WIRELESS_SECURITY);
7991 }
8092 #endif
8193
82 void nm_write_static_ipvX(FILE *config_file, nm_ipvX ipvx)
94 static void nm_write_static_ipvX(FILE *config_file, nm_ipvX ipvx)
8395 {
8496 char buffer[NM_MAX_LEN_BUF], addr[NM_MAX_LEN_IPV4];
8597 int i;
124136 fprintf(config_file, "addresses1=%s\n", buffer);
125137 }
126138
127 void nm_write_ipv4(FILE *config_file, nm_ipvX ipv4)
139 static void nm_write_ipv4(FILE *config_file, nm_ipvX ipv4)
128140 {
129141 fprintf(config_file, "\n%s\n", NM_SETTINGS_IPV4);
130142
137149 }
138150 }
139151
140 void nm_write_ipv6(FILE *config_file, nm_ipvX ipv6)
152 static void nm_write_ipv6(FILE *config_file, nm_ipvX ipv6)
141153 {
142154 fprintf(config_file, "\n%s\n", NM_SETTINGS_IPV6);
143155
152164 else if (ipv6.method == IGNORE) {
153165 fprintf(config_file, "method=%s\n", "ignore");
154166 }
167 }
168
169 /* Write info about how the network was configured to a specific file, in
170 * order to be used in the finish install script. */
171 static void nm_write_connection_type(struct nm_config_info nmconf)
172 {
173 FILE *f = fopen(NM_CONNECTION_FILE, "w");
174
175 if (nmconf.connection.type == WIFI) {
176 fprintf(f, "connection type: wireless\n");
177 }
178 else {
179 fprintf(f, "connection type: wired\n");
180 }
181
182 if (nmconf.connection.type == WIFI && nmconf.wireless.is_secured) {
183 fprintf(f, "security: secured\n");
184 }
185 else {
186 fprintf(f, "security: unsecured\n");
187 }
188
189 fclose(f);
155190 }
156191
157192 /* Write Network Manager config file. */
210245 nm_write_connection_type(nmconf);
211246 }
212247
213 /* Write info about how the network was configured to a specific file, in
214 * order to be used in the finish install script. */
215 void nm_write_connection_type(struct nm_config_info nmconf)
216 {
217 FILE *f = fopen(NM_CONNECTION_FILE, "w");
218
219 if (nmconf.connection.type == WIFI) {
220 fprintf(f, "connection type: wireless\n");
221 }
222 else {
223 fprintf(f, "connection type: wired\n");
224 }
225
226 if (nmconf.connection.type == WIFI && nmconf.wireless.is_secured) {
227 fprintf(f, "security: secured\n");
228 }
229 else {
230 fprintf(f, "security: unsecured\n");
231 }
232
233 fclose(f);
234 }
235
236248 /* Functions for extracting information from netcfg variables. */
237249
238250 /* Get info for the connection setting for wireless networks. */
239251
240252 #ifdef WIRELESS
241 void nm_get_wireless_connection(struct netcfg_interface *niface, nm_connection *connection)
253 static void nm_get_wireless_connection(struct netcfg_interface *niface, nm_connection *connection)
242254 {
243255 /* Use the wireless network name for connection id. */
244256 snprintf(connection->id, NM_MAX_LEN_ID, "%s", niface->essid);
251263 #endif
252264
253265 /* Get info for the connection setting for wired networks. */
254 void nm_get_wired_connection(nm_connection *connection)
266 static void nm_get_wired_connection(nm_connection *connection)
255267 {
256268 /* This is the first wired connection. */
257269 snprintf(connection->id, NM_MAX_LEN_ID, NM_DEFAULT_WIRED_NAME);
263275 }
264276
265277 /* Get MAC address from default file. */
266 void nm_get_mac_address(char *interface, char *mac_addr)
278 static void nm_get_mac_address(char *interface, char *mac_addr)
267279 {
268280 char file_name[NM_MAX_LEN_PATH];
269281 FILE *file;
287299 }
288300
289301 #ifdef WIRELESS
290 void nm_get_wireless_specific_options(struct netcfg_interface *niface, nm_wireless *wireless)
302 static void nm_get_wireless_specific_options(struct netcfg_interface *niface, nm_wireless *wireless)
291303 {
292304 strncpy(wireless->ssid, niface->essid, NM_MAX_LEN_SSID);
293305
313325 #endif
314326
315327 /* Only set MAC address, the others have good defaults in NM. */
316 void nm_get_wired_specific_options(struct netcfg_interface *niface, nm_wired *wired)
328 static void nm_get_wired_specific_options(struct netcfg_interface *niface, nm_wired *wired)
317329 {
318330 nm_get_mac_address(niface->name, wired->mac_addr);
319331 }
320332
321333 /* Security type for wireless networks. */
322334 #ifdef WIRELESS
323 void nm_get_wireless_security(struct netcfg_interface *niface, nm_wireless_security *wireless_security)
335 static void nm_get_wireless_security(struct netcfg_interface *niface, nm_wireless_security *wireless_security)
324336 {
325337 if (niface->wifi_security == REPLY_WPA) {
326338 wireless_security->key_mgmt = WPA_PSK;
340352 #endif
341353
342354 /* Save IPv4 settings. */
343 void nm_get_ipv4(struct netcfg_interface *niface, nm_ipvX *ipv4)
355 static void nm_get_ipv4(struct netcfg_interface *niface, nm_ipvX *ipv4)
344356 {
345357 /* DHCP wasn't used and there is no IPv4 address saved => didn't use ipv4
346358 * so won't use it in the future. */
373385 }
374386
375387 /* For the moment, just set it to ignore. */
376 void nm_get_ipv6(struct netcfg_interface *niface, nm_ipvX *ipv6)
388 static void nm_get_ipv6(struct netcfg_interface *niface, nm_ipvX *ipv6)
377389 {
378390 /* No IPv6 address, no dhcpv6, nor slaac, so wasn't used. */
379391 if (niface->address_family != AF_INET6 && niface->dhcpv6 == 0 &&
410422 /* Extract all configs for a wireless interface, from both global netcfg
411423 * values and other resources. */
412424 #ifdef WIRELESS
413 void nm_get_wireless_config(struct netcfg_interface *niface, struct nm_config_info *nmconf)
425 static void nm_get_wireless_config(struct netcfg_interface *niface, struct nm_config_info *nmconf)
414426 {
415427 nm_get_wireless_connection(niface, &(nmconf->connection));
416428 nm_get_wireless_specific_options(niface, &(nmconf->wireless));
425437 #endif
426438
427439 /* Extract all configs for a wired interface. */
428 void nm_get_wired_config(struct netcfg_interface *niface, struct nm_config_info *nmconf)
440 static void nm_get_wired_config(struct netcfg_interface *niface, struct nm_config_info *nmconf)
429441 {
430442 nm_get_wired_connection(&(nmconf->connection));
431443 nm_get_wired_specific_options(niface, &(nmconf->wired));
0
10 #ifndef _NM_CONF_H
21 #define _NM_CONF_H
32
4 #include <stdio.h>
5 #include <string.h>
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <arpa/inet.h>
9 #include <ctype.h>
10 #include <debian-installer.h>
11
12 #ifdef WIRELESS
13 #include <iwlib.h>
14 #endif
15
16 /* Global variables. */
173 #include "netcfg.h"
184
195 /* Constants for maximum size for Network Manager config fields. */
2713 #define NM_MAX_LEN_PATH 128 /* Assume a path won't be longer */
2814 #define NM_MAX_LEN_UUID 37
2915 #define NM_NO_BITS_IPV4 32
30
3116
3217 /* Some Network Manager default values for connection types. */
3318 #define NM_DEFAULT_WIRED "802-3-ethernet"
4429 #define NM_SETTINGS_WIRELESS_SECURITY "["NM_DEFAULT_WIRELESS_SECURITY"]"
4530 #define NM_SETTINGS_IPV4 "[ipv4]"
4631 #define NM_SETTINGS_IPV6 "[ipv6]"
47
4832
4933 /* Minimalist structures for storing basic elements in order to write a Network
5034 * Manager format config file.
11296 nm_ipvX ipv6;
11397 } nm_config_info;
11498
115 /* Here come functions: */
116
117 #ifdef WIRELESS
118 void nm_write_wireless_specific_options(FILE *config_file,
119 struct nm_config_info *nmconf);
120 void nm_write_wireless_security(FILE *config_file, nm_wireless_security
121 wireless_security);
122 #endif
123 void nm_write_connection(FILE *config_file, nm_connection connection);
124 void nm_write_wired_specific_options(FILE *config_file,
125 struct nm_config_info *nmconf);
126 void nm_write_ipv4(FILE *config_file, nm_ipvX ipv4);
127 void nm_write_ipv6(FILE *config_file, nm_ipvX ipv6);
128
99 /* Public functions */
100 void nm_get_configuration(struct netcfg_interface *niface, struct nm_config_info *nmconf);
129101 void nm_write_configuration(struct nm_config_info nmconf);
130102
131 void nm_write_connection_type(struct nm_config_info nmconf);
132
133
134 #ifdef WIRELESS
135 void nm_get_wireless_connection(struct netcfg_interface *niface, nm_connection *connection);
136 void nm_get_wireless_specific_options(struct netcfg_interface *niface, nm_wireless *wireless);
137 void nm_get_wireless_security(struct netcfg_interface *niface, nm_wireless_security *wireless_security);
138103 #endif
139 void nm_get_wired_connection(nm_connection *connection);
140 void nm_get_mac_address(char *interface, char *mac_addr);
141 void nm_get_wired_specific_options(struct netcfg_interface *niface, nm_wired *wired);
142 void nm_get_ipv4(struct netcfg_interface *niface, nm_ipvX *ipv4);
143 void nm_get_ipv6(struct netcfg_interface *niface, nm_ipvX *ipv6);
144
145 #ifdef WIRELESS
146 void nm_get_wireless_config(struct netcfg_interface *niface, struct nm_config_info *nmconf);
147 #endif
148 void nm_get_wired_config(struct netcfg_interface *niface, struct nm_config_info *nmconf);
149
150 void nm_get_configuration(struct netcfg_interface *niface, struct nm_config_info *nmconf);
151
152 #endif
153
+21
-21
wpa.c less more
260260 CMD_PROGRESSCANCELLED)
261261 goto stop;
262262
263 if (debconf_progress_step(client, 1) == CMD_PROGRESSCANCELLED)
263 if (debconf_progress_step(client, 1) == CMD_PROGRESSCANCELLED)
264 goto stop;
265
266 sleep(1);
267
268 if ((seconds_slept <= wpa_timeout) && (seconds_slept % 5) == 0) {
269 if (!wpa_status()) {
270 debconf_progress_set(client, wpa_timeout);
271 debconf_progress_info(client, "netcfg/wpa_success_note");
272 state = 0;
273 sleep(2);
264274 goto stop;
265
266 sleep(1);
267
268 if ((seconds_slept <= wpa_timeout) && (seconds_slept % 5) == 0) {
269 if (!wpa_status()) {
270 debconf_progress_set(client, wpa_timeout);
271 debconf_progress_info(client, "netcfg/wpa_success_note");
272 state = 0;
273 sleep(2);
274 goto stop;
275 }
276275 }
277 if (seconds_slept == wpa_timeout) {
278 debconf_progress_stop(client);
279 debconf_capb(client, "backup");
280 debconf_capb(client, "");
281 debconf_input(client, "critical", "netcfg/wpa_supplicant_failed");
282 debconf_go(client);
283 debconf_capb(client, "backup");
284 return 1;
285 }
276 }
277 if (seconds_slept == wpa_timeout) {
278 debconf_progress_stop(client);
279 debconf_capb(client, "backup");
280 debconf_capb(client, "");
281 debconf_input(client, "critical", "netcfg/wpa_supplicant_failed");
282 debconf_go(client);
283 debconf_capb(client, "backup");
284 return 1;
285 }
286286 }
287287 stop:
288288 debconf_progress_stop(client);