Codebase list openfortivpn / 2dc47c6
New upstream version 1.8.1 Daniel Echeverry 5 years ago
9 changed file(s) with 302 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
33 Legend
44 ------
55
6 * [+] new feature, improvement
6 * [+] new feature or improvement
77 * [-] bug fix
88 * [~] change in behavior
99
1010 Releases
1111 --------
12
13 This high level changelog is usually updated when a release is tagged.
14 On the master branch there may be changes that are not (yet) described here.
15
16 ### 1.8.1
17
18 * [~] Support longer passowrds by allocation of a larger buffer
19 * [-] With version 1.8.0 /etc/resolv.conf was not updated anymore in some situations.
20 To avoid this regression the change "Rationalize DNS options" has been reverted again
21 to restore the behavior of versions up to 1.7.1.
22 * [-] Correctly use realm together with two factor authentication
23 * [~] If no port is specified use standard https port similar as vendor client
24 * [-] Fix value of Accept-Encoding request header
25 * [-] Bugfix in url_encode for non alphanumerical characters
26 * [-] HTML URL Encoding with uppercase characters
27 * [-] Honor Cipher-list option
28 * [~] Improved detection of pppd/ppp client during configure stage
1229
1330 ### 1.8.0
1431
1633 * [~] On Mac OSX and FreeBSD moved netstat parsing output to higher debug level
1734 * [~] When logging traffic also show http traffic (not only tunneled traffic)
1835 * [~] Improve error message in case of login failure
19 * [~] Require root privileges for running. They are needed at various places.
20 Previously, just a warning was issued, but in later stage things have failed.
36 * [~] Require root privileges for running. They are needed at various places.
37 Previously, just a warning was issued, but in later stage things have failed.
2138 * [-] On Mac OSX the protection of the route to the vpn gateway may have failed
2239 * [~] Invert order of ssl libraries (this may help linking on some platforms)
2340 * [+] Add FreeBSD support and redesigned the autoconf mechanism
2744 * [+] Support systemd notification upon tunnel up
2845 * [+] Support building in a separate directory
2946 * [~] Change the way to read passwords such that backspace etc. should work as usual
30 * [~] Rationalize DNS options: pppd and openfortivpn were updating /etc/resolv.conf.
31 Check man page and help output for the documentation of the current behavior.
32
33 ### Earlier Versions
34
35 Please see Github [commit history](https://github.com/adrienverge/openfortivpn/commits)
47 * [~] Rationalize DNS options: pppd and openfortivpn were updating /etc/resolv.conf.
48 Check man page and help output for the documentation of the current behavior.
49
50 ### 1.7.1
51
52 * [~] Be more tolerant about white space in config file
53 * [~] Make better usage of pkg-config
54 * [~] Rework linking against OpenSSL
55 * [-] Build again on Mac OSX where pthread_mutexattr_setrobust is not available
56
57 ### 1.7.0
58
59 * [~] Correctly set up route to vpn gateway (add support for some particular situations)
60 * [+] Support two factor authentication with config file (for NM-plugin)
61 * [~] Change the ip address in the pppd call parameters by a rfc3330 test-net address
62 * [-] Correctly report the exit status codes of pppd
63 * [+] Add --pppd-call option
64 * [~] Use X509_check_host instead of explicit CN match
65 * [+] Add --persistent option
66 * [~] Improve autoconf (check for pkg-conf before using, improve error messages, etc.)
67
68 ### 1.6.0
69
70 * [-] Fix possible buffer overflow in in long requests
71 * [~] Code improvements in terms of header inclusion and some other coverity warnings
72 * [+] Add proxy support
73 * [~] Use the compiled-in fixed full path to pppd
74 * [+] Support pppd ifname option
75 * [+] Print a clear error message at runtime if pppd does not exist
76 * [+] Print clear text error messages of pppd upon failure
77 * [~] Existing config file is not overwritten anymore at installation time
78 * [~] Increase the accepted cookie size and align the error behavior according to RFCs
79 * [-] More gracefully handle unexcpected content of resolv.conf
80 * [~] Dynamically allocate memory for split routes and thus support larger numbers of routes
81
82 ### 1.5.0
83
84 * [~] Improve error handling around the call of pppd
85 * [+] Add half-internet-routes option
86 * [-] realm was not recognized in the config file
87 * [~] Switch from no-routes and no-dns to set-routes and set-dns option
88 * [+] Add pppd-no-peerdns and pppd-log option
89 * [~] Allow passing the otp via the config file for use with NetworkManager plugin
90 * [-] Fix issues initializing memory and with build system
91 * [+] Support building against Openssl 1.1
92 * [~] use pkg-config for configuration of openssl instead of configure option
93 * [-] Fix string handling of the command line arguments
94
95 ### 1.4.0
96
97 * [+] Allow to specify openssl location via configure option
98 * [+] Introduce autotools build script autogen.sh
99 * [~] Further increase possible number of split routes
100 * [-] Fix locking issues on Mac OS X
101 * [~] Rework signal handling: Handle SIGTERM as SIGINT and ignore SIGHUP
102
103 ### 1.3.1
104
105 * [~] When calling pppd allow passing an ipparam for use in pppd ip-up/down scripts
106 * [-] Command line option -o was not recognized before
107 * [~] Improve Mac OSX support and parse netstat output to obtain routing information
108 * [-] Fix segmentation fault when a gateway route is added on Mac OSX
109 * [-] Fix buffer overflow for name server entries
110 * [~] Increase possible number of split routes
111 * [-] Do not remove route to vpn gateway if it has existed before connecting
112 * [~] Load OS trusted certificate stores
113 * [~} When setting up routes protect the route to the vpn gateway
114 * [-] Add gateway flag to routes that may not be reachable directly at the tunnel end
115 * [-] Correctly detect if pushed routes have a gateway
116 * [-] Correctly mark the route to the vpn gateway as a host route
117 * [-] Clean up routing table upon termination
118
119 ### 1.3.0
120
121 * [+] Support vpn connections over an already existing ppp connection
122 * [-] Fix for diagnostic message colors invisible on light background
123 * [-] Bugfix for building with clang
124 * [+] Add token-based one-time password support
125 * [+] Add Mac OSX support
126 * [+] Support logging via syslog
127 * [-] Honor sysconfdir during runtime, i.e. when loading default configuration
128 * [~] Disable insecure openssl default protocols/ciphers
129
130 ### 1.2.0
131
132 * [+] Support login with client certificate, key, and ca-file specified in config file
133 * [~] Use more meaningful error codes when loading config fails
134 * [-] Correctly report errors of hostname lookup
135 * [+] Add an option not to ask ppp peer for dns servers
136 * [-] Fix array bounds error for trusted cert string
137 * [-] Fix compiler warning about type cast around getchar
138 * [-] Properly initialize memory for tunnel structure to avoid undeterministic behavior
139 * [-] Properly initialize pointer in auth_log_in to avoid crash on http_request
140 * [-] Fix buffer overflow in parse_config
141
142 ### 1.1.4
143
144 * [-] Fix new GCC 6 strict-aliasing errors
145 * [-] For split routes use interface if no gateway address is assigned in received route
146 * [-] Fix rewrite of resolv.conf with non null-terminated buffer
147 * [~] Perform two factor authentication also with zero-length tokeninfo
148
149 ### 1.1.3
150
151 * [~] Support set-dns and set-routes flag from config file as well
152 * [-] Properly URL-encode values sent in http requests
153 * [+] Add support for realm authentication
154 * [+] Add support for two factor authentication
155
156 ### 1.1.2
157
158 * [-] Fix incompatible-pointer-types compiler error for x86 architectures
159 * [~] Increase COOKIE_SIZE (again)
160
161 ### 1.1.1
162
163 * [~] Update of Makefile to treat all warnings as errors
164 * [~] Increase COOKIE_SIZE to 240 as the SVPNCOOKIE is longer in newer FortiOS versions
165
166 ### 1.1.0
167
168 * [~] Rename --plugin to --pppd-plugin for consistency with other pppd-related options
169 * [-] NUL terminate the config buffer
170 * [-] Fix an off-by-one error when reading a quad-dotted attribute from xml
171 * [+] Add support for client keys and certificates
172 * [~] Extend the split VPN support with older FortiOS servers
173 * [+] Add a config parser to handle received non-xml content
174 * [~] Allow ommitting the gateway for split routes
175 * [~] Allow ommitting DNS servers
176 * [-] Fix a memory leak in auth_get_config
177 * [+] Support split routes
178 * [+] Export the configuration of routes and gateway to environment
179 * [~] Several improvements around establishing the tunnel connection and http traffic
180 * [+] Allow using a custom CA
181 * [-] Turn on SSL verification, check the hostname at least for the CN
182 * [+] Add --plugin option
183 * [-] Fix a format string warning in do_log_packet
184 * [~] Improved debugging output
185 * [~] Restore default route
186
187 ### 1.0.1
188
189 * [~] Better error messages in /etc/resolv.conf helpers
190 * [~] Use better colors for warnings and error messages and only if output is a tty
191 * [-] Fix parsing of "trusted-cert" in config file
192 * [~] Add --pedantic to CFLAGS
193 * [+] Add ability to type password interactively
194 * [+] Verify gateway's X509 certificate
195 * [-] Don't delete nameservers at tear down if they were here before
196 * [~] Set /etc/openfortivpn/config not readable by other users
197 * [+] Add ability to use a config file
198
199 ### 1.0.0
200
201 * Start tracking openfortivpn - in this version with the following features:
202 ```
203 Usage: openfortivpn <host>:<port> -u <user> -p <pass>
204 [--no-routes] [--no-dns] [--pppd-log=<filename>]
205 [-v|-q]
206 openfortivpn --help
207 openfortivpn --version
208 ```
209
210 ### Details of the changes
211
212 This is a high level changelog meant to provide a rough overview about the version history of openfortivpn. Please see the Github [commit history](https://github.com/adrienverge/openfortivpn/commits) for more details of the individual changes listed here, and for a complete list of the internal code changes.
36213
37214 More Information
38215 ----------------
39216
40 * For a list of knwon issues please check the
217 * For a list of known issues please check the
41218 [issues list](https://github.com/adrienverge/openfortivpn/issues) on GitHub.
219
42220 * We try to avoid backwards incompatible changes, but sometimes it is not
43221 avoidable. When we are aware of compatibility issues, then we recommend to
44222 check the documentation in the above changelog. When changes turn out to break
2323
2424 * Don't set IP routes and don't add VPN nameservers to `/etc/resolv.conf`:
2525 ```
26 openfortivpn vpn-gateway:8443 -u foo -p bar --no-routes --no-dns
26 openfortivpn vpn-gateway:8443 -u foo -p bar --no-routes --no-dns --pppd-no-peerdns
2727 ```
2828 * Using a config file:
2929 ```
3838 password = bar
3939 set-routes = 0
4040 set-dns = 0
41 pppd-use-peerdns = 0
4142 # X509 certificate sha256 sum, trust only this one!
4243 trusted-cert = e46d4aff08ba6914e64daa85bc6112a422fa7ce16631bff0b592a28556f993db
4344 ```
5051 ### Installing existing packages
5152
5253 Some Linux distibutions provide `openfortivpn` packages:
53 * [Fedora](https://admin.fedoraproject.org/pkgdb/package/rpms/openfortivpn/)
54 * [Fedora](https://apps.fedoraproject.org/packages/openfortivpn)
5455 * [openSUSE / SLE](https://software.opensuse.org/package/openfortivpn)
5556 * [Gentoo](https://packages.gentoo.org/packages/net-vpn/openfortivpn)
5657 * [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/tools/networking/openfortivpn)
8384
8485 1. Install build dependencies.
8586
86 * RHEL/CentOS/Fedora: `gcc` `automake` `autoconf` `openssl-devel` `pkg-config`
87 * RHEL/CentOS/Fedora: `gcc` `automake` `autoconf` `openssl-devel` `make` `pkg-config`
8788 * Debian/Ubuntu: `gcc` `automake` `autoconf` `libssl-dev` `make` `pkg-config`
8889 * Arch Linux: `gcc` `automake` `autoconf` `openssl` `pkg-config`
8990 * Gentoo Linux: `net-dialup/ppp` `pkg-config`
122123 If you need to specify the openssl location you can set the
123124 `$PKG_CONFIG_PATH` environment variable.
124125
126 Finally, install runtime dependency `ppp` or `pppd`.
125127
126128 ----------------
127129 Running as root?
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ([2.63])
4 AC_INIT([openfortivpn], [1.8.0])
4 AC_INIT([openfortivpn], [1.8.1])
55 AC_CONFIG_SRCDIR([src/main.c])
66 AM_INIT_AUTOMAKE([foreign subdir-objects])
77
8888 AC_FUNC_MALLOC
8989 AC_FUNC_REALLOC
9090 AC_CHECK_FUNCS([ \
91 access \
9192 atoi \
9293 close \
9394 connect \
9798 fclose \
9899 fcntl \
99100 fflush \
101 fileno \
100102 fopen \
101103 forkpty \
102104 fprintf \
105 fputc \
103106 fputs \
107 fread \
104108 free \
105109 freeaddrinfo \
106110 freeifaddrs \
107111 freopen \
108112 fwrite \
113 gai_strerror \
109114 getaddrinfo \
110115 getchar \
111116 getenv \
117 geteuid \
118 getifaddrs \
112119 getopt_long \
113120 htons \
114121 index \
115122 inet_addr \
116123 inet_ntoa \
124 ioctl \
117125 isatty \
118126 isdigit \
119127 isspace \
120128 malloc \
129 memcmp \
121130 memcpy \
122131 memmem \
123132 memmove \
125134 ntohs \
126135 open \
127136 openlog \
137 optarg \
138 optind \
128139 pclose \
129140 popen \
130141 printf \
132143 pthread_cond_init \
133144 pthread_cond_signal \
134145 pthread_cond_wait \
146 pthread_create \
135147 pthread_join \
136148 pthread_mutexattr_init \
137149 pthread_mutex_destroy \
138150 pthread_mutex_init \
139151 pthread_mutex_lock \
140152 pthread_mutex_unlock \
153 pthread_self \
141154 pthread_sigmask \
155 putchar \
142156 puts \
143157 read \
144158 realloc \
145159 rewind \
146160 select \
161 sem_destroy \
162 sem_init \
163 sem_post \
164 sem_wait \
147165 setenv \
166 setsockopt \
148167 sigaddset \
149168 sigemptyset \
150169 signal \
170 sleep \
151171 snprintf \
152172 socket \
153173 sprintf \
174 sscanf \
175 strcasecmp \
154176 strcasestr \
155177 strcat \
156178 strchr \
161183 strlen \
162184 strncasecmp \
163185 strncat \
186 strncmp \
164187 strncpy \
165188 strsignal \
166189 strstr \
169192 strtol \
170193 syslog \
171194 system \
195 tcgetattr \
172196 tcsetattr \
173197 usleep \
174198 vprintf \
175199 vsnprintf \
176200 vsyslog \
201 waitpid \
177202 write \
178203 ], [], AC_MSG_ERROR([Required function not found]))
179204
260285 ])
261286 ])
262287
263 AC_CHECK_FILE(/usr/sbin/ppp,[
288 # check for ppp user space client
289 AC_PATH_PROG(PPP, [ppp], [/usr/sbin/ppp], "$PATH:/sbin:/usr/sbin")
290 AC_CHECK_FILE([$PPP], [
264291 AS_IF([test "x$PPP_PATH" = "x" ], [
265 PPP_PATH="/usr/sbin/ppp"
292 PPP_PATH="$PPP"
266293 ])
267294 AS_IF([test "x$with_ppp" = "x" ], [
268295 with_ppp="yes"
269296 ])
270297 ],[])
271 AC_CHECK_FILE(/usr/sbin/pppd,[
298
299 # check for pppd
300 AC_PATH_PROG(PPPD, [pppd], [/usr/sbin/pppd], "$PATH:/sbin:/usr/sbin")
301 AC_CHECK_FILE([$PPPD], [
272302 AS_IF([test "x$PPP_PATH" = "x" ], [
273 PPP_PATH="/usr/sbin/pppd"
303 PPP_PATH="$PPPD"
274304 ])
275305 AS_IF([test "x$with_pppd" = "x" ], [
276306 with_pppd="yes"
277307 ])
278308 ],[])
279309
310 # replace empty settings with "no"
311 AS_IF([test "x$with_ppp" = "x" ], [
312 with_ppp="no"
313 ])
314 AS_IF([test "x$with_pppd" = "x" ], [
315 with_pppd="no"
316 ])
280317
281318 # when neither ppp nor pppd are enabled, assume the previous behavior (for travis)
282319 AS_IF([test "x$with_ppp" = "xno" -a "x$with_pppd" = "xno" ], [
283 with_pppd="yes"
284 ])
285 AS_IF([test "x$with_ppp" = "x" -a "x$with_pppd" = "x" ], [
286 with_pppd="yes"
320 AS_IF([test "x$uname" = "xFreeBSD" ], [
321 PPP_PATH="/usr/sbin/ppp"
322 with_ppp="yes"
323 ], [
324 with_pppd="yes"
325 PPP_PATH="/usr/sbin/pppd"
326 ])
287327 ])
288328
289329 # when both are enabled, give pppd the higher priority (we can only use one of them)
118118 (default: HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4)
119119 .TP
120120 \fB\-\-pppd-no-peerdns\fR
121 Deprecated; do not ask peer ppp server for DNS server addresses and do not make
122 pppd rewrite /etc/resolv.conf.
121 Do not ask peer ppp server for DNS server addresses and do not make pppd
122 rewrite /etc/resolv.conf.
123123 .TP
124124 \fB\-\-pppd-log=\fI<file>\fR
125125 Set pppd in debug mode and save its logs into \fI<file>\fR.
235235 .br
236236 half-internet-routes = 0
237237 .br
238 pppd-use-peerdns = 1
239 .br
238240 # alternatively, use a specific pppd plugin instead
239241 .br
240242 # pppd-plugin = /usr/lib/pppd/default/some-plugin.so
2929 .gateway_host = {'\0'},
3030 .gateway_port = 0,
3131 .username = {'\0'},
32 .password = {'\0'},
32 .password = NULL,
3333 .otp = {'\0'},
3434 .realm = {'\0'},
3535 .set_routes = -1,
200200 strncpy(cfg->username, val, FIELD_SIZE - 1);
201201 cfg->username[FIELD_SIZE] = '\0';
202202 } else if (strcmp(key, "password") == 0) {
203 strncpy(cfg->password, val, FIELD_SIZE - 1);
204 cfg->password[FIELD_SIZE] = '\0';
203 cfg->password = strdup(val);
205204 } else if (strcmp(key, "otp") == 0) {
206205 strncpy(cfg->otp, val, FIELD_SIZE - 1);
207206 cfg->otp[FIELD_SIZE] = '\0';
329328
330329 void destroy_vpn_config(struct vpn_config *cfg)
331330 {
331 free(cfg->password);
332332 #if HAVE_USR_SBIN_PPPD
333333 free(cfg->pppd_log);
334334 free(cfg->pppd_plugin);
358358 dst->gateway_port = src->gateway_port;
359359 if (src->username[0])
360360 strcpy(dst->username, src->username);
361 if (src->password[0])
362 strcpy(dst->password, src->password);
361 if (src->password != NULL && src->password[0])
362 dst->password = strdup(src->password);
363363 if (src->otp[0])
364364 strcpy(dst->otp, src->otp);
365365 if (src->realm[0])
6363 struct in_addr gateway_ip;
6464 uint16_t gateway_port;
6565 char username[FIELD_SIZE + 1];
66 char password[FIELD_SIZE + 1];
66 char *password;
6767 char otp[FIELD_SIZE + 1];
6868 char realm[FIELD_SIZE + 1];
6969
4646 else if (*str == ' ')
4747 *dest++ = '+';
4848 else {
49 static const char hex[] = "0123456789abcdef";
49 static const char hex[] = "0123456789ABCDEF";
5050
5151 *dest++ = '%';
52 *dest++ = hex[*str >> 4];
53 *dest++ = hex[*str & 15];
52 *dest++ = hex[(unsigned char)*str >> 4];
53 *dest++ = hex[(unsigned char)*str & 15];
5454 }
5555 str++;
5656 }
8080 else if (length >= BUFSZ)
8181 return ERR_HTTP_TOO_LONG;
8282
83 log_debug_details("http_send : \n%s\n", buffer);
83 log_debug_details("%s: \n%s\n", __func__, buffer);
8484
8585 while (n == 0)
8686 n = safe_ssl_write(tunnel->ssl_handle, (uint8_t *) buffer,
148148 (uint8_t *) buffer + bytes_read,
149149 BUFSZ - 1 - bytes_read);
150150 if (n > 0) {
151 log_debug_details("http_receive : \n%s\n", buffer);
151 log_debug_details("%s: \n%s\n", __func__, buffer);
152152 const char *eoh;
153153
154154 bytes_read += n;
243243 "Host: %s:%d\r\n"
244244 "User-Agent: Mozilla/5.0 SV1\r\n"
245245 "Accept: text/plain\r\n"
246 "Accept-Encoding: identify\r\n"
246 "Accept-Encoding: identity\r\n"
247247 "Content-Type: application/x-www-form-urlencoded\r\n"
248248 "Cookie: %s\r\n"
249249 "Content-Length: %d\r\n"
499499 return -1;
500500 url_encode(d, cfg->otp);
501501 d += strlen(d);
502 /* realm workaround */
503 if (cfg->realm[0] != '\0') {
504 l = strlen(cfg->realm);
505 if (!SPACE_AVAILABLE(3 * l + 8))
506 return -1;
507 strcat(d, "&realm=");
508 d += strlen(d);
509 url_encode(d, cfg->realm);
510 d += strlen(d);
511 }
502512 } else if (strncmp(t, "submit", 6) == 0) {
503513 /* avoid adding another '&' */
504514 n = v = e = NULL;
2626 #include <string.h>
2727 #include <limits.h>
2828
29 #define PWD_BUFSIZ 4096
30
31
2932 #if HAVE_USR_SBIN_PPPD
3033 #define PPPD_USAGE \
3134 " [--pppd-no-peerdns] [--pppd-log=<file>]\n" \
3336 " [--pppd-call=<name>] [--pppd-plugin=<file>]\n"
3437
3538 #define PPPD_HELP \
36 " --pppd-no-peerdns Deprecated; do not ask peer ppp server for DNS server\n" \
37 " addresses and do not make pppd rewrite /etc/resolv.conf\n" \
39 " --pppd-no-peerdns Do not ask peer ppp server for DNS server addresses\n" \
40 " and do not make pppd rewrite /etc/resolv.conf\n" \
3841 " --pppd-log=<file> Set pppd in debug mode and save its logs into\n" \
3942 " <file>.\n" \
4043 " --pppd-plugin=<file> Use specified pppd plugin instead of configuring\n" \
5558 #endif
5659
5760 #define usage \
58 "Usage: openfortivpn [<host>:<port>] [-u <user>] [-p <pass>]\n" \
61 "Usage: openfortivpn [<host>[:<port>]] [-u <user>] [-p <pass>]\n" \
5962 " [--realm=<realm>] [--otp=<otp>] [--set-routes=<0|1>]\n" \
6063 " [--half-internet-routes=<0|1>] [--set-dns=<0|1>]\n" \
6164 PPPD_USAGE \
147150 const char *config_file = SYSCONFDIR"/openfortivpn/config";
148151 const char *host;
149152 char *port_str;
150 long int port;
151153
152154 struct vpn_config cfg = {
153155 .gateway_host = {'\0'},
154 .gateway_port = 0,
156 .gateway_port = 443,
155157 .username = {'\0'},
156 .password = {'\0'},
158 .password = NULL,
157159 .otp = {'\0'},
158160 .realm = {'\0'},
159161 .set_routes = 1,
376378 cli_cfg.username[FIELD_SIZE] = '\0';
377379 break;
378380 case 'p':
379 strncpy(cli_cfg.password, optarg, FIELD_SIZE);
380 cli_cfg.password[FIELD_SIZE] = '\0';
381 cli_cfg.password = strdup(optarg);
381382 break;
382383 case 'o':
383384 strncpy(cli_cfg.otp, optarg, FIELD_SIZE);
391392 if (optind < argc - 1 || optind > argc)
392393 goto user_error;
393394
394 if (cli_cfg.password[0] != '\0')
395 if (cli_cfg.password != NULL && cli_cfg.password[0] != '\0')
395396 log_warn("You should not pass the password on the command line. Type it interactively or use a config file instead.\n");
396397
397398 log_debug("openfortivpn " VERSION "\n", config_file);
413414 if (optind == argc - 1) {
414415 host = argv[optind++];
415416 port_str = strchr(host, ':');
416 if (port_str == NULL) {
417 log_error("Specify a valid host:port couple.\n");
418 goto user_error;
417 if (port_str != NULL) {
418 port_str[0] = '\0';
419 port_str++;
420 cfg.gateway_port = strtol(port_str, NULL, 0);
421 if (cfg.gateway_port <= 0 || cfg.gateway_port > 65535) {
422 log_error("Specify a valid port.\n");
423 goto user_error;
424 }
419425 }
420 port_str[0] = '\0';
421426 strncpy(cfg.gateway_host, host, FIELD_SIZE);
422427 cfg.gateway_host[FIELD_SIZE] = '\0';
423 port_str++;
424 port = strtol(port_str, NULL, 0);
425 if (port <= 0 || port > 65535) {
426 log_error("Specify a valid port.\n");
427 goto user_error;
428 }
429 cfg.gateway_port = port;
430428 }
431429
432430 // Check host and port
440438 goto user_error;
441439 }
442440 // If no password given, interactively ask user
443 if (cfg.password[0] == '\0')
444 read_password("VPN account password: ", cfg.password,
445 FIELD_SIZE);
441 if (cfg.password == NULL || cfg.password[0] == '\0') {
442 free(cfg.password);
443 char *tmp_password = malloc(PWD_BUFSIZ); // allocate large buffer
444 read_password("VPN account password: ", tmp_password, PWD_BUFSIZ);
445 cfg.password = strdup(tmp_password); // copy string of correct size
446 free(tmp_password);
447 }
446448 // Check password
447449 if (cfg.password[0] == '\0') {
448450 log_error("Specify a password.\n");
9797 }
9898 }
9999
100 if (tunnel->config->set_dns && !tunnel->config->pppd_use_peerdns) {
100 if (tunnel->config->set_dns) {
101101 log_info("Adding VPN nameservers...\n");
102102 ipv4_add_nameservers_to_resolv_conf(tunnel);
103103 }
120120 ipv4_restore_routes(tunnel);
121121 }
122122
123 if (tunnel->config->set_dns && !tunnel->config->pppd_use_peerdns) {
123 if (tunnel->config->set_dns) {
124124 log_info("Removing VPN nameservers...\n");
125125 ipv4_del_nameservers_from_resolv_conf(tunnel);
126126 }
198198 for (unsigned i = 0; i < ARRAY_SIZE(v); i++)
199199 ofv_append_varr(&pppd_args, v[i]);
200200 }
201 if (tunnel->config->set_dns && tunnel->config->pppd_use_peerdns)
201 if (tunnel->config->pppd_use_peerdns)
202202 ofv_append_varr(&pppd_args, "usepeerdns");
203203 if (tunnel->config->pppd_log) {
204204 ofv_append_varr(&pppd_args, "debug");
787787 if (!tunnel->config->insecure_ssl && !tunnel->config->cipher_list) {
788788 const char *cipher_list = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4";
789789
790 if (tunnel->config->cipher_list)
791 cipher_list = tunnel->config->cipher_list;
792 if (!SSL_set_cipher_list(tunnel->ssl_handle, cipher_list)) {
790 tunnel->config->cipher_list = strdup(cipher_list);
791 }
792
793 if (tunnel->config->cipher_list) {
794 if (!SSL_set_cipher_list(tunnel->ssl_handle,
795 tunnel->config->cipher_list)) {
793796 log_error("SSL_set_cipher_list failed: %s\n",
794797 ERR_error_string(ERR_peek_last_error(), NULL));
795798 return 1;