├── .gitignore
├── CHANGELOG.txt
├── Makefile
├── README-OPEVPN-CONF.md
├── README-instructions.md
├── README.md
├── TROUBLESHOOTING.md
├── VERSION
├── authy-openvpn.sln
├── authy-openvpn.vcxproj
├── curl-bundle-ca.crt
├── scripts
├── authy-vpn-add-user
└── post-install
├── src
├── authy_api.c
├── authy_api.h
├── authy_conf.c
├── authy_openvpn.c
├── headers
│ ├── authy_conf.h
│ ├── constants.h
│ ├── custom_types.h
│ ├── logger.h
│ ├── openvpn-plugin.h
│ └── utils.h
├── logger.c
├── utils.c
└── vendor
│ └── jsmn
│ ├── jsmn.c
│ └── jsmn.h
├── test
└── authy-conf-test.c
└── vendor-lib
├── TROUBLESHOOTING.md
└── include
├── Makefile.am
├── Makefile.in
├── README
└── curl
├── Makefile.am
├── Makefile.in
├── curl.h
├── curlbuild.h
├── curlbuild.h.in
├── curlrules.h
├── curlver.h
├── easy.h
├── mprintf.h
├── multi.h
├── stdcheaders.h
├── typecheck-gcc.h
└── types.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Object files
2 | *.o
3 | *.gch
4 | # Libraries
5 | *.lib
6 | *.a
7 |
8 | # Shared objects (inc. Windows DLLs)
9 | *.dll
10 | *.so
11 | *.so.*
12 | *.dylib
13 |
14 | # Executables
15 | *.exe
16 | *.out
17 | *.app
18 |
19 | # Emacs Temps
20 | *~
21 |
22 | # Vim Temps
23 | *.swp
24 |
25 | .DS_Store
26 |
27 | #RPM
28 | BUILD/*
29 | BUILDROOT/*
30 | SRPMS/*
31 |
32 | #DEB
33 | debian/authy-open-vpn*
34 |
35 | debian/authy-open-vpn*
36 |
37 |
--------------------------------------------------------------------------------
/CHANGELOG.txt:
--------------------------------------------------------------------------------
1 | 4.0
2 | - Modify auth to use synchronous auth from OpenVPN
3 | - Allow Auth if client cert name is null.
4 |
5 | 3.0
6 | - Add SMS tokens
7 | - Add Phone calls
8 | - Refactored the whole source code for stability.
9 | - Added proper logging.
10 |
11 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # For Automatic variables see:
2 | # http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
3 |
4 |
5 | # Build Authy OpenVPN plugin module on *nix.
6 |
7 | CC= gcc
8 | LIBNAME= authy-openvpn
9 |
10 | RELEASE_FLAGS= -fPIC -O2 -DNDEBUG
11 | DEBUG_FLAGS= -fPIC -O2 -Wall -DWITH_DEBUG -ggdb -Werror
12 |
13 | CFLAGS= $(RELEASE_FLAGS)
14 |
15 |
16 |
17 | OBJFLAGS= -I./src/headers/ -c
18 | LIBFLAGS= -shared -Wl,-soname
19 | BUILD_DIR= build
20 | SDIR= src
21 |
22 | INSTDIR=/usr/lib/authy
23 |
24 | # This functions will list all the files in a directory an add .o to them
25 | # Wildcard: will list all .c files.
26 | # basename: will remove the .c from the names
27 | # notdir: will remove the directory
28 | # addsuffix: will add the .o
29 | # EG: $(addsuffix .o, $(notdir $(basename $(wildcard $(SDIR)/*.c))))
30 | _OBJS = $(addsuffix .o, $(notdir $(basename $(wildcard $(SDIR)/*.c))))
31 | OBJS = $(patsubst %,$(BUILD_DIR)/%,$(_OBJS))
32 |
33 | _JSMN_OBJS = $(addsuffix .o, $(notdir $(basename $(wildcard $(SDIR)/vendor/jsmn/*.c))))
34 | JSMN_OBJS = $(patsubst %,$(BUILD_DIR)/vendor/%,$(_JSMN_OBJS))
35 |
36 |
37 | all: $(BUILD_DIR)/$(LIBNAME).so
38 |
39 | # Build all our .o
40 | $(BUILD_DIR)/%.o: $(SDIR)/%.c
41 | mkdir -p $(BUILD_DIR)
42 | $(CC) $(CFLAGS) $(OBJFLAGS) -o $@ $<
43 |
44 | #build vendor jsmn module. We need to duplicate the rule above as it's not possible
45 | # to use 2 patterns as pre-requisites in 1 rules.
46 | $(BUILD_DIR)/vendor/%.o: $(SDIR)/vendor/jsmn/%.c
47 | mkdir -p $(BUILD_DIR)/vendor
48 | $(CC) $(CFLAGS) $(OBJFLAGS) -o $@ $<
49 |
50 | # Make Authy shared Lib.
51 | $(BUILD_DIR)/$(LIBNAME).so: $(OBJS) $(JSMN_OBJS)
52 | @# MAC SUPER dylib compile gcc -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,/usr/local/lib/lib$(OBJ).1.dylib -o lib$(OBJ).1.dylib $(OBJ).o
53 | $(CC) $(CFLAGS) $(LIBFLAGS),$(LIBNAME).so -o $@ $^ -lc -lcurl
54 |
55 |
56 | # $(DESTDIR) is used by debian makefiles
57 | install: all
58 | mkdir -p $(DESTDIR)$(INSTDIR)
59 | cp $(BUILD_DIR)/$(LIBNAME).so $(DESTDIR)$(INSTDIR)
60 | chmod 755 $(DESTDIR)$(INSTDIR)/*.so
61 | mkdir -p $(DESTDIR)/usr/sbin
62 | cp scripts/authy-vpn-add-user $(DESTDIR)/usr/sbin/authy-vpn-add-user
63 | chmod 700 $(DESTDIR)/usr/sbin/authy-vpn-add-user
64 |
65 |
66 | # Debug build with debug symbols
67 | debug: CFLAGS = $(DEBUG_FLAGS)
68 | debug: clean
69 | debug: all
70 |
71 |
72 | clean:
73 | rm -rf $(BUILD_DIR)
74 |
75 |
--------------------------------------------------------------------------------
/README-OPEVPN-CONF.md:
--------------------------------------------------------------------------------
1 | # Instructions on setting a OpenVPN server for dev.
2 |
3 | ## Parallels VM's
4 |
5 | We have CentOS and Ubuntu VM's that are fully configured.
6 |
7 | Client keys to setup Viscosity are in `~/client-keys/`
8 |
9 | The configured accounts (with sudo) on the VM's are:
10 |
11 | User: root : password
12 | authy : authy
13 |
14 |
15 | ## From Scratch
16 |
17 | Start installing openvpn package.
18 |
19 | ## OpenVPN config
20 |
21 | Config is on `/etc/openvpn/server.conf`
22 |
23 | port 1194
24 | proto tcp
25 |
26 | dev tun
27 |
28 | ca ca.crt
29 | cert server.crt
30 | key server.key # This file should be kept secret
31 | tls-auth ta.key 0 # This file is secret
32 |
33 | dh dh1024.pem
34 |
35 | # ethernet bridging. See the man page for more info.
36 | server 10.8.0.0 255.255.255.0
37 |
38 | # previously assigned.
39 | ifconfig-pool-persist ipp.txt
40 |
41 | keepalive 10 120
42 |
43 |
44 | # Enable compression on the VPN link.
45 | # If you enable it here, you must also
46 | # enable it in the client config file.
47 | comp-lzo
48 |
49 | persist-key
50 | persist-tun
51 |
52 | status openvpn-status.log
53 | log openvpn.log
54 | log-append openvpn.log
55 |
56 | # Set the appropriate level of log
57 | # file verbosity.
58 | #
59 | # 0 is silent, except for fatal errors
60 | # 4 is reasonable for general usage
61 | # 5 and 6 can help to debug connection problems
62 | # 9 is extremely verbose
63 | verb 4
64 |
65 |
66 |
67 | ## Server certificates
68 |
69 | sudo cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/ /etc/openvpn/easy-rsa
70 | cd /etc/openvpn/easy-rsa/ ## move to the easy-rsa directory
71 | sudo chown -R root:adm . ## make this directory writable by the system administrators
72 | sudo chmod g+w . ## make this directory writable by the system administrators
73 | source ./vars ## execute your new vars file
74 | ./clean-all ## Setup the easy-rsa directory (Deletes all keys)
75 | ./build-dh ## takes a while consider backgrounding
76 | ./pkitool --initca ## creates ca cert and key
77 | ./pkitool --server server ## creates a server cert and key
78 | ## If you get this error:
79 | ## "The correct version should have a comment that says: easy-rsa version 2.x"
80 | ## Try This:
81 | ## sudo ln -s openssl-1.0.0.cnf openssl.cnf
82 | ## Refer to: https://bugs.launchpad.net/ubuntu/+source/openvpn/+bug/998918
83 | cd keys
84 | openvpn --genkey --secret ta.key ## Build a TLS key
85 | sudo cp server.crt server.key ca.crt dh1024.pem ta.key ../../
86 |
87 |
88 | ## Client certificates
89 |
90 |
91 | cd /etc/openvpn/easy-rsa/ ## move to the easy-rsa directory
92 | source ./vars ## execute the vars file
93 | KEY_CN=client ./pkitool client ## create a cert and key named "client"
94 | ## Note: if you get a 'TXT_DB error number 2' error you may need to specify
95 | ## a unique KEY_CN, for example: KEY_CN=client ./pkitool client
96 |
97 | Now move the necessary keys to a folder
98 |
99 | mkdir ~/client-keys/
100 | cd /etc/openvpn/easy-rsa/keys
101 | sudo cp ca.crt client.crt ta.key client.key ~/client-keys/
102 | sudo chown $USER -R ~/client-keys
103 |
104 | Now move client-keys to you client machine
105 |
106 |
107 | ## Client Setup
108 |
109 | Use Viscosity VPN client.
110 |
111 | ##### Advanced
112 |
113 | Use OpenVPN version 2.2
114 |
115 | ##### General
116 |
117 | Protocol: TCP
118 | Device: TUN
119 |
120 | ##### Authentication
121 |
122 | Type: SSL/TLS CLient
123 |
124 | CA: ca.crt
125 | CERT: client.crt
126 | Key: client.key
127 |
128 | TLs-Auth: ta.key
129 | Direction 1 #super important
130 |
131 | ##### Options
132 |
133 | Turn on: Perstist Tun, Persist Key, No Bind, Pull Options
134 | LZO COmpression: Off
135 |
136 |
137 |
--------------------------------------------------------------------------------
/README-instructions.md:
--------------------------------------------------------------------------------
1 | # Authy Open VPN
2 |
3 | With Authy OpenVPN plugin you can add Two-Factor Authentication to
4 | your vpn server in just minutes. This plugin supports certificate based
5 | authentication, PAM or LDAP.
6 |
7 | With Authy your users can authenticate using Authy mobile app or a hardware dongle.
8 |
9 | _For hardware dongles, phone calls or LDAP please contact sales@authy.com_
10 |
11 | ## Pre-Requisites
12 |
13 | 1. Authy API Key. Get one free at: [https://www.authy.com/signup](https://www.authy.com/signup).
14 | 2. OpenVPN installation ([How To](http://openvpn.net/index.php/open-source/documentation/howto.html))
15 |
16 | ## Quick Installation
17 |
18 | #### Using the source code
19 |
20 | __This is the recommended way of installing.__
21 |
22 | ##### Required libs
23 |
24 | 1. Compiler:
25 |
26 | - Ubuntu: apt-get install build-essential
27 | - Centos: yum groupinstall 'Development Tools'
28 |
29 | 2. libcurl with SSL:
30 |
31 | - Ubuntu: apt-get install libcurl4-openssl-dev
32 | - CentOS: yum install libcurl-devel.x86_64
33 |
34 | ##### Compiling and installing
35 |
36 | 1. Compile and install.
37 |
38 | curl -L "https://github.com/authy/authy-openvpn/archive/master.tar.gz" -o authy-openvpn.tar.gz
39 | tar -zxvf authy-openvpn.tar.gz
40 | cd authy-openvpn-master
41 | make
42 | sudo make install
43 |
44 | 2. Get your free Authy API KEY from: [https://www.authy.com/signup](https://www.authy.com/signup).
45 |
46 | 3. Finally configure the plugin.
47 |
48 | sudo ./scripts/post-install
49 |
50 | 4. Restart your server (see below).
51 |
52 | 5. Start adding users using `sudo authy-vpn-add-user` (see below).
53 |
54 | #### Windows install
55 |
56 | You need to copy the following dlls `authy-openvpn.dll`, `lib/msvcr100.dll` and `lib/normaliz.dll` to `OpenVPN\bin`, and `curl-bundle-ca.crt` to `OpenVPN\config\`
57 |
58 | Add the following line to your `server.ovpn`
59 |
60 | plugin "C:\\Program Files\\OpenVPN\\bin\\authy-openvpn.dll" https://api.authy.com/protected/json AUTHY_API_KEY nopam
61 |
62 | And create the `authy-vpn.conf` inside `C:\\Program Files\\OpenVPN\\config`, remember that the this file follows one of the following patterns
63 |
64 | USERNAME AUTHY_ID
65 |
66 | or
67 |
68 | USERNAME COMMON_NAME AUTHY_ID
69 |
70 | Remember that the last one is to also check the match between `USERNAME` and `COMMON_NAME`
71 |
72 | __Recommended:__
73 |
74 | Set the `reneg-sec 0` option in your OpenVPN configuration file. This will prevent the server from forcing renegotiation (and asking for a new Authy token).
75 | Note that if your OpenVPN version is `<= 2.2` you need to set reneg-sec to a large value instead of 0.
76 |
77 | ### Restarting your OpenVPN server
78 |
79 | #### Ubuntu
80 |
81 | sudo service openvpn restart
82 |
83 | #### Debian
84 |
85 | /etc/init.d/openvpn restart
86 |
87 | #### CentOS and RedHat
88 |
89 | /sbin/service openvpn restart
90 |
91 |
92 |
93 |
94 | ## Adding Users
95 |
96 | To add users make sure you have their cellphone numbers.
97 |
98 | The Authy VPN plugin comes with a script, that helps you register users.
99 |
100 | To start adding users type:
101 |
102 | sudo authy-vpn-add-user
103 |
104 | sudo authy-vpn-add-user
105 | This script is to add users to Authy Open VPN
106 | For each user you will need to provide the vpn login, e-mail, country code and cellphone
107 | For PAM, login is the *nix login or your PAM login username.
108 | For certificate based Auth we recommend you use e-mails as the login.
109 | Login: liz@authy.com
110 | Email: liz@authy.com
111 | Country Code (EG. 1 for US): 1
112 | Cellphone: 347-388-2229
113 | Registering the user with Authy
114 | ...
115 | Success: User liz@authy.com was registered with AUTHY_ID 12323.
116 |
117 |
118 |
119 |
120 |
121 | ## How Authy-VPN works
122 |
123 | Authy stores it's configuration in the file `/etc/openvpn/authy/authy-vpn.conf`
124 | The files format is:
125 |
126 | username authy_id
127 |
128 | For example for `liz@authy.com` it would look:
129 |
130 | sudo cat /etc/openvpn/authy/authy-vpn.conf
131 | liz@authy.com 12323
132 |
133 | When liz is login in, she will type `liz@authy.com` as her username and the
134 | token as the password.
135 |
136 | You can edit this file by hand or using `authy-vpn-add-user`
137 |
138 | ### With Certificates based Authentication
139 |
140 | In this scenario user needs: username + certificate + token to login.
141 |
142 | If you're already using certificates to authenticate your vpn users you won't
143 | need to regenerate them. All you have to do is edit '/etc/openvpn/authy/authy-vpn.conf' were you tell
144 | authy the users login and the AUTHY_ID.
145 |
146 | ##### Example authy-vpn.conf for a user joe with AUTHY_ID 10229
147 |
148 | joe@company.com 10229
149 |
150 | Here the user will enter `joe@company.com` as username and the
151 | Token(which he gets from the app) as the password. The
152 | certificate is transparently checked before this happens.
153 |
154 | ### PAM based Auth
155 |
156 | If you are using PAM before you can still use authy Two-Factor
157 | Authentication.
158 |
159 | To use PAM simply answer that you are going to use PAM during the
160 | `post-install` script.
161 |
162 | #### After run the post-install script your server.conf should have the following lines:
163 |
164 | # This line was added by the authy-openvpn installer
165 | plugin /usr/lib/authy/authy-openvpn.so https://api.authy.com/protected/json [YOUR_API_KEY] pam
166 |
167 | Make sure your pam openvpn plugin is loaded after the authy openvpn plugin.
168 | Plugins are loaded in the order they appear in the config file, the result should look like:
169 |
170 | # This line was added by the authy-openvpn installer
171 | plugin /usr/lib/authy/authy-openvpn.so https://api.authy.com/protected/json [YOUR_API_KEY] pam
172 |
173 | plugin /usr/lib/openvpn/openvpn-auth-pam.so "login login USERNAME password PASSWORD"
174 |
175 |
176 | Also your users will need to separate the password from the token during login
177 | by using a '-' character.
178 |
179 | Eg:
180 | [PASSWORD]-[TOKEN]
181 |
182 |
183 | ##### Example authy-vpn.conf for a user joe with AUTHY_ID 10229
184 |
185 | joe 10229
186 |
187 | Here joe is the PAM login username.
188 |
189 | Let's suppose joe password is `god`. So the user will enter `joe` as
190 | username. On the password field he will enter his password followed by a `-` followed by the Authy Token.
191 |
192 | EG.
193 |
194 | username:joe
195 | password:god-1234567
196 |
197 | `1234567` would be the Authy Token and `god` his password.
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 | ## SMS and Phone Calls
206 |
207 | To use SMS or Phone calls the user will have to enter `sms` or `call` as
208 | the password. The first authentication will fail. The user should then
209 | wait for the SMS or Call to arrive and re-authenticate with the right
210 | username and token.
211 |
212 | Eg.
213 |
214 | auth#1:
215 | username: joe@authy.com
216 | password: sms
217 |
218 | auth#2:
219 | username: joe@authy.com
220 | password: 172839
221 |
222 |
223 | ## Optional: Authy OpenVPN with Common Name Verification
224 |
225 | Authy by default does not verify that the common name in the certificate matches the login.
226 | This means a user can logon with someone elses certificate and a different Two-Factor Auth login.
227 |
228 |
229 | This normaly ok as most of the time all users in the VPN have the same privileges and routes.
230 | If this is not the case we suggest you verify the common name matches the Two-Factor login.
231 | This is accomplish by modifying authy-vpn.conf to add the common name to every login.
232 |
233 | ### Example authy-vpn.conf for a user joe with Common Name joe1 and AUTHY_ID 10229
234 |
235 | joe 10229 joe1
236 |
237 | This will check that joe and the common name from the certificate
238 | (joe1) matches before proceding with the authentication.
239 |
240 | ## VPN Client configuration for all users
241 |
242 | Your users will need to add
243 |
244 | auth-user-pass
245 |
246 | to their `client.conf`. This is to ensure that the OpenVPN client asks
247 | for username and password (this is where they enter the token).
248 |
249 | ## Copyright
250 |
251 | Copyright (c) 2013-2020 Authy Inc.
252 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Authy Open VPN
2 |
3 | This plugin is no longer actively maintained. If you're interested in becoming a maintainer, we welcome forks of this project. You can also contact help@twilio.com and we can discuss giving you write access to the project. We apologize for any inconvenience this may cause.
4 |
5 | Legacy documentation is found at [README-instructions.md](README-instructions.md).
6 |
--------------------------------------------------------------------------------
/TROUBLESHOOTING.md:
--------------------------------------------------------------------------------
1 | # Troubleshooting installation.
2 |
3 | Authy VPN has a lot of debug logs to help you diagnose issues.
4 | Start by editing your vpn server.conf so that it creates a log file.
5 |
6 | ## Logging
7 |
8 | Add the following lines at the end of: `/etc/openvpn/server.conf`
9 |
10 | status openvpn-status.log
11 | log openvpn.log
12 | log-append openvpn.log
13 | verb 4
14 |
15 | ## Verifying that the authy plugin is being properly loaded
16 |
17 | If the pluging is loaded correctly, it will log this line at
18 | initialization:
19 |
20 | sudo cat openvpn.log | grep '\[Authy\]'
21 | [Authy] Authy Two-Factor Authentication started
22 |
23 |
24 | ## Authentication logs
25 |
26 | Authy will also log all the authentication activity on openvpn.log
27 |
28 | #### Example log when auth fails
29 |
30 | [Authy] Authy Two-Factor Authentication started
31 | [Authy] Authenticating: username=d@authy.com, token=1234567 and AUTHY_ID=1
32 | * About to connect() to api.authy.com port 443 (#0)
33 | * Trying 107.23.117.172...
34 | * Connected to api.authy.com (107.23.117.172) port 443 (#0)
35 | * successfully set certificate verify locations:
36 | * CAfile: none
37 | CApath: /etc/ssl/certs
38 | * SSL connection using ECDHE-RSA-AES256-SHA
39 | * Server certificate:
40 | * subject: serialNumber=STgISFc5XC8h7Ocjt9n9-dNQ/cxTm75c; OU=GT76495531; OU=See www.rapidssl.com/resources/cps (c)12; OU=Domain Control Validated - RapidSSL(R); CN=api.authy.com
41 | * start date: 2012-12-16 08:56:17 GMT
42 | * expire date: 2014-01-18 09:08:03 GMT
43 | * subjectAltName: api.authy.com matched
44 | * issuer: C=US; O=GeoTrust, Inc.; CN=RapidSSL CA
45 | * SSL certificate verify ok.
46 | > GET /protected/json/verify/1234567/1?api_key=004436f9c97c9988253bd95933296580 HTTP/1.1
47 | Host: api.authy.com
48 | Accept: */*
49 |
50 | < HTTP/1.1 401 Unauthorized
51 | < Server: nginx/1.1.19
52 | < Date: Fri, 16 Aug 2013 20:14:00 GMT
53 | < Content-Type: application/json;charset=utf-8
54 | < Content-Length: 88
55 | < Connection: keep-alive
56 | < Status: 401 Unauthorized
57 | < WWW-Authenticate: Basic realm="Access Denied"
58 | <
59 | * Connection #0 to host api.authy.com left intact
60 | [Authy] Curl response: Code=0, Body={"success":"false","message":"token is invalid","errors":{"message":"token is invalid"}}
61 | [Authy] Auth failed for d@authy.com
62 |
63 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 5.0
2 |
--------------------------------------------------------------------------------
/authy-openvpn.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C++ Express 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "authy-openvpn", "authy-openvpn.vcxproj", "{B2D97E1F-1EDC-902F-8EBA-217FD041625C}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {B2D97E1F-1EDC-902F-8EBA-217FD041625C}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {B2D97E1F-1EDC-902F-8EBA-217FD041625C}.Debug|Win32.Build.0 = Debug|Win32
14 | {B2D97E1F-1EDC-902F-8EBA-217FD041625C}.Release|Win32.ActiveCfg = Release|Win32
15 | {B2D97E1F-1EDC-902F-8EBA-217FD041625C}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/authy-openvpn.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | Win32Proj
15 | {B2D97E1F-1EDC-902F-8EBA-217FD041625C}
16 |
17 |
18 |
19 | DynamicLibrary
20 | true
21 | v110
22 |
23 |
24 | DynamicLibrary
25 | false
26 | v110
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | true
41 | C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\include;C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\lib\include;$(IncludePath)
42 | C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\lib;$(LibraryPath)
43 |
44 |
45 | false
46 | C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\lib\include;C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\include;$(IncludePath)
47 | C:\Documents and Settings\Sebastian\Mis documentos\GitHub\authy-open-vpn\lib;$(LibraryPath)
48 | false
49 |
50 |
51 |
52 | WIN32;_DEBUG;_WINDOWS;_USRDLL;AUTHYOPENVPN_EXPORTS;%(PreprocessorDefinitions)
53 | MultiThreadedDLL
54 | Level1
55 | ProgramDatabase
56 | Disabled
57 | CompileAsCpp
58 | Cdecl
59 |
60 |
61 | MachineX86
62 | true
63 | Windows
64 | C:\Users\Administrator\Documents\GitHub\authy-open-vpn\lib;%(AdditionalLibraryDirectories)
65 | curllib.lib;libeay32.lib;ssleay32.lib;openldap.lib;%(AdditionalDependencies)
66 |
67 |
68 | true
69 |
70 |
71 |
72 |
73 | WIN32;NDEBUG;_WINDOWS;_USRDLL;AUTHYOPENVPN_EXPORTS;%(PreprocessorDefinitions)
74 | MultiThreadedDLL
75 | TurnOffAllWarnings
76 | CompileAsCpp
77 | -DCURL_STATICLIB %(AdditionalOptions)
78 | false
79 | false
80 | C:\Users\Administrator\Documents\GitHub\authy-open-vpn\lib\include;C:\Users\Administrator\Documents\GitHub\authy-open-vpn\include;%(AdditionalIncludeDirectories)
81 |
82 |
83 | MachineX86
84 | false
85 | Windows
86 | true
87 | true
88 | curllib_static.lib;ssleay32.lib;libeay32.lib;%(AdditionalDependencies)
89 | false
90 | false
91 | true
92 | %(IgnoreSpecificDefaultLibraries)
93 | 5.0
94 | C:\Users\Administrator\Documents\GitHub\authy-open-vpn\lib;%(AdditionalLibraryDirectories)
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/scripts/authy-vpn-add-user:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This script is based on
3 | # https://github.com/authy/authy-ssh/blob/master/authy-ssh
4 |
5 | VERSION="1.0"
6 | AUTHY_URL="https://api.authy.com"
7 | CONFIG_FILE="/etc/openvpn/authy/authy-vpn.conf"
8 |
9 | export TERM="xterm-256color"
10 | NORMAL=$(tput sgr0)
11 | GREEN=$(tput setaf 2; tput bold)
12 | YELLOW=$(tput setaf 3)
13 | RED=$(tput setaf 1)
14 |
15 | function red() {
16 | echo -e "$RED$*$NORMAL"
17 | }
18 |
19 | function green() {
20 | echo -e "$GREEN$*$NORMAL"
21 | }
22 |
23 | function yellow() {
24 | echo -e "$YELLOW$*$NORMAL"
25 | }
26 |
27 | function require_curl() {
28 | which curl 2>&1 > /dev/null
29 | if [ $? -eq 0 ]
30 | then
31 | return 0
32 | fi
33 |
34 | # if `which` is not installed this check is ran
35 | curl --help 2>&1 > /dev/null
36 |
37 | if [ $? -ne 0 ]
38 | then
39 | red "install curl and try again"
40 | exit 1
41 | fi
42 | }
43 |
44 | function check_api_key() {
45 | if [[ $AUTHY_API_KEY == "replace_me" || ! $AUTHY_API_KEY ]]
46 | then
47 | red "Cannot find a valid api key"
48 | exit 1
49 | fi
50 | }
51 |
52 | # usage: register_user "login" "" "" ""
53 | function register_user() {
54 | local login=$1
55 | url="$AUTHY_URL/protected/json/users/new?api_key=${AUTHY_API_KEY} -d user[email]=$2 -d user[country_code]=$3 -d user[cellphone]=$4 -s"
56 |
57 | green "Registering the user with Authy"
58 |
59 | response=`curl ${url} 2>/dev/null`
60 | ok=true
61 |
62 | if [[ $response == *cellphone* ]]
63 | then
64 | yellow "Cellphone is invalid"
65 | ok=false
66 | fi
67 |
68 | if [[ $response == *email* ]]
69 | then
70 | yellow "Email is invalid"
71 | ok=false
72 | fi
73 |
74 | if [[ $response == *country* ]]
75 | then
76 | yellow "Country Code is invalid"
77 | ok=false
78 | fi
79 |
80 | if [[ $ok == false ]]
81 | then
82 | return 1
83 | fi
84 |
85 | if [[ $response == *user*id* ]]
86 | then
87 | user_id=`echo $response | grep -o '[0-9]\{1,\}'` # match the authy id
88 | if [[ $user_id ]]
89 | then
90 | echo "$login $user_id" >> $CONFIG_FILE
91 | green "Success: User $login was registered with AUTHY_ID $user_id."
92 | return 0
93 | else
94 | red "Cannot register user: $response"
95 | fi
96 | elif [[ $response == "invalid key" ]]
97 | then
98 | yellow "The api_key value is not valid"
99 | else
100 | red "Unknown response: $response"
101 | fi
102 | return 1
103 | }
104 |
105 | function read_config()
106 | {
107 | local api_key="$(cat /etc/openvpn/*.conf | grep authy-openvpn.so -m 1 | cut -d" " -f4)"
108 |
109 | if [[ $api_key != "" ]]
110 | then
111 | echo $api_key
112 | return 0
113 | fi
114 |
115 | return 1
116 | }
117 |
118 | function register_users()
119 | {
120 | echo "This script is to add users to Authy Open VPN"
121 | echo "For each user you will need to provide the vpn login, e-mail, country code and cellphone"
122 | echo "For PAM, login is the *nix login or your PAM login username."
123 | echo "For certificate based Auth we recommend you use e-mails as the login."
124 |
125 | echo -n "Login: "
126 | read login
127 |
128 | echo -n "Email: "
129 | read email
130 |
131 | echo -n "Country Code (EG. 1 for US): "
132 | read country_code
133 |
134 | echo -n "Cellphone: "
135 | read cellphone
136 |
137 | register_user $login $email $country_code $cellphone
138 |
139 | if [[ $? -ne 0 ]] ; then
140 | red "Failed to add user. Try again."
141 | exit 1
142 | fi
143 | }
144 |
145 |
146 | # cd - >/dev/null
147 | require_curl
148 | AUTHY_API_KEY="$(read_config)"
149 | if [ $? -ne 0 ] ; then
150 | exit 1
151 | fi
152 |
153 | mkdir -p `dirname "${CONFIG_FILE}"`
154 | touch $CONFIG_FILE
155 | if [ $? -ne 0 ] ; then
156 | exit 1
157 | fi
158 | chown root $CONFIG_FILE
159 | chmod 600 $CONFIG_FILE
160 |
161 | check_api_key
162 | register_users
163 |
164 |
--------------------------------------------------------------------------------
/scripts/post-install:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #This command need to be called like ./postinstall
3 |
4 | function check_root {
5 | if [[ "$(whoami)" != "root" ]]
6 | then
7 | echo "Please run this command as root."
8 | exit -1
9 | fi
10 | }
11 |
12 | function add_configuration {
13 | local conf_file=$1
14 | local string_to_add=$2
15 | echo "" >> $conf_file
16 | echo "# This line was added by the authy-openvpn installer" >> $conf_file
17 | echo "$string_to_add" >> $conf_file
18 | }
19 |
20 | function add_authy {
21 | local server_conf=$1
22 | local plugin=$2
23 | local key=$3
24 | local pam=$4
25 |
26 | sed -ie '/authy-openvpn/d' "$server_conf"
27 | add_configuration "$server_conf" "plugin $plugin https://api.authy.com/protected/json $key $pam"
28 | }
29 |
30 | function prephase {
31 | echo -n "Do you want us to edit server.conf for you? (y/n): "
32 | read helpp
33 | if [ $helpp != 'y' ] ; then
34 | return 0
35 | fi
36 |
37 | local serverconf="/etc/openvpn/server.conf"
38 | if [ ! -f $serverconf ] ; then
39 | echo -n "Enter path to your openvpn configuration: "
40 | read serverconf
41 | fi
42 |
43 | if [ ! -f "$serverconf" ] ; then
44 | echo "Config file not found. Make sure you enter the absolute path."
45 | return 1
46 | fi
47 |
48 | echo -n "Authy API KEY: "
49 | read authy_key
50 |
51 | echo -n "Are you using OpenVPN with PAM? (y/n): "
52 | read helpp
53 |
54 | if [ $helpp != 'y' ] ; then
55 | add_authy $serverconf $AUTHYSO $authy_key "nopam"
56 | else
57 | add_authy $serverconf $AUTHYSO $authy_key "pam"
58 | fi
59 |
60 | echo ""
61 | echo "All done. Now start adding users using 'sudo authy-vpn-add-user'"
62 | }
63 |
64 | DESTDIR=/usr/lib/authy
65 | AUTHYSO=$DESTDIR/authy-openvpn.so
66 |
67 | check_root
68 | prephase
69 |
70 |
--------------------------------------------------------------------------------
/src/authy_api.c:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // authy_api.c
8 | //
9 | // Abstract
10 | //
11 | // Implements the public Authy API using json. Uses CURL to do multi-platform HTTPS request.
12 | //
13 | // registerUser
14 | // verifyToken
15 | // requestSMS
16 | //
17 | //
18 | //
19 | // History
20 | //
21 | // 8/1/2013 dpalacio Created
22 | //
23 | //------------------------------------------------------------------------------
24 |
25 |
26 | #include
27 | #include
28 | #include
29 | #include "utils.h"
30 | #include "logger.h"
31 | #include "authy_api.h"
32 | #include "constants.h"
33 |
34 | #include "vendor/jsmn/jsmn.h"
35 |
36 | #ifdef WIN32
37 | #define snprintf _snprintf
38 | #endif
39 |
40 |
41 | //
42 | // Description
43 | //
44 | // Given the url, endpoint, params and keys, calculates the size
45 | // of the URL
46 | //
47 | // Parameters
48 | //
49 | // pszApiUrl - Server URL
50 | // pszEndPoint - The API endpoint including format
51 | // pszParams - The endpoint params.
52 | // pszApiKey - The Authy API key.
53 | //
54 | // Returns
55 | //
56 | // The size of the URL to be allocated.
57 | //
58 | //
59 |
60 | static size_t
61 | calcUrlSize(const char *pszApiUrl,
62 | const char *pszEndPoint,
63 | const char *pszParams,
64 | const char *pszApiKey)
65 | {
66 | return strlen(pszApiUrl) + strlen(pszEndPoint) + strlen(pszParams) + strlen(pszApiKey) + 1;
67 | }
68 |
69 | //
70 | // Description
71 | //
72 | // Allocates the memory and build the URL of the enpoind including
73 | // params.
74 | //
75 | // Parameters
76 | //
77 | // pResultUrl - A pointer to the pointer were the URL will be stored.
78 | // pszApiUrl - Server URL
79 | // pszEndPoint - The API endpoint including format
80 | // pszParams - The endpoint params.
81 | // pszApiKey - The Authy API key.
82 | //
83 | // Returns
84 | //
85 | // Standard RESULT
86 | //
87 | RESULT
88 | buildUrl(__out char **ppszResultUrl,
89 | const char *pszApiUrl,
90 | const char *pszEndPoint,
91 | const char *pszParams,
92 | const char *pszApiKey)
93 | {
94 | assert(ppszResultUrl != NULL);
95 |
96 | RESULT r = FAIL;
97 |
98 | size_t urlSize = calcUrlSize(pszApiUrl,
99 | pszEndPoint,
100 | pszParams,
101 | pszApiKey);
102 |
103 |
104 | *ppszResultUrl = calloc(urlSize, sizeof(char));
105 | if(NULL == *ppszResultUrl){
106 | trace(ERROR, __LINE__, "[Authy] Out of Memory: Malloc failed.");
107 | r = OUT_OF_MEMORY;
108 | goto EXIT;
109 | }
110 |
111 | snprintf(*ppszResultUrl,
112 | urlSize,
113 | "%s%s%s%s",
114 | pszApiUrl, pszEndPoint, pszParams, pszApiKey);
115 |
116 | trace(DEBUG, __LINE__, "[Authy] buildUrl pszResultUrl=%s\n.", *ppszResultUrl);
117 | r = OK;
118 |
119 | EXIT:
120 | return r;
121 | }
122 |
123 |
124 |
125 | //
126 | // Description
127 | //
128 | // curl custom writer. Implements the prototype:
129 | // prototype: size_t function( char *ptr, size_t size, size_t nmemb, void *userdata);
130 | //
131 | // Parameters
132 | //
133 | // ptr - Rough data with size size * nmemb. Not zero terminated
134 | // size - size of each member of ptr
135 | // nmemb - number of members
136 | // userdata - pointer to were the date is written too. Max write is CURL_MAX_WRITE_SIZE
137 | // We allocate userdate 0 termited from the start.
138 | //
139 | // Returns
140 | //
141 | // Ammount of data that was written to userdata. Else curl will raise an
142 | // error.
143 | //
144 | //
145 | static size_t
146 | curlWriter(char *ptr,
147 | size_t size,
148 | size_t nmemb,
149 | void *userdata)
150 | {
151 | memcpy(userdata, ptr, (size_t) size * nmemb);
152 | return nmemb*size;
153 | }
154 |
155 | // Description
156 | //
157 | // Goes through the response body looking for token validity.
158 | //
159 | // Parameters
160 | //
161 | // pszRespone - Response body in json format
162 | //
163 | // Returns
164 | //
165 | // TRUE if the response body includes "token": "is valid", FALSE otherwise.
166 | //
167 | BOOL
168 | tokenResponseIsValid(char *pszResponse)
169 | {
170 | int cnt;
171 | jsmn_parser parser;
172 | jsmn_init(&parser);
173 | jsmntok_t tokens[20] = {{0}};
174 | jsmn_parse(&parser, pszResponse, tokens, 20);
175 |
176 | /* success isn't always on the same place, look until 19 because it
177 | shouldn't be the last one because it won't be a key */
178 | for (cnt = 0; cnt < 19; cnt++)
179 | {
180 | /* avoid matching empty strings since "" == "" */
181 | int len = (tokens[cnt]).end - (tokens[cnt]).start;
182 | if(len > 0 && strncmp(pszResponse + (tokens[cnt]).start, "token", len) == 0)
183 | {
184 | if(strncmp(pszResponse + (tokens[cnt+1]).start, "is valid", (tokens[cnt+1]).end - (tokens[cnt+1]).start) == 0){
185 | return TRUE;
186 | } else {
187 | return FALSE;
188 | }
189 | }
190 | }
191 | return FALSE;
192 | }
193 |
194 | //
195 | // Description
196 | //
197 | // Handles the http request to the api
198 | // it knows when to do a GET or a POST based
199 | // on the present of pszPostFields
200 | //
201 | // Parameters
202 | //
203 | // pszResultUrl - The full URL
204 | // pszPostFields - POST fields if it's a POST request or NULL for GET request
205 | // pszEndPoint - The API endpoint including format
206 | // pszParams - The endpoint params.
207 | // pszApiKey - The Authy API key.
208 | //
209 | // Returns
210 | //
211 | // Standard RESULT
212 | //
213 | RESULT
214 | doHttpRequest(char *pszResultUrl, char *pszPostFields, char *pszResponse)
215 | {
216 | RESULT r = FAIL;
217 | CURL *pCurl = NULL;
218 | int curlResult = -1;
219 | char *pszUserAgent = NULL;
220 |
221 | pszUserAgent = getUserAgent();
222 | if(NULL == pszUserAgent)
223 | {
224 | trace(ERROR, __LINE__, "[Authy] Cannot get user agent. Setting user agent to unkown.");
225 |
226 | pszUserAgent = calloc(strlen(UNKNOWN_VERSION_AGENT) + 1, sizeof(char));
227 | if(pszUserAgent == NULL)
228 | {
229 | trace(ERROR, __LINE__, "[Authy] Failed to set user agent. Could not allocate memory for user agent.");
230 | goto EXIT;
231 | }
232 | pszUserAgent = strncpy(pszUserAgent, UNKNOWN_VERSION_AGENT, strlen(UNKNOWN_VERSION_AGENT));
233 | }
234 |
235 | curl_global_init(CURL_GLOBAL_ALL);
236 |
237 | pCurl = curl_easy_init();
238 | if(!pCurl){
239 | r = FAIL;
240 | trace(ERROR, __LINE__, "[Authy] CURL failed to initialize");
241 | goto EXIT;
242 | }
243 |
244 | curl_easy_setopt(pCurl, CURLOPT_URL, pszResultUrl);
245 |
246 | if(pszPostFields) // POST REQUEST
247 | {
248 | curl_easy_setopt(pCurl, CURLOPT_POSTFIELDS, pszPostFields);
249 | }
250 |
251 | #ifdef WIN32
252 | curl_easy_setopt(p_curl, CURLOPT_CAINFO, "curl-bundle-ca.crt");
253 | #endif
254 |
255 | curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, 1L); //verify PEER certificate
256 | curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYHOST, 2L); //verify HOST certificate
257 | curl_easy_setopt(pCurl, CURLOPT_VERBOSE, 1L);
258 | curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, curlWriter);
259 | curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, pszResponse);
260 | curl_easy_setopt(pCurl, CURLOPT_USERAGENT, pszUserAgent);
261 |
262 | curlResult = (int) curl_easy_perform(pCurl);
263 | if(0 != curlResult) {
264 | trace(ERROR, __LINE__, "Curl failed with code %d", curlResult);
265 | r = FAIL;
266 | goto EXIT;
267 | }
268 |
269 | trace(INFO, __LINE__, "[Authy] Curl response: Body=%s\n", pszResponse);
270 |
271 | r = OK;
272 |
273 | EXIT:
274 | if(pszUserAgent)
275 | {
276 | free(pszUserAgent);
277 | }
278 |
279 | #ifdef WIN32
280 | trace(DEBUG, __LINE__, "[Authy] Can't clean curl, curl easy cleanup doesn't work on Windows");
281 | #else
282 | if(pCurl){
283 | curl_easy_cleanup(pCurl);
284 | }
285 | #endif
286 |
287 | return r;
288 | }
289 |
290 | //
291 | // Description
292 | //
293 | // Calls the new user Authy API API
294 | //
295 | // Parameters
296 | //
297 | // pszApiUrl - The server URL
298 | // pszPostFields - POST fields if it's a POST request
299 | // pszEndPoint - The API endpoint including format
300 | // pszParams - The endpoint params.
301 | // pszApiKey - The Authy API key.
302 | //
303 | // Returns
304 | //
305 | // Standard RESULT
306 | //
307 | extern RESULT
308 | registerUser(const char *pszApiUrl,
309 | char *pszPostFields,
310 | const char *pszApiKey,
311 | char *pszResponse)
312 | {
313 | int r = FAIL;
314 | char *pszResultUrl = NULL;
315 | char *pszEndPoint = "/users/new";
316 | char *pszParams = "?api_key=";
317 |
318 | r = buildUrl(&pszResultUrl,
319 | pszApiUrl,
320 | pszEndPoint,
321 | pszParams,
322 | pszApiKey);
323 |
324 | if(FAILED(r)){
325 | goto EXIT;
326 | }
327 |
328 | r = doHttpRequest(pszResultUrl, pszPostFields, pszResponse);
329 |
330 | // Clean memory used in the request
331 | cleanAndFree(pszResultUrl);
332 | pszResultUrl = NULL;
333 |
334 | if(FAILED(r)){
335 | trace(ERROR, __LINE__, "[Authy] User Registration Failed\n");
336 | goto EXIT;
337 | }
338 |
339 | r = OK;
340 |
341 | EXIT:
342 | return r;
343 | }
344 |
345 |
346 |
347 | //
348 | // Description
349 | //
350 | // Calls the verify Authy API using force=true
351 | //
352 | // Does a GET to https://api.authy.com/protected/{FORMAT}/verify/{TOKEN}/{AUTHY_ID}?force=true&api_key={KEY}
353 | // Parameters
354 | //
355 | // pszApiUrl - The server URL
356 | // pszToken - The token entered by the user
357 | // pszAuthyId - The Authy ID fo the user
358 | // pszApiKey - The Authy API key
359 | // pszResponse - Pointer to where the response will be stored.
360 | //
361 | // Returns
362 | //
363 | // Standard RESULT
364 | //
365 | extern RESULT
366 | verifyToken(const char *pszApiUrl,
367 | char *pszToken,
368 | char *pszAuthyId,
369 | const char *pszApiKey,
370 | char *pszResponse)
371 | {
372 | RESULT r = FAIL;
373 | size_t endPointSize = 0;
374 | char *pszResultUrl = NULL;
375 | char *pszEndPoint = NULL;
376 | char *pszParams = "?force=true&api_key=";
377 |
378 | endPointSize = strlen("/verify/") + strlen(pszToken) + strlen("/") + strlen(pszAuthyId) + 1;
379 | pszEndPoint = calloc(endPointSize, sizeof(char));
380 | if(!pszEndPoint){
381 | r = FAIL;
382 | goto EXIT;
383 | }
384 |
385 | snprintf(pszEndPoint, endPointSize, "/verify/%s/%s", pszToken, pszAuthyId);
386 |
387 | r = buildUrl(&pszResultUrl,
388 | pszApiUrl,
389 | pszEndPoint,
390 | pszParams,
391 | pszApiKey);
392 |
393 | if(FAILED(r)) {
394 | trace(INFO, __LINE__, "[Authy] URL for Token verification failed\n");
395 | goto EXIT;
396 | }
397 |
398 | r = doHttpRequest(pszResultUrl, NULL, pszResponse); //GET request, postFields are NULL
399 |
400 | if(FAILED(r)) {
401 | trace(INFO, __LINE__, "[Authy] Token request verification failed.\n");
402 | goto EXIT;
403 | }
404 |
405 | if(FALSE == tokenResponseIsValid(pszResponse))
406 | {
407 | trace(ERROR, __LINE__, "Response does not include 'token': 'is valid'. Invalid token assumed.");
408 | r = FAIL;
409 | goto EXIT;
410 | }
411 |
412 | EXIT:
413 | cleanAndFree(pszResultUrl);
414 | pszResultUrl = NULL;
415 | cleanAndFree(pszEndPoint);
416 | pszEndPoint = NULL;
417 |
418 | return r;
419 | }
420 |
421 |
422 | ///
423 | // Description
424 | //
425 | // Calls the request SMS Authy API.
426 | //
427 | //
428 | // Parameters
429 | //
430 | // pszApiUrl - The server URL
431 | // pszAuthyId - The Authy ID fo the user
432 | // pszVia - This is the way, either 'call' or 'sms'
433 | // pszApiKey - The Authy API key
434 | // pszResponse - Pointer to where the response will be stored.
435 | //
436 | // Returns
437 | //
438 | // Standard RESULT
439 | //
440 | extern RESULT
441 | sendTokenToUser(const char *pszApiUrl,
442 | char *pszAuthyId,
443 | char *pszVia,
444 | const char *pszApiKey,
445 | char *pszResponse)
446 | {
447 | int r = FAIL;
448 | size_t endPointSize = 0;
449 | char *pszResultUrl = NULL;
450 | char *pszEndPoint = NULL;
451 | char *pszParams = "?api_key=";
452 |
453 | // /call/1 or /sms/1. Including the 2 slashes.
454 | endPointSize = 2 + strlen(pszVia) + strlen(pszAuthyId) + 1;
455 | pszEndPoint = calloc(endPointSize, sizeof(char));
456 | if(NULL == pszEndPoint){
457 | r = OUT_OF_MEMORY;
458 | goto EXIT;
459 | }
460 |
461 | snprintf(pszEndPoint, endPointSize, "/%s/%s", pszVia, pszAuthyId);
462 | r = buildUrl(&pszResultUrl,
463 | pszApiUrl,
464 | pszEndPoint,
465 | pszParams,
466 | pszApiKey);
467 |
468 | if(FAILED(r)) {
469 | r = FAIL;
470 | goto EXIT;
471 | }
472 |
473 | trace(INFO, __LINE__, "[Authy] Requesting %sfor Authy ID\n", pszVia, pszAuthyId);
474 | r = doHttpRequest(pszResultUrl, NULL, pszResponse);
475 |
476 | EXIT:
477 | cleanAndFree(pszResultUrl);
478 | pszResultUrl = NULL;
479 | cleanAndFree(pszEndPoint);
480 | pszEndPoint = NULL;
481 |
482 | return r;
483 | }
484 |
485 | ///
486 | // Description
487 | //
488 | // Calls the request SMS Authy API.
489 | //
490 | //
491 | // Parameters
492 | //
493 | // pszApiUrl - The server URL
494 | // pszAuthyId - The Authy ID fo the user
495 | // pszApiKey - The Authy API key
496 | // pszResponse - Pointer to where the response will be stored.
497 | //
498 | // Returns
499 | //
500 | // Standard RESULT
501 | //
502 | extern RESULT
503 | sms(const char *pszApiUrl,
504 | char *pszAuthyId,
505 | const char *pszApiKey,
506 | char *pszResponse)
507 | {
508 | int r = FAIL;
509 |
510 | char *pszVia = "sms";
511 | r = sendTokenToUser(pszApiUrl,
512 | pszAuthyId,
513 | pszVia,
514 | pszApiKey,
515 | pszResponse);
516 |
517 | if (FAILED(r)){
518 | trace(ERROR, __LINE__, "[AUTHY] Error sendingsms token to user\n");
519 | r = FAIL;
520 | goto EXIT;
521 | }
522 |
523 | r = OK;
524 |
525 | EXIT:
526 | return r;
527 | }
528 |
529 |
530 | ///
531 | // Description
532 | //
533 | // Calls the request call Authy API.
534 | //
535 | //
536 | // Parameters
537 | //
538 | // pszApiUrl - The server URL
539 | // pszAuthyId - The Authy ID fo the user
540 | // pszApiKey - The Authy API key
541 | // pszResponse - Pointer to where the response will be stored.
542 | //
543 | // Returns
544 | //
545 | // Standard RESULT
546 | //
547 | extern RESULT
548 | call(const char *pszApiUrl,
549 | char *pszAuthyId,
550 | const char *pszApiKey,
551 | char *pszResponse)
552 | {
553 | int r = FAIL;
554 |
555 | char *pszVia = "call";
556 | r = sendTokenToUser(pszApiUrl,
557 | pszAuthyId,
558 | pszVia,
559 | pszApiKey,
560 | pszResponse);
561 |
562 | if (FAILED(r)){
563 | trace(ERROR, __LINE__, "[AUTHY] Error trying to call the user\n");
564 | r = FAIL;
565 | goto EXIT;
566 | }
567 |
568 | r = OK;
569 |
570 | EXIT:
571 | return r;
572 | }
573 |
574 |
575 |
576 |
--------------------------------------------------------------------------------
/src/authy_api.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // authy_api.h
8 | //
9 | // Abstract
10 | //
11 | // Implements the public Authy API using json. Uses CURL to do multi-platform HTTPS request.
12 | //
13 | // History
14 | //
15 | // 8/1/2013 dpalacio Modified
16 | //
17 | //------------------------------------------------------------------------------
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include "custom_types.h"
25 |
26 | extern RESULT
27 | registerUser(const char *pszApiUrl,
28 | char *pszPostFields,
29 | const char *pszApiKey,
30 | char *pszResponse);
31 |
32 |
33 | extern RESULT
34 | verifyToken(const char *pszApiUrl,
35 | char *pszToken,
36 | char *pszAuthyId,
37 | const char *pszApiKey,
38 | char *pszResponse);
39 |
40 |
41 | extern RESULT
42 | sms(const char *pszApiUrl,
43 | char *pszAuthyId,
44 | const char *pszApiKey,
45 | char *pszResponse);
46 |
47 | extern RESULT
48 | call(const char *pszApiUrl,
49 | char *pszAuthyId,
50 | const char *pszApiKey,
51 | char *pszResponse);
52 |
--------------------------------------------------------------------------------
/src/authy_conf.c:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // authy_conf.c
8 | //
9 | // Abstract
10 | //
11 | //
12 | //
13 | // History
14 | //
15 | // 8/1/2013 dpalacio Created
16 | //
17 | //------------------------------------------------------------------------------
18 | #include
19 | #include
20 |
21 | #include "authy_conf.h"
22 | #include "logger.h"
23 | #include "utils.h"
24 | #include "constants.h"
25 |
26 | #define ALLOW_NON_TWO_FACTOR_LOGINS TRUE
27 |
28 | #define LINE_LENGTH 80 // CONF FILE MAX LINE LENGTH
29 |
30 | #ifdef WIN32
31 | #define snprintf _snprintf
32 | #endif
33 |
34 | #ifdef WIN32
35 | #define strcasecmp _stricmp
36 | #endif
37 |
38 | // Description
39 | //
40 | // Checks if pszAuthyId is a valid authyId
41 | // by checking if it's a number only.
42 | //
43 | // Parameters
44 | //
45 | // pszAuthyId - The Authy ID
46 | //
47 | // Returns
48 | //
49 | // 1 if it's a valid authy ID
50 | // 0 otherwie
51 | //
52 | static BOOL
53 | isAnAuthyId(char *pszAuthyId)
54 | {
55 | long long llAuthyId = (long long)strtoll(pszAuthyId, (char **)NULL, 10);
56 | if( 0 == llAuthyId){
57 | trace(DEBUG, __LINE__, "%s is not an Authy ID\n", pszAuthyId);
58 | return 0;
59 | }
60 | return 1;
61 | }
62 |
63 | // Description
64 | //
65 | // Checks that the username is valid
66 | //
67 | // Parameters
68 | //
69 | // pszUsername - The username to test
70 | //
71 | // Returns
72 | //
73 | // Standard RESULT
74 | //
75 | static RESULT
76 | checkUsername(const char *pszUsername)
77 | {
78 | RESULT r = FAIL;
79 | char *pszTempUsername = strdup(pszUsername);
80 | if(NULL == pszTempUsername){
81 | r = OUT_OF_MEMORY;
82 | trace(ERROR, __LINE__, "[Authy] Out of memory\n");
83 | goto EXIT;
84 | }
85 |
86 | removeSpaces(pszTempUsername);
87 |
88 | if(strlen(pszTempUsername) <= 0){
89 | r = FAIL;
90 | trace(ERROR, __LINE__, "[Authy] Invalid username %s=\n", pszUsername);
91 | goto EXIT;
92 | }
93 |
94 | r = OK;
95 |
96 | EXIT:
97 | cleanAndFree(pszTempUsername);
98 | pszTempUsername = NULL;
99 | return r;
100 | }
101 |
102 |
103 | // Description
104 | //
105 | // Validates that the given common name in the certificate
106 | // matches the common name for the user in the config file.
107 | //
108 | // Parameters
109 | //
110 | // pszCommonName - The common name on the certificate.
111 | // pszWantedCommonName - The common name on the config file
112 | //
113 | // Returns
114 | //
115 | // Standard RESULT
116 | //
117 | RESULT
118 | validateCommonName(const char *pszCommonName,
119 | const char *pszWantedCommonName
120 | )
121 | {
122 |
123 | RESULT r = FAIL;
124 |
125 | if(pszCommonName != NULL && strcmp(pszCommonName, pszWantedCommonName) == 0){
126 | r = OK;
127 | trace(ERROR, __LINE__, "[Authy] CommonName validation succeeded\n");
128 | }
129 | else{
130 | trace(ERROR, __LINE__, "[Authy] CommonName %s does not match the configuration file common name %s\n", pszCommonName, pszWantedCommonName);
131 | }
132 |
133 | return r;
134 | }
135 |
136 | // Description
137 | //
138 | // Extracts the Authy ID and common name from the configuration file
139 | //
140 | // Parameters
141 | //
142 | // ppszAuthyId - A pointer to the pointer that will hold the authy id string
143 | // ppszCommonName - A pointer to the pointer that will hold the CommonName String
144 | // pszConfFilename - Full path to the configuration file
145 | // pszUsername - The Username (login) for which we are getting the Authy ID
146 | // pszCommonName - Common name from the OpenVPN certificate
147 | //
148 | // Returns
149 | //
150 | // standard RESULT
151 | //
152 | RESULT
153 | getAuthyIdAndCommonName(__out char **ppszAuthyId,
154 | __out char **ppszCommonName,
155 | const char *pszConfFilename,
156 | const char *pszUsername
157 | )
158 | {
159 | FILE *fpConfFile = NULL;
160 | char *pch = NULL;
161 |
162 | char line[LINE_LENGTH];
163 | char *columns[3] = {NULL};
164 | int i = 0;
165 |
166 | RESULT r = FAIL;
167 |
168 | if(!pszConfFilename){
169 | r = FAIL;
170 | trace(ERROR, __LINE__, "[Authy] Wrong configuration filename.\n");
171 | goto EXIT;
172 | }
173 |
174 | if(!pszUsername || FAILED(checkUsername(pszUsername)) ) {
175 | r = FAIL;
176 | trace(ERROR, __LINE__, "[Authy] Username is invalid. Either empty or not a valid unix username.\n");
177 | goto EXIT;
178 | }
179 |
180 | fpConfFile = fopen(pszConfFilename, "r");
181 |
182 | if(NULL == fpConfFile) {
183 | trace(ERROR, __LINE__, "[Authy] Unable to read authy config file: %s.\n", pszConfFilename);
184 | trace(ERROR, __LINE__, "[Authy] Error %d: %s\n", errno, strerror(errno));
185 | r = FAIL;
186 | goto EXIT;
187 | }
188 |
189 | memset(columns, 0, sizeof(columns));
190 | while(NULL != fgets(line, ARRAY_SIZE(line), fpConfFile)){
191 | pch = strtok(line," \t");
192 | i = 0;
193 | while(pch != NULL && i < 3){
194 | columns[i] = removeSpaces(pch);
195 | pch = strtok (NULL, " \t"); //Go to the next token
196 | i++;
197 | }
198 | if(0 == strcasecmp(columns[0], pszUsername)){
199 | trace(DEBUG, __LINE__, "[Authy] Found column for pszUsername=%s column is %s\n", pszUsername, line);
200 | break;
201 | }
202 | memset(columns, 0, sizeof(columns));
203 | }
204 |
205 | if(columns[0] == NULL){
206 | r = FAIL;
207 | if (ALLOW_NON_TWO_FACTOR_LOGINS){
208 | r = OK;
209 | }
210 | trace(ERROR, __LINE__, "[Authy] Username %s was not found in Authy Config file.\n", pszUsername);
211 | goto EXIT;
212 | }
213 |
214 | if(columns[1] == NULL || isAnAuthyId(columns[1])== FALSE ){
215 | r = FAIL;
216 | trace(ERROR, __LINE__, "[Authy] AuthyID %s for Username %s is not valid. Authy ID's can only be numeric values\n", columns[1], pszUsername);
217 | goto EXIT;
218 | }
219 |
220 | trace(INFO, __LINE__, "[Authy] Found Authy ID: %s for username: %s\n", columns[1], pszUsername);
221 |
222 | *ppszAuthyId = strdup(columns[1]);
223 | if(!*ppszAuthyId){
224 | r = FAIL;
225 | trace(ERROR, __LINE__, "[Authy] Unable to allocate memory to copy AuthyID.\n");
226 | goto EXIT;
227 | }
228 |
229 |
230 | if(columns[2]){
231 | *ppszCommonName = strdup(columns[2]);
232 | if(!*ppszCommonName){
233 | trace(ERROR, __LINE__, "[Authy] Unable to allocate memory to copy CommonName.\n");
234 | }
235 | }
236 |
237 | r = OK;
238 |
239 | EXIT:
240 | if(fpConfFile){
241 | fclose(fpConfFile);
242 | }
243 | return r;
244 | }
245 |
--------------------------------------------------------------------------------
/src/authy_openvpn.c:
--------------------------------------------------------------------------------
1 | #ifdef WIN32
2 | #define WIN32_LEAN_AND_MEAN
3 |
4 | #include
5 | #include
6 | #include
7 | #define AUTHY_VPN_CONF "authy-vpn.conf"
8 | #pragma comment(lib, "ws2_32.lib")
9 |
10 | #else
11 | #define AUTHY_VPN_CONF "/etc/openvpn/authy/authy-vpn.conf"
12 | #endif
13 |
14 | #include
15 | #include
16 | #include
17 |
18 |
19 | #include "vendor/jsmn/jsmn.h"
20 |
21 | #include "openvpn-plugin.h"
22 | #include "authy_conf.h"
23 | #include "authy_api.h"
24 | #include "utils.h"
25 | #include "logger.h"
26 | #include "constants.h"
27 |
28 | /*
29 | * This state expects the following config line
30 | * plugin authy-openvpn.so APIURL APIKEY PAM
31 | * where APIURL should be something like https://api.authy.com/protected/json
32 | * APIKEY like d57d919d11e6b221c9bf6f7c882028f9
33 | * PAM pam
34 | * pam = 1;
35 | */
36 | struct plugin_context {
37 | char *pszApiUrl;
38 | char *pszApiKey;
39 | int bPAM;
40 | int verbosity;
41 | };
42 |
43 |
44 |
45 | // Description
46 | //
47 | // Given an environmental variable name, search
48 | // the envp array for its value, returning it
49 | //
50 | // Parameters
51 | //
52 | // name - Name of the enviromental
53 | // envp - The environment
54 | //
55 | // Returns
56 | //
57 | // The value of the env variable or NULL otherwise
58 | // if not found
59 | //
60 | /*
61 | * Given an environmental variable name, search
62 | * the envp array for its value, returning it
63 | * if found or NULL otherwise.
64 | * From openvpn/sample/sample-plugins/defer/simple.c
65 | */
66 | static char *
67 | getEnv(const char *name, const char *envp[])
68 | {
69 | if (envp)
70 | {
71 | int i;
72 | const int nameLength = strlen(name);
73 | for (i = 0; envp[i]; ++i)
74 | {
75 | if (!strncmp (envp[i], name, nameLength))
76 | {
77 | const char *cp = envp[i] + nameLength;
78 | if (*cp == '=')
79 | return (char *) cp + 1;
80 | }
81 | }
82 | }
83 | return NULL;
84 | }
85 |
86 |
87 |
88 | // Description
89 | //
90 | // Registers the functions that we want to intercept (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY)
91 | // and initializes the plugin context that holds the api url, api key and if we are using PAM
92 | //
93 | // Parameters
94 | //
95 | // type_mask - Name of the enviromental
96 | // argv - arguments
97 | // envp - The environment
98 | //
99 | // Returns
100 | //
101 | // The handle to the plugin
102 | //
103 | OPENVPN_EXPORT openvpn_plugin_handle_t
104 | openvpn_plugin_open_v1(unsigned int *type_mask,
105 | const char *argv[],
106 | const char *envp[])
107 | {
108 | /* Context Allocation */
109 | struct plugin_context *context;
110 |
111 | context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
112 |
113 | if(NULL == context){
114 | trace(ERROR, __LINE__, "[Authy] Failed to allocate context\n");
115 | return (openvpn_plugin_handle_t)FAIL;
116 | }
117 |
118 | /* Save the verbosite level from env */
119 | const char *verbosity = getEnv("verb", envp);
120 | if (verbosity){
121 | context->verbosity = (int)strtol(verbosity, (char **)NULL, 10);
122 | }
123 |
124 | if(argv[1] && argv[2])
125 | {
126 | trace(DEBUG, __LINE__, "Plugin path = %s\n", argv[0]);
127 | trace(DEBUG, __LINE__, "Api URL = %s, api key %s\n", argv[1], argv[2]);
128 | context->pszApiUrl = (char *) calloc(strlen(argv[1]) + 1, sizeof(char));
129 | strncpy(context->pszApiUrl, argv[1], strlen(argv[1]));
130 |
131 | context->pszApiKey = (char *) calloc(strlen(argv[2]) + 1, sizeof(char));
132 | strncpy(context->pszApiKey, argv[2], strlen(argv[2]));
133 |
134 | context->bPAM = 0;
135 |
136 | }
137 |
138 | if (argv[3] && strncmp(argv[3], "pam", 3) == 0){
139 | context->bPAM = 1;
140 | }
141 |
142 | /* Set type_mask, a.k.a callbacks that we want to intercept */
143 | *type_mask = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY);
144 |
145 | /* Cast and return the context */
146 | return (openvpn_plugin_handle_t) context;
147 |
148 | }
149 |
150 |
151 |
152 | // Description
153 | //
154 | // Goes through the response body looking for success. Else assumes failure
155 | //
156 | // Parameters
157 | //
158 | // pszRespone - Response body in json format
159 | //
160 | // Returns
161 | //
162 | // Standard RESULT
163 | //
164 | static RESULT
165 | responseWasSuccessful(char *pszAuthyResponse)
166 | {
167 | int cnt;
168 | jsmn_parser parser;
169 | jsmn_init(&parser);
170 | jsmntok_t tokens[20];
171 | jsmn_parse(&parser, pszAuthyResponse, tokens, 20);
172 |
173 | /* success isn't always on the same place, look until 19 because it
174 | shouldn't be the last one because it won't be a key */
175 | for (cnt = 0; cnt < 19; ++cnt)
176 | {
177 | if(strncmp(pszAuthyResponse + (tokens[cnt]).start, "success", (tokens[cnt]).end - (tokens[cnt]).start) == 0)
178 | {
179 | if(strncmp(pszAuthyResponse + (tokens[cnt+1]).start, "true", (tokens[cnt+1]).end - (tokens[cnt+1]).start) == 0){
180 | return OK;
181 | } else {
182 | return FAIL;
183 | }
184 | }
185 | }
186 | return FAIL;
187 | }
188 |
189 |
190 |
191 | // Description
192 | //
193 | // This is real core of the plugin
194 | // it handles the authentication agains Authy services
195 | // using the password field to obtain the OTP
196 | // and as other authentication plugins it sets its authenication status
197 | // to the control file
198 | //
199 | // Parameters
200 | //
201 | // context - Passed on by OpenVPN
202 | // argv - Passed by OpenVPN
203 | // envp - Passed by OpenVPN
204 | // Returns
205 | //
206 | // OPENVPN_PLUGIN_FUNC_SUCCESS: If authentication was succesful
207 | // OPENVPN_PLUGIN_FUNC_ERROR: If Auth was unsuccesful
208 | //
209 | static int
210 | authenticate(struct plugin_context *context,
211 | const char *argv[],
212 | const char *envp[])
213 | {
214 | int iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR; //auth failed
215 |
216 | RESULT r = FAIL;
217 | char *pszToken = NULL;
218 | char *pszAuthyResponse = NULL;
219 | char *pszCommonName = NULL;
220 | char *pszUsername = NULL;
221 | char *pszAuthyId = NULL;
222 | char *pszWantedCommonName = NULL;
223 | char *pszTokenStartPosition = NULL;
224 |
225 |
226 | trace(INFO, __LINE__, "[Authy] Authy Two-Factor Authentication started.\n");
227 |
228 | pszUsername = getEnv("username", envp);
229 | if(!pszUsername){
230 | trace(ERROR, __LINE__,"[Authy] ERROR: Username is NULL. Marking Auth as failure.\n");
231 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
232 | goto EXIT;
233 | }
234 |
235 | r = getAuthyIdAndCommonName(&pszAuthyId, &pszWantedCommonName,AUTHY_VPN_CONF, pszUsername);
236 | if(FAILED(r)){
237 | trace(ERROR,
238 | __LINE__,
239 | "[Authy] Authentication failed. Authy ID was not found for %s and Two-Factor Authentication is required.\n",
240 | pszUsername);
241 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
242 | goto EXIT;
243 | }
244 |
245 | // If AuthyId is null but function still returned success means that username was not found
246 | // but the config allows username to logon without to factor auth.
247 | if(SUCCESS(r) && !pszAuthyId){
248 |
249 | // Login without two factor is only available when using pam. Else, it doesn't make sense to have two factor authentication,
250 | // as anyone could login by finding an unexisting username.
251 | if(FALSE == context->bPAM) {
252 | trace(INFO,
253 | __LINE__,
254 | "[Authy] Authentication failed. Username not found in authy-vpn.conf and since pam is not enabled, two factor is enforced for all users.\n");
255 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
256 | goto EXIT;
257 | }
258 | trace(INFO,
259 | __LINE__,
260 | "[Authy] Warning: Authentication succeeded because username %s was not found in config file and Two-Factor is not mandatory.\n",
261 | pszUsername);
262 | iAuthResult = OPENVPN_PLUGIN_FUNC_SUCCESS;
263 | goto EXIT;
264 | }
265 |
266 | pszCommonName = getEnv("common_name", envp);
267 | if(pszWantedCommonName && FAILED(validateCommonName(pszCommonName, pszWantedCommonName)) ){
268 | trace(INFO,
269 | __LINE__,
270 | "[Authy] Authentication failed. CommonaName validation failed.\n");
271 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
272 | goto EXIT;
273 | }
274 |
275 | // From here we start authenticating the user token.
276 | pszToken = getEnv("password", envp);
277 | if(!pszToken){
278 | trace(ERROR, __LINE__, "[Authy] ERROR: Token is NULL. Marking Auth as failure.\n");
279 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
280 | goto EXIT;
281 | }
282 |
283 | pszAuthyResponse= calloc(CURL_MAX_WRITE_SIZE + 1, sizeof(char)); //allocate memory for Authy Response
284 | if(!pszAuthyResponse){
285 | trace(ERROR, __LINE__, "[Authy] ERROR: Unable to allocate memory for curl response. Marking Auth as failure.\n");
286 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
287 | goto EXIT;
288 | }
289 |
290 | // Here check if the user is trying to just request a phone call or an sms token.
291 | if (0 == strcmp(pszToken, "sms")){
292 |
293 | sms(context->pszApiUrl, pszAuthyId, context->pszApiKey, pszAuthyResponse);
294 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR; //doing sms always fails authentication
295 | goto EXIT;
296 | }
297 | else if(0 == strcmp(pszToken, "call")){
298 | call(context->pszApiUrl, pszAuthyId, context->pszApiKey, pszAuthyResponse);
299 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR; //doing phone call always fails authentication
300 | goto EXIT;
301 | }
302 |
303 | //PAM Authentication: password is concatenated and separated by TOKEN_PASSWORD_SEPARATOR
304 | if(TRUE == context->bPAM)
305 | {
306 | pszTokenStartPosition = strrchr(pszToken, TOKEN_PASSWORD_SEPARATOR);
307 | if (NULL == pszTokenStartPosition){
308 | trace(ERROR, __LINE__, "[Authy] PAM being used but password was not properly concatenated. Use [PASSWORD]-[TOKEN].\n");
309 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
310 | goto EXIT;
311 | }
312 | *pszTokenStartPosition = '\0'; // This 0 terminates the password so that pam gets only the password and not the token.
313 | pszToken = pszTokenStartPosition + 1;
314 | }
315 |
316 | if(FALSE == isTokenSafe(pszToken))
317 | {
318 | trace(ERROR, __LINE__, "[Authy] Token is not safe. Aborting.\n");
319 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
320 | goto EXIT;
321 | }
322 |
323 | trace(INFO, __LINE__, "[Authy] Authenticating username=%s, token=%s with AUTHY_ID=%s.\n", pszUsername, pszToken, pszAuthyId);
324 |
325 | r = verifyToken(context->pszApiUrl,
326 | pszToken,
327 | pszAuthyId,
328 | context->pszApiKey,
329 | pszAuthyResponse);
330 |
331 | if (SUCCESS(r) && SUCCESS(responseWasSuccessful(pszAuthyResponse))){
332 | iAuthResult = OPENVPN_PLUGIN_FUNC_SUCCESS; //Two-Factor Auth was succesful
333 | goto EXIT;
334 | }
335 |
336 | iAuthResult = OPENVPN_PLUGIN_FUNC_ERROR;
337 |
338 | EXIT:
339 |
340 | if(pszAuthyId) {cleanAndFree(pszAuthyId);}
341 | if(pszToken) { memset(pszToken, 0, (strlen(pszToken))); } // Cleanup the token. Password is left untouch.
342 | if(pszAuthyResponse) { cleanAndFree(pszAuthyResponse);};
343 |
344 | if(iAuthResult == OPENVPN_PLUGIN_FUNC_SUCCESS){
345 | trace(INFO, __LINE__, "[Authy] Auth finished. Result: Authy success for username %s.\n", pszUsername);
346 | }
347 | else{
348 | trace(INFO, __LINE__, "[Authy] Auth finished. Result: Authy failed for username %s.\n", pszUsername);
349 | }
350 |
351 | return iAuthResult;
352 | }
353 |
354 |
355 |
356 | // Description
357 | //
358 | // This is the function that is called when one of the registered functions of the vpn
359 | // are called
360 | //
361 | // Parameters
362 | //
363 | // pszRespone - Response body in json format
364 | //
365 | // Returns
366 | //
367 | // Standard 0 is success, or something else otherwise.
368 | //
369 | OPENVPN_EXPORT int
370 | openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
371 | {
372 | struct plugin_context *context = (struct plugin_context *) handle;
373 |
374 | if(type == OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY){
375 | return authenticate(context, argv, envp);
376 | }
377 |
378 | return OPENVPN_PLUGIN_FUNC_ERROR; //Auth FAILED
379 | }
380 |
381 | /*
382 | * Free the memory related with the context
383 | * This is call before openvpn stops the plugin
384 | */
385 | OPENVPN_EXPORT void
386 | openvpn_plugin_close_v1(openvpn_plugin_handle_t handle)
387 | {
388 | struct plugin_context *context = (struct plugin_context *) handle;
389 | cleanAndFree(context->pszApiUrl);
390 | cleanAndFree(context->pszApiKey);
391 | free(context);
392 | }
393 |
--------------------------------------------------------------------------------
/src/headers/authy_conf.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // authy-conf.h
8 | //
9 | // Abstract
10 | //
11 | // Handles Authy config file. Allows us to extract the Authy ID
12 | // given a username.
13 | //
14 | //
15 | // History
16 | //
17 | // 8/1/2013 dpalacio Created
18 | //
19 | //------------------------------------------------------------------------------
20 | #ifndef __AUTHY_CONF_H__
21 | #define __AUTHY_CONF_H__ 1
22 |
23 |
24 | #include
25 | #include
26 | #include
27 |
28 | #include "custom_types.h"
29 | #include "utils.h"
30 |
31 | RESULT
32 | getAuthyIdAndCommonName(__out char **ppszAuthyId,
33 | __out char **ppszCommonName,
34 | const char *pszConfFilename,
35 | const char *pszUsername
36 | );
37 |
38 | RESULT
39 | validateCommonName(const char *pszCommonName,
40 | const char *pszWantedCommonName);
41 | #endif
42 |
--------------------------------------------------------------------------------
/src/headers/constants.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // constants.h
8 | //
9 | // Abstract
10 | //
11 | // Define used constants throught the project.
12 | //
13 | //
14 | //
15 | // History
16 | //
17 | // 8/21/2013 dpalacio Created
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 |
22 | #ifndef __CONSTANTS_H__
23 | #define __CONSTANTS_H__ 1
24 |
25 | #define AUTHY_OPENVPN_VERSION "5.0"
26 |
27 | #define AUTHY_TOKEN_SIZE 7 // The size of our mobile tokens
28 | #define HARDWARE_TOKEN_SIZE 6 // Size of our hardware OTP's
29 |
30 | #define MAX_AUTHY_ID_LENGTH 50 // The max size an Authy ID can be
31 | #define MIN_TOKEN_LENGTH 6
32 | #define MAX_TOKEN_LENGTH 12
33 |
34 | #define UNKNOWN_VERSION_AGENT "AuthyOpenVPN/Unknown"
35 |
36 | #define TOKEN_PASSWORD_SEPARATOR '-'
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/headers/custom_types.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // custom_types.h
8 | //
9 | // Abstract
10 | //
11 | // defines new types used on the Authy OpenVPN project.
12 | //
13 | //
14 | //
15 | // History
16 | //
17 | // 8/1/2013 dpalacio Created
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 | #ifndef __CUSTOM_TYPES_H__
22 | #define __CUSTOM_TYPES_H__ 1
23 |
24 | #define __out //indicates that the argument will contain the result.
25 |
26 |
27 | #define BOOL short // Boolean type.
28 | #define TRUE 1
29 | #define FALSE 0
30 |
31 |
32 | #define FAILED(r) (((RESULT)(r)) != 0) // Test if result is different than 0
33 | #define SUCCESS(r)(((RESULT)(r)) == 0) //test if result is OK
34 |
35 | typedef enum
36 | {
37 | FAIL = -1,
38 | OK = 0,
39 | INVALID_ARG = -2,
40 | OUT_OF_MEMORY = -3
41 | } RESULT; // Standard result returned by most functions
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/headers/logger.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // logger.h
8 | //
9 | // Abstract
10 | //
11 | // Wraps a logger object based of levels of openvpn logs
12 | //
13 | // defaults to 4
14 | //
15 | //
16 | //
17 | // History
18 | //
19 | // 8/1/2013 dpalacio Created
20 | //
21 | //------------------------------------------------------------------------------
22 |
23 | #ifndef __LOGGER_H__
24 | #define __LOGGER_H__ 1
25 |
26 |
27 | #define INFO 4 // OpenVPN regular debug level
28 | #define ERROR 3
29 | #define DEBUG 5 //when compiled with DWITH_DEBUG
30 |
31 | void trace(const int level, const int line, const char *msg, ...);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/headers/openvpn-plugin.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenVPN -- An application to securely tunnel IP networks
3 | * over a single TCP/UDP port, with support for SSL/TLS-based
4 | * session authentication and key exchange,
5 | * packet encryption, packet authentication, and
6 | * packet compression.
7 | *
8 | * Copyright (C) 2002-2010 OpenVPN Technologies, Inc.
9 | *
10 | * This program is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License version 2
12 | * as published by the Free Software Foundation.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with this program (see the file COPYING included with this
21 | * distribution); if not, write to the Free Software Foundation, Inc.,
22 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | */
24 |
25 | #ifndef OPENVPN_PLUGIN_H_
26 | #define OPENVPN_PLUGIN_H_
27 |
28 | #define OPENVPN_PLUGIN_VERSION 3
29 |
30 | #ifdef ENABLE_SSL
31 | #ifdef ENABLE_CRYPTO_POLARSSL
32 | #include
33 | #ifndef __OPENVPN_X509_CERT_T_DECLARED
34 | #define __OPENVPN_X509_CERT_T_DECLARED
35 | typedef x509_cert openvpn_x509_cert_t;
36 | #endif
37 | #else
38 | #include
39 | #ifndef __OPENVPN_X509_CERT_T_DECLARED
40 | #define __OPENVPN_X509_CERT_T_DECLARED
41 | typedef X509 openvpn_x509_cert_t;
42 | #endif
43 | #endif
44 | #endif
45 |
46 | #include
47 |
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | /*
53 | * Plug-in types. These types correspond to the set of script callbacks
54 | * supported by OpenVPN.
55 | *
56 | * This is the general call sequence to expect when running in server mode:
57 | *
58 | * Initial Server Startup:
59 | *
60 | * FUNC: openvpn_plugin_open_v1
61 | * FUNC: openvpn_plugin_client_constructor_v1 (this is the top-level "generic"
62 | * client template)
63 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_UP
64 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ROUTE_UP
65 | *
66 | * New Client Connection:
67 | *
68 | * FUNC: openvpn_plugin_client_constructor_v1
69 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ENABLE_PF
70 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_VERIFY (called once for every cert
71 | * in the server chain)
72 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY
73 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_FINAL
74 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_IPCHANGE
75 | *
76 | * [If OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY returned OPENVPN_PLUGIN_FUNC_DEFERRED,
77 | * we don't proceed until authentication is verified via auth_control_file]
78 | *
79 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_CLIENT_CONNECT_V2
80 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_LEARN_ADDRESS
81 | *
82 | * [Client session ensues]
83 | *
84 | * For each "TLS soft reset", according to reneg-sec option (or similar):
85 | *
86 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ENABLE_PF
87 | *
88 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_VERIFY (called once for every cert
89 | * in the server chain)
90 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY
91 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_FINAL
92 | *
93 | * [If OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY returned OPENVPN_PLUGIN_FUNC_DEFERRED,
94 | * we expect that authentication is verified via auth_control_file within
95 | * the number of seconds defined by the "hand-window" option. Data channel traffic
96 | * will continue to flow uninterrupted during this period.]
97 | *
98 | * [Client session continues]
99 | *
100 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_CLIENT_DISCONNECT
101 | * FUNC: openvpn_plugin_client_destructor_v1
102 | *
103 | * [ some time may pass ]
104 | *
105 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_LEARN_ADDRESS (this coincides with a
106 | * lazy free of initial
107 | * learned addr object)
108 | * Server Shutdown:
109 | *
110 | * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_DOWN
111 | * FUNC: openvpn_plugin_client_destructor_v1 (top-level "generic" client)
112 | * FUNC: openvpn_plugin_close_v1
113 | */
114 | #define OPENVPN_PLUGIN_UP 0
115 | #define OPENVPN_PLUGIN_DOWN 1
116 | #define OPENVPN_PLUGIN_ROUTE_UP 2
117 | #define OPENVPN_PLUGIN_IPCHANGE 3
118 | #define OPENVPN_PLUGIN_TLS_VERIFY 4
119 | #define OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY 5
120 | #define OPENVPN_PLUGIN_CLIENT_CONNECT 6
121 | #define OPENVPN_PLUGIN_CLIENT_DISCONNECT 7
122 | #define OPENVPN_PLUGIN_LEARN_ADDRESS 8
123 | #define OPENVPN_PLUGIN_CLIENT_CONNECT_V2 9
124 | #define OPENVPN_PLUGIN_TLS_FINAL 10
125 | #define OPENVPN_PLUGIN_ENABLE_PF 11
126 | #define OPENVPN_PLUGIN_ROUTE_PREDOWN 12
127 | #define OPENVPN_PLUGIN_N 13
128 |
129 | /*
130 | * Build a mask out of a set of plug-in types.
131 | */
132 | #define OPENVPN_PLUGIN_MASK(x) (1<<(x))
133 |
134 | /*
135 | * A pointer to a plugin-defined object which contains
136 | * the object state.
137 | */
138 | typedef void *openvpn_plugin_handle_t;
139 |
140 | /*
141 | * Return value for openvpn_plugin_func_v1 function
142 | */
143 | #define OPENVPN_PLUGIN_FUNC_SUCCESS 0
144 | #define OPENVPN_PLUGIN_FUNC_ERROR 1
145 | #define OPENVPN_PLUGIN_FUNC_DEFERRED 2
146 |
147 | /*
148 | * For Windows (needs to be modified for MSVC)
149 | */
150 | #if defined(WIN32) && !defined(OPENVPN_PLUGIN_H)
151 | # define OPENVPN_EXPORT __declspec(dllexport)
152 | #else
153 | # define OPENVPN_EXPORT
154 | #endif
155 |
156 | /*
157 | * If OPENVPN_PLUGIN_H is defined, we know that we are being
158 | * included in an OpenVPN compile, rather than a plugin compile.
159 | */
160 | #ifdef OPENVPN_PLUGIN_H
161 |
162 | /*
163 | * We are compiling OpenVPN.
164 | */
165 | #define OPENVPN_PLUGIN_DEF typedef
166 | #define OPENVPN_PLUGIN_FUNC(name) (*name)
167 |
168 | #else
169 |
170 | /*
171 | * We are compiling plugin.
172 | */
173 | #define OPENVPN_PLUGIN_DEF OPENVPN_EXPORT
174 | #define OPENVPN_PLUGIN_FUNC(name) name
175 |
176 | #endif
177 |
178 | /*
179 | * Used by openvpn_plugin_func to return structured
180 | * data. The plugin should allocate all structure
181 | * instances, name strings, and value strings with
182 | * malloc, since OpenVPN will assume that it
183 | * can free the list by calling free() over the same.
184 | */
185 | struct openvpn_plugin_string_list
186 | {
187 | struct openvpn_plugin_string_list *next;
188 | char *name;
189 | char *value;
190 | };
191 |
192 |
193 | /* openvpn_plugin_{open,func}_v3() related structs */
194 |
195 | /* Defines version of the v3 plugin argument structs
196 | *
197 | * Whenever one or more of these structs are modified, this constant
198 | * must be updated. A changelog should be appended in this comment
199 | * as well, to make it easier to see what information is available
200 | * in the different versions.
201 | *
202 | * Version Comment
203 | * 1 Initial plugin v3 structures providing the same API as
204 | * the v2 plugin interface + X509 certificate information.
205 | *
206 | */
207 | #define OPENVPN_PLUGINv3_STRUCTVER 1
208 |
209 | /**
210 | * Definitions needed for the plug-in callback functions.
211 | */
212 | typedef enum
213 | {
214 | PLOG_ERR = (1 << 0), /* Error condition message */
215 | PLOG_WARN = (1 << 1), /* General warning message */
216 | PLOG_NOTE = (1 << 2), /* Informational message */
217 | PLOG_DEBUG = (1 << 3), /* Debug message, displayed if verb >= 7 */
218 |
219 | PLOG_ERRNO = (1 << 8), /* Add error description to message */
220 | PLOG_NOMUTE = (1 << 9), /* Mute setting does not apply for message */
221 |
222 | } openvpn_plugin_log_flags_t;
223 |
224 |
225 | #ifdef __GNUC__
226 | #if __USE_MINGW_ANSI_STDIO
227 | # define _ovpn_chk_fmt(a, b) __attribute__ ((format(gnu_printf, (a), (b))))
228 | #else
229 | # define _ovpn_chk_fmt(a, b) __attribute__ ((format(__printf__, (a), (b))))
230 | #endif
231 | #else
232 | # define _ovpn_chk_fmt(a, b)
233 | #endif
234 |
235 | typedef void (*plugin_log_t) (openvpn_plugin_log_flags_t flags,
236 | const char *plugin_name,
237 | const char *format, ...) _ovpn_chk_fmt(3, 4);
238 |
239 | typedef void (*plugin_vlog_t) (openvpn_plugin_log_flags_t flags,
240 | const char *plugin_name,
241 | const char *format,
242 | va_list arglist) _ovpn_chk_fmt(3, 0);
243 |
244 | #undef _ovpn_chk_fmt
245 |
246 | /**
247 | * Used by the openvpn_plugin_open_v3() function to pass callback
248 | * function pointers to the plug-in.
249 | *
250 | * plugin_log
251 | * plugin_vlog : Use these functions to add information to the OpenVPN log file.
252 | * Messages will only be displayed if the plugin_name parameter
253 | * is set. PLOG_DEBUG messages will only be displayed with plug-in
254 | * debug log verbosity (at the time of writing that's verb >= 7).
255 | */
256 | struct openvpn_plugin_callbacks
257 | {
258 | plugin_log_t plugin_log;
259 | plugin_vlog_t plugin_vlog;
260 | };
261 |
262 | /**
263 | * Arguments used to transport variables to the plug-in.
264 | * The struct openvpn_plugin_args_open_in is only used
265 | * by the openvpn_plugin_open_v3() function.
266 | *
267 | * STRUCT MEMBERS
268 | *
269 | * type_mask : Set by OpenVPN to the logical OR of all script
270 | * types which this version of OpenVPN supports.
271 | *
272 | * argv : a NULL-terminated array of options provided to the OpenVPN
273 | * "plug-in" directive. argv[0] is the dynamic library pathname.
274 | *
275 | * envp : a NULL-terminated array of OpenVPN-set environmental
276 | * variables in "name=value" format. Note that for security reasons,
277 | * these variables are not actually written to the "official"
278 | * environmental variable store of the process.
279 | *
280 | * callbacks : a pointer to the plug-in callback function struct.
281 | *
282 | */
283 | struct openvpn_plugin_args_open_in
284 | {
285 | const int type_mask;
286 | const char ** const argv;
287 | const char ** const envp;
288 | struct openvpn_plugin_callbacks *callbacks;
289 | };
290 |
291 |
292 | /**
293 | * Arguments used to transport variables from the plug-in back
294 | * to the OpenVPN process. The struct openvpn_plugin_args_open_return
295 | * is only used by the openvpn_plugin_open_v3() function.
296 | *
297 | * STRUCT MEMBERS
298 | *
299 | * *type_mask : The plug-in should set this value to the logical OR of all script
300 | * types which the plug-in wants to intercept. For example, if the
301 | * script wants to intercept the client-connect and client-disconnect
302 | * script types:
303 | *
304 | * *type_mask = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT)
305 | * | OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT)
306 | *
307 | * *handle : Pointer to a global plug-in context, created by the plug-in. This pointer
308 | * is passed on to the other plug-in calls.
309 | *
310 | * return_list : used to return data back to OpenVPN.
311 | *
312 | */
313 | struct openvpn_plugin_args_open_return
314 | {
315 | int type_mask;
316 | openvpn_plugin_handle_t *handle;
317 | struct openvpn_plugin_string_list **return_list;
318 | };
319 |
320 | /**
321 | * Arguments used to transport variables to and from the
322 | * plug-in. The struct openvpn_plugin_args_func is only used
323 | * by the openvpn_plugin_func_v3() function.
324 | *
325 | * STRUCT MEMBERS:
326 | *
327 | * type : one of the PLUGIN_x types.
328 | *
329 | * argv : a NULL-terminated array of "command line" options which
330 | * would normally be passed to the script. argv[0] is the dynamic
331 | * library pathname.
332 | *
333 | * envp : a NULL-terminated array of OpenVPN-set environmental
334 | * variables in "name=value" format. Note that for security reasons,
335 | * these variables are not actually written to the "official"
336 | * environmental variable store of the process.
337 | *
338 | * *handle : Pointer to a global plug-in context, created by the plug-in's openvpn_plugin_open_v3().
339 | *
340 | * *per_client_context : the per-client context pointer which was returned by
341 | * openvpn_plugin_client_constructor_v1, if defined.
342 | *
343 | * current_cert_depth : Certificate depth of the certificate being passed over (only if compiled with ENABLE_SSL defined)
344 | *
345 | * *current_cert : X509 Certificate object received from the client (only if compiled with ENABLE_SSL defined)
346 | *
347 | */
348 | struct openvpn_plugin_args_func_in
349 | {
350 | const int type;
351 | const char ** const argv;
352 | const char ** const envp;
353 | openvpn_plugin_handle_t handle;
354 | void *per_client_context;
355 | #ifdef ENABLE_SSL
356 | int current_cert_depth;
357 | openvpn_x509_cert_t *current_cert;
358 | #else
359 | int __current_cert_depth_disabled; /* Unused, for compatibility purposes only */
360 | void *__current_cert_disabled; /* Unused, for compatibility purposes only */
361 | #endif
362 | };
363 |
364 |
365 | /**
366 | * Arguments used to transport variables to and from the
367 | * plug-in. The struct openvpn_plugin_args_func is only used
368 | * by the openvpn_plugin_func_v3() function.
369 | *
370 | * STRUCT MEMBERS:
371 | *
372 | * return_list : used to return data back to OpenVPN for further processing/usage by
373 | * the OpenVPN executable.
374 | *
375 | */
376 | struct openvpn_plugin_args_func_return
377 | {
378 | struct openvpn_plugin_string_list **return_list;
379 | };
380 |
381 | /*
382 | * Multiple plugin modules can be cascaded, and modules can be
383 | * used in tandem with scripts. The order of operation is that
384 | * the module func() functions are called in the order that
385 | * the modules were specified in the config file. If a script
386 | * was specified as well, it will be called last. If the
387 | * return code of the module/script controls an authentication
388 | * function (such as tls-verify or auth-user-pass-verify), then
389 | * every module and script must return success (0) in order for
390 | * the connection to be authenticated.
391 | *
392 | * Notes:
393 | *
394 | * Plugins which use a privilege-separation model (by forking in
395 | * their initialization function before the main OpenVPN process
396 | * downgrades root privileges and/or executes a chroot) must
397 | * daemonize after a fork if the "daemon" environmental variable is
398 | * set. In addition, if the "daemon_log_redirect" variable is set,
399 | * the plugin should preserve stdout/stderr across the daemon()
400 | * syscall. See the daemonize() function in plugin/auth-pam/auth-pam.c
401 | * for an example.
402 | */
403 |
404 | /*
405 | * Prototypes for functions which OpenVPN plug-ins must define.
406 | */
407 |
408 | /*
409 | * FUNCTION: openvpn_plugin_open_v2
410 | *
411 | * REQUIRED: YES
412 | *
413 | * Called on initial plug-in load. OpenVPN will preserve plug-in state
414 | * across SIGUSR1 restarts but not across SIGHUP restarts. A SIGHUP reset
415 | * will cause the plugin to be closed and reopened.
416 | *
417 | * ARGUMENTS
418 | *
419 | * *type_mask : Set by OpenVPN to the logical OR of all script
420 | * types which this version of OpenVPN supports. The plug-in
421 | * should set this value to the logical OR of all script types
422 | * which the plug-in wants to intercept. For example, if the
423 | * script wants to intercept the client-connect and
424 | * client-disconnect script types:
425 | *
426 | * *type_mask = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT)
427 | * | OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT)
428 | *
429 | * argv : a NULL-terminated array of options provided to the OpenVPN
430 | * "plug-in" directive. argv[0] is the dynamic library pathname.
431 | *
432 | * envp : a NULL-terminated array of OpenVPN-set environmental
433 | * variables in "name=value" format. Note that for security reasons,
434 | * these variables are not actually written to the "official"
435 | * environmental variable store of the process.
436 | *
437 | * return_list : used to return data back to OpenVPN.
438 | *
439 | * RETURN VALUE
440 | *
441 | * An openvpn_plugin_handle_t value on success, NULL on failure
442 | */
443 | OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v2)
444 | (unsigned int *type_mask,
445 | const char *argv[],
446 | const char *envp[],
447 | struct openvpn_plugin_string_list **return_list);
448 |
449 | /*
450 | * FUNCTION: openvpn_plugin_func_v2
451 | *
452 | * Called to perform the work of a given script type.
453 | *
454 | * REQUIRED: YES
455 | *
456 | * ARGUMENTS
457 | *
458 | * handle : the openvpn_plugin_handle_t value which was returned by
459 | * openvpn_plugin_open.
460 | *
461 | * type : one of the PLUGIN_x types
462 | *
463 | * argv : a NULL-terminated array of "command line" options which
464 | * would normally be passed to the script. argv[0] is the dynamic
465 | * library pathname.
466 | *
467 | * envp : a NULL-terminated array of OpenVPN-set environmental
468 | * variables in "name=value" format. Note that for security reasons,
469 | * these variables are not actually written to the "official"
470 | * environmental variable store of the process.
471 | *
472 | * per_client_context : the per-client context pointer which was returned by
473 | * openvpn_plugin_client_constructor_v1, if defined.
474 | *
475 | * return_list : used to return data back to OpenVPN.
476 | *
477 | * RETURN VALUE
478 | *
479 | * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure
480 | *
481 | * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by
482 | * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY. This enables asynchronous
483 | * authentication where the plugin (or one of its agents) may indicate
484 | * authentication success/failure some number of seconds after the return
485 | * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single
486 | * char to the file named by auth_control_file in the environmental variable
487 | * list (envp).
488 | *
489 | * first char of auth_control_file:
490 | * '0' -- indicates auth failure
491 | * '1' -- indicates auth success
492 | *
493 | * OpenVPN will delete the auth_control_file after it goes out of scope.
494 | *
495 | * If an OPENVPN_PLUGIN_ENABLE_PF handler is defined and returns success
496 | * for a particular client instance, packet filtering will be enabled for that
497 | * instance. OpenVPN will then attempt to read the packet filter configuration
498 | * from the temporary file named by the environmental variable pf_file. This
499 | * file may be generated asynchronously and may be dynamically updated during the
500 | * client session, however the client will be blocked from sending or receiving
501 | * VPN tunnel packets until the packet filter file has been generated. OpenVPN
502 | * will periodically test the packet filter file over the life of the client
503 | * instance and reload when modified. OpenVPN will delete the packet filter file
504 | * when the client instance goes out of scope.
505 | *
506 | * Packet filter file grammar:
507 | *
508 | * [CLIENTS DROP|ACCEPT]
509 | * {+|-}common_name1
510 | * {+|-}common_name2
511 | * . . .
512 | * [SUBNETS DROP|ACCEPT]
513 | * {+|-}subnet1
514 | * {+|-}subnet2
515 | * . . .
516 | * [END]
517 | *
518 | * Subnet: IP-ADDRESS | IP-ADDRESS/NUM_NETWORK_BITS
519 | *
520 | * CLIENTS refers to the set of clients (by their common-name) which
521 | * this instance is allowed ('+') to connect to, or is excluded ('-')
522 | * from connecting to. Note that in the case of client-to-client
523 | * connections, such communication must be allowed by the packet filter
524 | * configuration files of both clients.
525 | *
526 | * SUBNETS refers to IP addresses or IP address subnets which this
527 | * instance may connect to ('+') or is excluded ('-') from connecting
528 | * to.
529 | *
530 | * DROP or ACCEPT defines default policy when there is no explicit match
531 | * for a common-name or subnet. The [END] tag must exist. A special
532 | * purpose tag called [KILL] will immediately kill the client instance.
533 | * A given client or subnet rule applies to both incoming and outgoing
534 | * packets.
535 | *
536 | * See plugin/defer/simple.c for an example on using asynchronous
537 | * authentication and client-specific packet filtering.
538 | */
539 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v2)
540 | (openvpn_plugin_handle_t handle,
541 | const int type,
542 | const char *argv[],
543 | const char *envp[],
544 | void *per_client_context,
545 | struct openvpn_plugin_string_list **return_list);
546 |
547 |
548 | /*
549 | * FUNCTION: openvpn_plugin_open_v3
550 | *
551 | * REQUIRED: YES
552 | *
553 | * Called on initial plug-in load. OpenVPN will preserve plug-in state
554 | * across SIGUSR1 restarts but not across SIGHUP restarts. A SIGHUP reset
555 | * will cause the plugin to be closed and reopened.
556 | *
557 | * ARGUMENTS
558 | *
559 | * version : fixed value, defines the API version of the OpenVPN plug-in API. The plug-in
560 | * should validate that this value is matching the OPENVPN_PLUGIN_VERSION value.
561 | *
562 | * arguments : Structure with all arguments available to the plug-in.
563 | *
564 | * retptr : used to return data back to OpenVPN.
565 | *
566 | * RETURN VALUE
567 | *
568 | * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure
569 | */
570 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v3)
571 | (const int version,
572 | struct openvpn_plugin_args_open_in const *arguments,
573 | struct openvpn_plugin_args_open_return *retptr);
574 |
575 | /*
576 | * FUNCTION: openvpn_plugin_func_v3
577 | *
578 | * Called to perform the work of a given script type.
579 | *
580 | * REQUIRED: YES
581 | *
582 | * ARGUMENTS
583 | *
584 | * version : fixed value, defines the API version of the OpenVPN plug-in API. The plug-in
585 | * should validate that this value is matching the OPENVPN_PLUGIN_VERSION value.
586 | *
587 | * handle : the openvpn_plugin_handle_t value which was returned by
588 | * openvpn_plugin_open.
589 | *
590 | * return_list : used to return data back to OpenVPN.
591 | *
592 | * RETURN VALUE
593 | *
594 | * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure
595 | *
596 | * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by
597 | * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY. This enables asynchronous
598 | * authentication where the plugin (or one of its agents) may indicate
599 | * authentication success/failure some number of seconds after the return
600 | * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single
601 | * char to the file named by auth_control_file in the environmental variable
602 | * list (envp).
603 | *
604 | * first char of auth_control_file:
605 | * '0' -- indicates auth failure
606 | * '1' -- indicates auth success
607 | *
608 | * OpenVPN will delete the auth_control_file after it goes out of scope.
609 | *
610 | * If an OPENVPN_PLUGIN_ENABLE_PF handler is defined and returns success
611 | * for a particular client instance, packet filtering will be enabled for that
612 | * instance. OpenVPN will then attempt to read the packet filter configuration
613 | * from the temporary file named by the environmental variable pf_file. This
614 | * file may be generated asynchronously and may be dynamically updated during the
615 | * client session, however the client will be blocked from sending or receiving
616 | * VPN tunnel packets until the packet filter file has been generated. OpenVPN
617 | * will periodically test the packet filter file over the life of the client
618 | * instance and reload when modified. OpenVPN will delete the packet filter file
619 | * when the client instance goes out of scope.
620 | *
621 | * Packet filter file grammar:
622 | *
623 | * [CLIENTS DROP|ACCEPT]
624 | * {+|-}common_name1
625 | * {+|-}common_name2
626 | * . . .
627 | * [SUBNETS DROP|ACCEPT]
628 | * {+|-}subnet1
629 | * {+|-}subnet2
630 | * . . .
631 | * [END]
632 | *
633 | * Subnet: IP-ADDRESS | IP-ADDRESS/NUM_NETWORK_BITS
634 | *
635 | * CLIENTS refers to the set of clients (by their common-name) which
636 | * this instance is allowed ('+') to connect to, or is excluded ('-')
637 | * from connecting to. Note that in the case of client-to-client
638 | * connections, such communication must be allowed by the packet filter
639 | * configuration files of both clients.
640 | *
641 | * SUBNETS refers to IP addresses or IP address subnets which this
642 | * instance may connect to ('+') or is excluded ('-') from connecting
643 | * to.
644 | *
645 | * DROP or ACCEPT defines default policy when there is no explicit match
646 | * for a common-name or subnet. The [END] tag must exist. A special
647 | * purpose tag called [KILL] will immediately kill the client instance.
648 | * A given client or subnet rule applies to both incoming and outgoing
649 | * packets.
650 | *
651 | * See plugin/defer/simple.c for an example on using asynchronous
652 | * authentication and client-specific packet filtering.
653 | */
654 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v3)
655 | (const int version,
656 | struct openvpn_plugin_args_func_in const *arguments,
657 | struct openvpn_plugin_args_func_return *retptr);
658 |
659 | /*
660 | * FUNCTION: openvpn_plugin_close_v1
661 | *
662 | * REQUIRED: YES
663 | *
664 | * ARGUMENTS
665 | *
666 | * handle : the openvpn_plugin_handle_t value which was returned by
667 | * openvpn_plugin_open.
668 | *
669 | * Called immediately prior to plug-in unload.
670 | */
671 | OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_close_v1)
672 | (openvpn_plugin_handle_t handle);
673 |
674 | /*
675 | * FUNCTION: openvpn_plugin_abort_v1
676 | *
677 | * REQUIRED: NO
678 | *
679 | * ARGUMENTS
680 | *
681 | * handle : the openvpn_plugin_handle_t value which was returned by
682 | * openvpn_plugin_open.
683 | *
684 | * Called when OpenVPN is in the process of aborting due to a fatal error.
685 | * Will only be called on an open context returned by a prior successful
686 | * openvpn_plugin_open callback.
687 | */
688 | OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_abort_v1)
689 | (openvpn_plugin_handle_t handle);
690 |
691 | /*
692 | * FUNCTION: openvpn_plugin_client_constructor_v1
693 | *
694 | * Called to allocate a per-client memory region, which
695 | * is then passed to the openvpn_plugin_func_v2 function.
696 | * This function is called every time the OpenVPN server
697 | * constructs a client instance object, which normally
698 | * occurs when a session-initiating packet is received
699 | * by a new client, even before the client has authenticated.
700 | *
701 | * This function should allocate the private memory needed
702 | * by the plugin to track individual OpenVPN clients, and
703 | * return a void * to this memory region.
704 | *
705 | * REQUIRED: NO
706 | *
707 | * ARGUMENTS
708 | *
709 | * handle : the openvpn_plugin_handle_t value which was returned by
710 | * openvpn_plugin_open.
711 | *
712 | * RETURN VALUE
713 | *
714 | * void * pointer to plugin's private per-client memory region, or NULL
715 | * if no memory region is required.
716 | */
717 | OPENVPN_PLUGIN_DEF void * OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_constructor_v1)
718 | (openvpn_plugin_handle_t handle);
719 |
720 | /*
721 | * FUNCTION: openvpn_plugin_client_destructor_v1
722 | *
723 | * This function is called on client instance object destruction.
724 | *
725 | * REQUIRED: NO
726 | *
727 | * ARGUMENTS
728 | *
729 | * handle : the openvpn_plugin_handle_t value which was returned by
730 | * openvpn_plugin_open.
731 | *
732 | * per_client_context : the per-client context pointer which was returned by
733 | * openvpn_plugin_client_constructor_v1, if defined.
734 | */
735 | OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_destructor_v1)
736 | (openvpn_plugin_handle_t handle, void *per_client_context);
737 |
738 | /*
739 | * FUNCTION: openvpn_plugin_select_initialization_point_v1
740 | *
741 | * Several different points exist in OpenVPN's initialization sequence where
742 | * the openvpn_plugin_open function can be called. While the default is
743 | * OPENVPN_PLUGIN_INIT_PRE_DAEMON, this function can be used to select a
744 | * different initialization point. For example, if your plugin needs to
745 | * return configuration parameters to OpenVPN, use
746 | * OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE.
747 | *
748 | * REQUIRED: NO
749 | *
750 | * RETURN VALUE:
751 | *
752 | * An OPENVPN_PLUGIN_INIT_x value.
753 | */
754 | #define OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE 1
755 | #define OPENVPN_PLUGIN_INIT_PRE_DAEMON 2 /* default */
756 | #define OPENVPN_PLUGIN_INIT_POST_DAEMON 3
757 | #define OPENVPN_PLUGIN_INIT_POST_UID_CHANGE 4
758 |
759 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_select_initialization_point_v1)
760 | (void);
761 |
762 | /*
763 | * FUNCTION: openvpn_plugin_min_version_required_v1
764 | *
765 | * This function is called by OpenVPN to query the minimum
766 | plugin interface version number required by the plugin.
767 | *
768 | * REQUIRED: NO
769 | *
770 | * RETURN VALUE
771 | *
772 | * The minimum OpenVPN plugin interface version number necessary to support
773 | * this plugin.
774 | */
775 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_min_version_required_v1)
776 | (void);
777 |
778 | /*
779 | * Deprecated functions which are still supported for backward compatibility.
780 | */
781 |
782 | OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v1)
783 | (unsigned int *type_mask,
784 | const char *argv[],
785 | const char *envp[]);
786 |
787 | OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v1)
788 | (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[]);
789 |
790 | #ifdef __cplusplus
791 | }
792 | #endif
793 |
794 | #endif /* OPENVPN_PLUGIN_H_ */
795 |
--------------------------------------------------------------------------------
/src/headers/utils.h:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // utils.h
8 | //
9 | // Abstract
10 | //
11 | // Utility functions
12 | //
13 | //
14 | // History
15 | //
16 | // 8/1/2013 dpalacio Created
17 | // 9/2/2015 serargz Edited
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 | #include
22 | #include "custom_types.h"
23 |
24 | #ifndef __UTILS_H__
25 | #define __UTILS_H__ 1
26 |
27 | #define ARRAY_SIZE(array) (sizeof(array))/(sizeof(*(array)))
28 |
29 | void cleanAndFree(void *pszPtr);
30 | char* removeSpaces(char *pszString);
31 | char* truncateAndSanitizeToken(char *pszString);
32 | char* getUserAgent();
33 | BOOL* isTokenSafe(char *pszToken);
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/src/logger.c:
--------------------------------------------------------------------------------
1 | #include
2 | //------------------------------------------------------------------------------
3 | //
4 | // Copyright (c) Authy Inc.
5 | //
6 | // Name
7 | //
8 | // logger.c
9 | //
10 | // Abstract
11 | //
12 | // Implements a re-usable logger
13 | //
14 | // registerUser
15 | // verifyToken
16 | // requestSMS
17 | //
18 | //
19 | //
20 | // History
21 | //
22 | // 8/2/2013 dpalacio Created
23 | //
24 | //------------------------------------------------------------------------------
25 |
26 | #include
27 | #include
28 |
29 |
30 | //
31 | // Description
32 | //
33 | // Prints a debug message on the openVPN log.
34 | // Include the line number if debug is set.
35 | //
36 | // Parameters
37 | //
38 | // line - The line number
39 | // msg - C formatted string with debug message
40 | //
41 | // Returns
42 | // void
43 | //
44 |
45 | #ifdef WITH_DEBUG
46 | static int g_logLevel = 5;
47 | #elif defined DERROR
48 | static int g_logLevel = 3;
49 | #else
50 | static int g_logLevel = 4;
51 | #endif
52 |
53 | void
54 | trace(const int level, const int line, const char *format, ...)
55 | {
56 | if(level <= g_logLevel)
57 | {
58 | va_list arg;
59 | va_start(arg, format);
60 | vfprintf(stderr, format, arg);
61 | va_end (arg);
62 | fflush(stderr);
63 | }
64 | }
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/utils.c:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Authy Inc.
4 | //
5 | // Name
6 | //
7 | // utils.c
8 | //
9 | // Abstract
10 | //
11 | // Utility Functions
12 | //
13 | //
14 | // History
15 | //
16 | // 8/1/2013 dpalacio Created
17 | // 9/2/2015 serargz Edited
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #ifndef WIN32
29 | #include "sys/utsname.h"
30 | #endif
31 |
32 | #include "openvpn-plugin.h"
33 | #include "constants.h"
34 | #include "custom_types.h"
35 | #include "logger.h"
36 |
37 | //
38 | // Description
39 | //
40 | // Memsets the pointer string to 0's and free's it if is not NULL.
41 | // Ignores it otherwise.
42 | //
43 | // Parameters
44 | //
45 | // pTarget - The pointer being free'd
46 | //
47 | // Returns
48 | // void
49 | //
50 | void
51 | cleanAndFree(void *pszPtr)
52 | {
53 | size_t length = 0;
54 | if(NULL != pszPtr) {
55 | length = strlen(pszPtr);
56 | memset(pszPtr, 0, sizeof(char)*length);
57 | free(pszPtr);
58 | }
59 | }
60 |
61 |
62 |
63 | // Description
64 | //
65 | // Remove spaces from a NULL terminated String
66 | //
67 | // Parameters
68 | //
69 | // pszString - A NULL terminated string containing spaces
70 | //
71 | // Returns
72 | //
73 | // a pointer to the beginning of the same string.
74 | //
75 | char *
76 | removeSpaces(char *pszString)
77 | {
78 | assert(pszString != NULL);
79 |
80 | char* i = pszString;
81 | char* j = pszString;
82 |
83 | while(*j != '\0')
84 | {
85 | if(*i != ' ' && *i != '\n' && *i != '\r' && *i != '\t'){
86 | *i = *j;
87 | i++;
88 | }
89 | j++;
90 | }
91 | *i = '\0';
92 |
93 | return pszString;
94 | }
95 |
96 | // Description
97 | //
98 | // Takes a token String entered by the end user and sanitizes
99 | // the input to make sure it's only numeric and is less than
100 | // 12 characters.
101 | //
102 | // Parameters
103 | //
104 | // pszString - A NULL terminated string
105 | //
106 | // Returns
107 | //
108 | // The sanitized token String.
109 | //
110 | BOOL
111 | isTokenSafe(char *pszToken)
112 | {
113 | size_t len = strlen(pszToken);
114 | BOOL isNumeric = TRUE;
115 |
116 | int i;
117 | for(i = 0; i < len; i++)
118 | {
119 | if(0 == isdigit(pszToken[i]))
120 | {
121 | isNumeric = FALSE;
122 | }
123 | }
124 |
125 | if(isNumeric && len >= MIN_TOKEN_LENGTH && len <= MAX_TOKEN_LENGTH) {
126 | return TRUE;
127 | }
128 |
129 | if(FALSE == isNumeric)
130 | {
131 | trace(INFO, __LINE__, "[Authy] Possible hack attempt, token is not numeric\n");
132 | }
133 |
134 | trace(INFO, __LINE__, "[Authy] Token length is invalid: %i\n", len);
135 | return FALSE;
136 | }
137 |
138 | // Description
139 | //
140 | // Generates a user agent string for the plugin.
141 | //
142 | // Returns
143 | //
144 | // A string with the user agent.
145 | char *
146 | getUserAgent()
147 | {
148 | size_t userAgentSize = 0;
149 | size_t systemInfoLength = 0;
150 | char *pszUserAgent = NULL;
151 | char *pszSystemInfo = NULL;
152 |
153 | #ifdef WIN32
154 | systemInfoLength = strlen("Windows");
155 | pszSystemInfo = calloc(systemInfoLength + 1, sizeof(char));
156 | if(NULL == pszSystemInfo)
157 | {
158 | trace(ERROR, __LINE__, "[Authy] Could not allocate space for System Info\n");
159 | goto EXIT;
160 | }
161 | snprintf(pszSystemInfo, systemInfoLength, "Windows");
162 | #else
163 | struct utsname unameData;
164 | if(-1 == uname(&unameData))
165 | {
166 | trace(INFO, __LINE__, "[Authy] Could not fetch system info\n");
167 | pszSystemInfo = calloc(strlen("Unknown") + 1, sizeof(char));
168 | if(NULL == pszSystemInfo)
169 | {
170 | trace(ERROR, __LINE__, "[Authy] Could not allocate space for System Info\n");
171 | goto EXIT;
172 | }
173 | snprintf(pszSystemInfo, strlen("Unknown"), "Unknown");
174 | }
175 | else
176 | {
177 | systemInfoLength = strlen(unameData.sysname) + strlen(" ") + strlen(unameData.release);
178 | pszSystemInfo = calloc(systemInfoLength + 1, sizeof(char));
179 | if(NULL == pszSystemInfo)
180 | {
181 | trace(ERROR, __LINE__, "[Authy] Could not allocate space for System Info\n");
182 | goto EXIT;
183 | }
184 | snprintf(pszSystemInfo, systemInfoLength, "%s %s", unameData.sysname, unameData.release);
185 | }
186 | #endif
187 |
188 | userAgentSize = strlen("AuthyOpenVPN/ ()") + strlen(AUTHY_OPENVPN_VERSION) + strlen(pszSystemInfo);
189 | pszUserAgent = calloc(userAgentSize + 1, sizeof(char));
190 | if(NULL == pszUserAgent)
191 | {
192 | trace(ERROR, __LINE__, "[Authy] Could not allocate space for User Agent\n");
193 | goto EXIT;
194 | }
195 |
196 | snprintf(pszUserAgent, userAgentSize, "AuthyOpenVPN/%s (%s)", AUTHY_OPENVPN_VERSION, pszSystemInfo );
197 |
198 | EXIT:
199 | if(pszSystemInfo)
200 | {
201 | free(pszSystemInfo);
202 | }
203 |
204 | return pszUserAgent;
205 | }
206 |
--------------------------------------------------------------------------------
/src/vendor/jsmn/jsmn.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "jsmn.h"
4 |
5 | /**
6 | * Allocates a fresh unused token from the token pull.
7 | */
8 | static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
9 | jsmntok_t *tokens, size_t num_tokens) {
10 | jsmntok_t *tok;
11 | if (parser->toknext >= num_tokens) {
12 | return NULL;
13 | }
14 | tok = &tokens[parser->toknext++];
15 | tok->start = tok->end = -1;
16 | tok->size = 0;
17 | #ifdef JSMN_PARENT_LINKS
18 | tok->parent = -1;
19 | #endif
20 | return tok;
21 | }
22 |
23 | /**
24 | * Fills token type and boundaries.
25 | */
26 | static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
27 | int start, int end) {
28 | token->type = type;
29 | token->start = start;
30 | token->end = end;
31 | token->size = 0;
32 | }
33 |
34 | /**
35 | * Fills next available token with JSON primitive.
36 | */
37 | static jsmnerr_t jsmn_parse_primitive(jsmn_parser *parser, const char *js,
38 | jsmntok_t *tokens, size_t num_tokens) {
39 | jsmntok_t *token;
40 | int start;
41 |
42 | start = parser->pos;
43 |
44 | for (; js[parser->pos] != '\0'; parser->pos++) {
45 | switch (js[parser->pos]) {
46 | #ifndef JSMN_STRICT
47 | /* In strict mode primitive must be followed by "," or "}" or "]" */
48 | case ':':
49 | #endif
50 | case '\t' : case '\r' : case '\n' : case ' ' :
51 | case ',' : case ']' : case '}' :
52 | goto found;
53 | }
54 | if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
55 | parser->pos = start;
56 | return JSMN_ERROR_INVAL;
57 | }
58 | }
59 | #ifdef JSMN_STRICT
60 | /* In strict mode primitive must be followed by a comma/object/array */
61 | parser->pos = start;
62 | return JSMN_ERROR_PART;
63 | #endif
64 |
65 | found:
66 | token = jsmn_alloc_token(parser, tokens, num_tokens);
67 | if (token == NULL) {
68 | parser->pos = start;
69 | return JSMN_ERROR_NOMEM;
70 | }
71 | jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
72 | #ifdef JSMN_PARENT_LINKS
73 | token->parent = parser->toksuper;
74 | #endif
75 | parser->pos--;
76 | return JSMN_SUCCESS;
77 | }
78 |
79 | /**
80 | * Filsl next token with JSON string.
81 | */
82 | static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js,
83 | jsmntok_t *tokens, size_t num_tokens) {
84 | jsmntok_t *token;
85 |
86 | int start = parser->pos;
87 |
88 | parser->pos++;
89 |
90 | /* Skip starting quote */
91 | for (; js[parser->pos] != '\0'; parser->pos++) {
92 | char c = js[parser->pos];
93 |
94 | /* Quote: end of string */
95 | if (c == '\"') {
96 | token = jsmn_alloc_token(parser, tokens, num_tokens);
97 | if (token == NULL) {
98 | parser->pos = start;
99 | return JSMN_ERROR_NOMEM;
100 | }
101 | jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
102 | #ifdef JSMN_PARENT_LINKS
103 | token->parent = parser->toksuper;
104 | #endif
105 | return JSMN_SUCCESS;
106 | }
107 |
108 | /* Backslash: Quoted symbol expected */
109 | if (c == '\\') {
110 | parser->pos++;
111 | switch (js[parser->pos]) {
112 | /* Allowed escaped symbols */
113 | case '\"': case '/' : case '\\' : case 'b' :
114 | case 'f' : case 'r' : case 'n' : case 't' :
115 | break;
116 | /* Allows escaped symbol \uXXXX */
117 | case 'u':
118 | /* TODO */
119 | break;
120 | /* Unexpected symbol */
121 | default:
122 | parser->pos = start;
123 | return JSMN_ERROR_INVAL;
124 | }
125 | }
126 | }
127 | parser->pos = start;
128 | return JSMN_ERROR_PART;
129 | }
130 |
131 | /**
132 | * Parse JSON string and fill tokens.
133 | */
134 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, jsmntok_t *tokens,
135 | unsigned int num_tokens) {
136 | jsmnerr_t r;
137 | int i;
138 | jsmntok_t *token;
139 |
140 | for (; js[parser->pos] != '\0'; parser->pos++) {
141 | char c;
142 | jsmntype_t type;
143 |
144 | c = js[parser->pos];
145 | switch (c) {
146 | case '{': case '[':
147 | token = jsmn_alloc_token(parser, tokens, num_tokens);
148 | if (token == NULL)
149 | return JSMN_ERROR_NOMEM;
150 | if (parser->toksuper != -1) {
151 | tokens[parser->toksuper].size++;
152 | #ifdef JSMN_PARENT_LINKS
153 | token->parent = parser->toksuper;
154 | #endif
155 | }
156 | token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
157 | token->start = parser->pos;
158 | parser->toksuper = parser->toknext - 1;
159 | break;
160 | case '}': case ']':
161 | type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
162 | #ifdef JSMN_PARENT_LINKS
163 | if (parser->toknext < 1) {
164 | return JSMN_ERROR_INVAL;
165 | }
166 | token = &tokens[parser->toknext - 1];
167 | for (;;) {
168 | if (token->start != -1 && token->end == -1) {
169 | if (token->type != type) {
170 | return JSMN_ERROR_INVAL;
171 | }
172 | token->end = parser->pos + 1;
173 | parser->toksuper = token->parent;
174 | break;
175 | }
176 | if (token->parent == -1) {
177 | break;
178 | }
179 | token = &tokens[token->parent];
180 | }
181 | #else
182 | for (i = parser->toknext - 1; i >= 0; i--) {
183 | token = &tokens[i];
184 | if (token->start != -1 && token->end == -1) {
185 | if (token->type != type) {
186 | return JSMN_ERROR_INVAL;
187 | }
188 | parser->toksuper = -1;
189 | token->end = parser->pos + 1;
190 | break;
191 | }
192 | }
193 | /* Error if unmatched closing bracket */
194 | if (i == -1) return JSMN_ERROR_INVAL;
195 | for (; i >= 0; i--) {
196 | token = &tokens[i];
197 | if (token->start != -1 && token->end == -1) {
198 | parser->toksuper = i;
199 | break;
200 | }
201 | }
202 | #endif
203 | break;
204 | case '\"':
205 | r = jsmn_parse_string(parser, js, tokens, num_tokens);
206 | if (r < 0) return r;
207 | if (parser->toksuper != -1)
208 | tokens[parser->toksuper].size++;
209 | break;
210 | case '\t' : case '\r' : case '\n' : case ':' : case ',': case ' ':
211 | break;
212 | #ifdef JSMN_STRICT
213 | /* In strict mode primitives are: numbers and booleans */
214 | case '-': case '0': case '1' : case '2': case '3' : case '4':
215 | case '5': case '6': case '7' : case '8': case '9':
216 | case 't': case 'f': case 'n' :
217 | #else
218 | /* In non-strict mode every unquoted value is a primitive */
219 | default:
220 | #endif
221 | r = jsmn_parse_primitive(parser, js, tokens, num_tokens);
222 | if (r < 0) return r;
223 | if (parser->toksuper != -1)
224 | tokens[parser->toksuper].size++;
225 | break;
226 |
227 | #ifdef JSMN_STRICT
228 | /* Unexpected char in strict mode */
229 | default:
230 | return JSMN_ERROR_INVAL;
231 | #endif
232 |
233 | }
234 | }
235 |
236 | for (i = parser->toknext - 1; i >= 0; i--) {
237 | /* Unmatched opened object or array */
238 | if (tokens[i].start != -1 && tokens[i].end == -1) {
239 | return JSMN_ERROR_PART;
240 | }
241 | }
242 |
243 | return JSMN_SUCCESS;
244 | }
245 |
246 | /**
247 | * Creates a new parser based over a given buffer with an array of tokens
248 | * available.
249 | */
250 | void jsmn_init(jsmn_parser *parser) {
251 | parser->pos = 0;
252 | parser->toknext = 0;
253 | parser->toksuper = -1;
254 | }
255 |
256 |
--------------------------------------------------------------------------------
/src/vendor/jsmn/jsmn.h:
--------------------------------------------------------------------------------
1 | #ifndef __JSMN_H_
2 | #define __JSMN_H_
3 |
4 | /**
5 | * JSON type identifier. Basic types are:
6 | * o Object
7 | * o Array
8 | * o String
9 | * o Other primitive: number, boolean (true/false) or null
10 | */
11 | typedef enum {
12 | JSMN_PRIMITIVE = 0,
13 | JSMN_OBJECT = 1,
14 | JSMN_ARRAY = 2,
15 | JSMN_STRING = 3
16 | } jsmntype_t;
17 |
18 | typedef enum {
19 | /* Not enough tokens were provided */
20 | JSMN_ERROR_NOMEM = -1,
21 | /* Invalid character inside JSON string */
22 | JSMN_ERROR_INVAL = -2,
23 | /* The string is not a full JSON packet, more bytes expected */
24 | JSMN_ERROR_PART = -3,
25 | /* Everything was fine */
26 | JSMN_SUCCESS = 0
27 | } jsmnerr_t;
28 |
29 | /**
30 | * JSON token description.
31 | * @param type type (object, array, string etc.)
32 | * @param start start position in JSON data string
33 | * @param end end position in JSON data string
34 | */
35 | typedef struct {
36 | jsmntype_t type;
37 | int start;
38 | int end;
39 | int size;
40 | #ifdef JSMN_PARENT_LINKS
41 | int parent;
42 | #endif
43 | } jsmntok_t;
44 |
45 | /**
46 | * JSON parser. Contains an array of token blocks available. Also stores
47 | * the string being parsed now and current position in that string
48 | */
49 | typedef struct {
50 | unsigned int pos; /* offset in the JSON string */
51 | int toknext; /* next token to allocate */
52 | int toksuper; /* superior token node, e.g parent object or array */
53 | } jsmn_parser;
54 |
55 | /**
56 | * Create JSON parser over an array of tokens
57 | */
58 | void jsmn_init(jsmn_parser *parser);
59 |
60 | /**
61 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
62 | * a single JSON object.
63 | */
64 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js,
65 | jsmntok_t *tokens, unsigned int num_tokens);
66 |
67 | #endif /* __JSMN_H_ */
68 |
--------------------------------------------------------------------------------
/test/authy-conf-test.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #define SUCCESS 0
7 | #define FAILURE 1
8 |
9 | void
10 | test(int expected, const char *psz_username,
11 | const char *psz_common_name, char *expected_authy_id,
12 | const char *msg)
13 | {
14 | static int kase = 0;
15 | printf("Test Case #%d\n", ++kase);
16 | char authy_id[8];
17 | int r = get_authy_ID("sample.conf", psz_username, psz_common_name,
18 | authy_id);
19 | if(r != expected)
20 | {
21 | puts(msg);
22 | return;
23 | }
24 | if(r == 0 && strcmp(expected_authy_id, authy_id) != 0)
25 | {
26 | puts(msg);
27 | return;
28 | }
29 | puts("runs as expected");
30 | }
31 |
32 | int main()
33 | {
34 |
35 | test(1, "\t\r\r\t", "\r\r\t", "so", "this just need to fail");
36 |
37 | test(1, NULL, NULL, NULL, "this must be an error if tries to check\
38 | for NULL user");
39 |
40 | test(1, NULL, NULL, NULL, "this must be an error if tries to check\
41 | for NULL user");
42 |
43 | test(1, NULL, NULL, NULL, "this must be an error if tries to check\
44 | for NULL user");
45 |
46 | test(1, "", NULL, NULL, "this must be an error if check for the\
47 | blank user \"\"");
48 |
49 | test(1, " ", NULL, NULL, "this must be an error if check for the\
50 | blank user \" \"");
51 |
52 | test(1, " ", NULL, NULL, "this must be an error if check for the\
53 | blank user \" \"");
54 |
55 | test(1, "\t\n", NULL, NULL, "this must be an error if check for the\
56 | blank user \"\\t\\n\"");
57 |
58 | test(1, "\r\n", NULL, NULL, "this must be an error if check for the\
59 | blank user \"\\r\\n\"");
60 |
61 | test(1, "david", "", "", "this must be an error because we don't\
62 | have a david in our configuration file");
63 |
64 | test(1, "sarcilav", "", "", "this must be an error because sarcilav\
65 | is using a common name in the configuration file");
66 |
67 | test(0, "sarcilav", "sebastian", "0000013", "this is the line\
68 | sarcilav sebastian 0000013");
69 |
70 | test(0, "sarciav", "cualquiercosa", "0000012", "this is the line\
71 | sarciav 0000012");
72 |
73 | test(0, "daniel", "daniel", "0000001", "this is the line daniel\
74 | daniel 0000001");
75 |
76 | test(1, "daniel", "sdaniel", "", "this must be an error because the\
77 | common name check fails");
78 |
79 | return 0;
80 | }
81 |
--------------------------------------------------------------------------------
/vendor-lib/TROUBLESHOOTING.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twilio/authy-openvpn/3e5dc738bfcf7a8745e3400fc085685b744a5ccf/vendor-lib/TROUBLESHOOTING.md
--------------------------------------------------------------------------------
/vendor-lib/include/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS = curl
2 |
3 | EXTRA_DIST = README
4 |
5 | AUTOMAKE_OPTIONS = foreign no-dependencies
6 |
--------------------------------------------------------------------------------
/vendor-lib/include/Makefile.in:
--------------------------------------------------------------------------------
1 | # Makefile.in generated by automake 1.9.6 from Makefile.am.
2 | # @configure_input@
3 |
4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5 | # 2003, 2004, 2005 Free Software Foundation, Inc.
6 | # This Makefile.in is free software; the Free Software Foundation
7 | # gives unlimited permission to copy and/or distribute it,
8 | # with or without modifications, as long as this notice is preserved.
9 |
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 | # PARTICULAR PURPOSE.
14 |
15 | @SET_MAKE@
16 | srcdir = @srcdir@
17 | top_srcdir = @top_srcdir@
18 | VPATH = @srcdir@
19 | pkgdatadir = $(datadir)/@PACKAGE@
20 | pkglibdir = $(libdir)/@PACKAGE@
21 | pkgincludedir = $(includedir)/@PACKAGE@
22 | top_builddir = ..
23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24 | INSTALL = @INSTALL@
25 | install_sh_DATA = $(install_sh) -c -m 644
26 | install_sh_PROGRAM = $(install_sh) -c
27 | install_sh_SCRIPT = $(install_sh) -c
28 | INSTALL_HEADER = $(INSTALL_DATA)
29 | transform = $(program_transform_name)
30 | NORMAL_INSTALL = :
31 | PRE_INSTALL = :
32 | POST_INSTALL = :
33 | NORMAL_UNINSTALL = :
34 | PRE_UNINSTALL = :
35 | POST_UNINSTALL = :
36 | build_triplet = @build@
37 | host_triplet = @host@
38 | subdir = include
39 | DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41 | am__aclocal_m4_deps = $(top_srcdir)/m4/curl-compilers.m4 \
42 | $(top_srcdir)/m4/curl-confopts.m4 \
43 | $(top_srcdir)/m4/curl-functions.m4 \
44 | $(top_srcdir)/m4/curl-override.m4 \
45 | $(top_srcdir)/m4/curl-reentrant.m4 \
46 | $(top_srcdir)/m4/curl-system.m4 $(top_srcdir)/m4/libtool.m4 \
47 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
48 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
49 | $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
50 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
51 | $(ACLOCAL_M4)
52 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
53 | CONFIG_HEADER = $(top_builddir)/lib/config.h \
54 | $(top_builddir)/src/config.h \
55 | $(top_builddir)/include/curl/curlbuild.h
56 | CONFIG_CLEAN_FILES =
57 | depcomp =
58 | am__depfiles_maybe =
59 | SOURCES =
60 | DIST_SOURCES =
61 | RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
62 | html-recursive info-recursive install-data-recursive \
63 | install-exec-recursive install-info-recursive \
64 | install-recursive installcheck-recursive installdirs-recursive \
65 | pdf-recursive ps-recursive uninstall-info-recursive \
66 | uninstall-recursive
67 | ETAGS = etags
68 | CTAGS = ctags
69 | DIST_SUBDIRS = $(SUBDIRS)
70 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
71 | ACLOCAL = @ACLOCAL@
72 | AMDEP_FALSE = @AMDEP_FALSE@
73 | AMDEP_TRUE = @AMDEP_TRUE@
74 | AMTAR = @AMTAR@
75 | AR = @AR@
76 | AS = @AS@
77 | AUTOCONF = @AUTOCONF@
78 | AUTOHEADER = @AUTOHEADER@
79 | AUTOMAKE = @AUTOMAKE@
80 | AWK = @AWK@
81 | CC = @CC@
82 | CCDEPMODE = @CCDEPMODE@
83 | CFLAGS = @CFLAGS@
84 | CPP = @CPP@
85 | CPPFLAGS = @CPPFLAGS@
86 | CROSSCOMPILING_FALSE = @CROSSCOMPILING_FALSE@
87 | CROSSCOMPILING_TRUE = @CROSSCOMPILING_TRUE@
88 | CURL_CA_BUNDLE = @CURL_CA_BUNDLE@
89 | CURL_DISABLE_DICT = @CURL_DISABLE_DICT@
90 | CURL_DISABLE_FILE = @CURL_DISABLE_FILE@
91 | CURL_DISABLE_FTP = @CURL_DISABLE_FTP@
92 | CURL_DISABLE_HTTP = @CURL_DISABLE_HTTP@
93 | CURL_DISABLE_LDAP = @CURL_DISABLE_LDAP@
94 | CURL_DISABLE_LDAPS = @CURL_DISABLE_LDAPS@
95 | CURL_DISABLE_PROXY = @CURL_DISABLE_PROXY@
96 | CURL_DISABLE_TELNET = @CURL_DISABLE_TELNET@
97 | CURL_DISABLE_TFTP = @CURL_DISABLE_TFTP@
98 | CURL_LIBS = @CURL_LIBS@
99 | CYGPATH_W = @CYGPATH_W@
100 | DEFS = @DEFS@
101 | DEPDIR = @DEPDIR@
102 | DLLTOOL = @DLLTOOL@
103 | DSYMUTIL = @DSYMUTIL@
104 | DUMPBIN = @DUMPBIN@
105 | ECHO_C = @ECHO_C@
106 | ECHO_N = @ECHO_N@
107 | ECHO_T = @ECHO_T@
108 | EGREP = @EGREP@
109 | EXEEXT = @EXEEXT@
110 | FGREP = @FGREP@
111 | GREP = @GREP@
112 | HAVE_ARES = @HAVE_ARES@
113 | HAVE_LIBZ = @HAVE_LIBZ@
114 | HAVE_LIBZ_FALSE = @HAVE_LIBZ_FALSE@
115 | HAVE_LIBZ_TRUE = @HAVE_LIBZ_TRUE@
116 | HAVE_PK11_CREATEGENERICOBJECT = @HAVE_PK11_CREATEGENERICOBJECT@
117 | IDN_ENABLED = @IDN_ENABLED@
118 | INSTALL_DATA = @INSTALL_DATA@
119 | INSTALL_PROGRAM = @INSTALL_PROGRAM@
120 | INSTALL_SCRIPT = @INSTALL_SCRIPT@
121 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
122 | IPV6_ENABLED = @IPV6_ENABLED@
123 | KRB4_ENABLED = @KRB4_ENABLED@
124 | LD = @LD@
125 | LDFLAGS = @LDFLAGS@
126 | LIBCURL_LIBS = @LIBCURL_LIBS@
127 | LIBOBJS = @LIBOBJS@
128 | LIBS = @LIBS@
129 | LIBTOOL = @LIBTOOL@
130 | LIPO = @LIPO@
131 | LN_S = @LN_S@
132 | LTLIBOBJS = @LTLIBOBJS@
133 | MAINT = @MAINT@
134 | MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
135 | MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
136 | MAKEINFO = @MAKEINFO@
137 | MANOPT = @MANOPT@
138 | MIMPURE_FALSE = @MIMPURE_FALSE@
139 | MIMPURE_TRUE = @MIMPURE_TRUE@
140 | NM = @NM@
141 | NMEDIT = @NMEDIT@
142 | NO_UNDEFINED_FALSE = @NO_UNDEFINED_FALSE@
143 | NO_UNDEFINED_TRUE = @NO_UNDEFINED_TRUE@
144 | NROFF = @NROFF@
145 | OBJDUMP = @OBJDUMP@
146 | OBJEXT = @OBJEXT@
147 | OTOOL = @OTOOL@
148 | OTOOL64 = @OTOOL64@
149 | PACKAGE = @PACKAGE@
150 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
151 | PACKAGE_NAME = @PACKAGE_NAME@
152 | PACKAGE_STRING = @PACKAGE_STRING@
153 | PACKAGE_TARNAME = @PACKAGE_TARNAME@
154 | PACKAGE_VERSION = @PACKAGE_VERSION@
155 | PATH = @PATH@
156 | PATH_SEPARATOR = @PATH_SEPARATOR@
157 | PERL = @PERL@
158 | PKGADD_NAME = @PKGADD_NAME@
159 | PKGADD_PKG = @PKGADD_PKG@
160 | PKGADD_VENDOR = @PKGADD_VENDOR@
161 | PKGCONFIG = @PKGCONFIG@
162 | RANDOM_FILE = @RANDOM_FILE@
163 | RANLIB = @RANLIB@
164 | REQUIRE_LIB_DEPS = @REQUIRE_LIB_DEPS@
165 | SED = @SED@
166 | SET_MAKE = @SET_MAKE@
167 | SHELL = @SHELL@
168 | SONAME_BUMP_FALSE = @SONAME_BUMP_FALSE@
169 | SONAME_BUMP_TRUE = @SONAME_BUMP_TRUE@
170 | SSL_ENABLED = @SSL_ENABLED@
171 | STATICLIB_FALSE = @STATICLIB_FALSE@
172 | STATICLIB_TRUE = @STATICLIB_TRUE@
173 | STRIP = @STRIP@
174 | SUPPORT_FEATURES = @SUPPORT_FEATURES@
175 | SUPPORT_PROTOCOLS = @SUPPORT_PROTOCOLS@
176 | TEST_SERVER_LIBS = @TEST_SERVER_LIBS@
177 | USE_GNUTLS = @USE_GNUTLS@
178 | USE_LIBSSH2 = @USE_LIBSSH2@
179 | USE_MANUAL_FALSE = @USE_MANUAL_FALSE@
180 | USE_MANUAL_TRUE = @USE_MANUAL_TRUE@
181 | USE_NSS = @USE_NSS@
182 | USE_SSLEAY = @USE_SSLEAY@
183 | USE_WINDOWS_SSPI = @USE_WINDOWS_SSPI@
184 | VERSION = @VERSION@
185 | VERSIONNUM = @VERSIONNUM@
186 | ac_ct_CC = @ac_ct_CC@
187 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
188 | am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
189 | am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
190 | am__include = @am__include@
191 | am__leading_dot = @am__leading_dot@
192 | am__quote = @am__quote@
193 | am__tar = @am__tar@
194 | am__untar = @am__untar@
195 | bindir = @bindir@
196 | build = @build@
197 | build_alias = @build_alias@
198 | build_cpu = @build_cpu@
199 | build_os = @build_os@
200 | build_vendor = @build_vendor@
201 | datadir = @datadir@
202 | datarootdir = @datarootdir@
203 | docdir = @docdir@
204 | dvidir = @dvidir@
205 | exec_prefix = @exec_prefix@
206 | host = @host@
207 | host_alias = @host_alias@
208 | host_cpu = @host_cpu@
209 | host_os = @host_os@
210 | host_vendor = @host_vendor@
211 | htmldir = @htmldir@
212 | includedir = @includedir@
213 | infodir = @infodir@
214 | install_sh = @install_sh@
215 | libdir = @libdir@
216 | libexecdir = @libexecdir@
217 | libext = @libext@
218 | localedir = @localedir@
219 | localstatedir = @localstatedir@
220 | lt_ECHO = @lt_ECHO@
221 | mandir = @mandir@
222 | mkdir_p = @mkdir_p@
223 | oldincludedir = @oldincludedir@
224 | pdfdir = @pdfdir@
225 | prefix = @prefix@
226 | program_transform_name = @program_transform_name@
227 | psdir = @psdir@
228 | sbindir = @sbindir@
229 | sharedstatedir = @sharedstatedir@
230 | subdirs = @subdirs@
231 | sysconfdir = @sysconfdir@
232 | target_alias = @target_alias@
233 | SUBDIRS = curl
234 | EXTRA_DIST = README
235 | AUTOMAKE_OPTIONS = foreign no-dependencies
236 | all: all-recursive
237 |
238 | .SUFFIXES:
239 | $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
240 | @for dep in $?; do \
241 | case '$(am__configure_deps)' in \
242 | *$$dep*) \
243 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
244 | && exit 0; \
245 | exit 1;; \
246 | esac; \
247 | done; \
248 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
249 | cd $(top_srcdir) && \
250 | $(AUTOMAKE) --foreign include/Makefile
251 | .PRECIOUS: Makefile
252 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
253 | @case '$?' in \
254 | *config.status*) \
255 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
256 | *) \
257 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
258 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
259 | esac;
260 |
261 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
262 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
263 |
264 | $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
265 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
266 | $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
267 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
268 |
269 | mostlyclean-libtool:
270 | -rm -f *.lo
271 |
272 | clean-libtool:
273 | -rm -rf .libs _libs
274 |
275 | distclean-libtool:
276 | -rm -f libtool
277 | uninstall-info-am:
278 |
279 | # This directory's subdirectories are mostly independent; you can cd
280 | # into them and run `make' without going through this Makefile.
281 | # To change the values of `make' variables: instead of editing Makefiles,
282 | # (1) if the variable is set in `config.status', edit `config.status'
283 | # (which will cause the Makefiles to be regenerated when you run `make');
284 | # (2) otherwise, pass the desired values on the `make' command line.
285 | $(RECURSIVE_TARGETS):
286 | @failcom='exit 1'; \
287 | for f in x $$MAKEFLAGS; do \
288 | case $$f in \
289 | *=* | --[!k]*);; \
290 | *k*) failcom='fail=yes';; \
291 | esac; \
292 | done; \
293 | dot_seen=no; \
294 | target=`echo $@ | sed s/-recursive//`; \
295 | list='$(SUBDIRS)'; for subdir in $$list; do \
296 | echo "Making $$target in $$subdir"; \
297 | if test "$$subdir" = "."; then \
298 | dot_seen=yes; \
299 | local_target="$$target-am"; \
300 | else \
301 | local_target="$$target"; \
302 | fi; \
303 | (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
304 | || eval $$failcom; \
305 | done; \
306 | if test "$$dot_seen" = "no"; then \
307 | $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
308 | fi; test -z "$$fail"
309 |
310 | mostlyclean-recursive clean-recursive distclean-recursive \
311 | maintainer-clean-recursive:
312 | @failcom='exit 1'; \
313 | for f in x $$MAKEFLAGS; do \
314 | case $$f in \
315 | *=* | --[!k]*);; \
316 | *k*) failcom='fail=yes';; \
317 | esac; \
318 | done; \
319 | dot_seen=no; \
320 | case "$@" in \
321 | distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
322 | *) list='$(SUBDIRS)' ;; \
323 | esac; \
324 | rev=''; for subdir in $$list; do \
325 | if test "$$subdir" = "."; then :; else \
326 | rev="$$subdir $$rev"; \
327 | fi; \
328 | done; \
329 | rev="$$rev ."; \
330 | target=`echo $@ | sed s/-recursive//`; \
331 | for subdir in $$rev; do \
332 | echo "Making $$target in $$subdir"; \
333 | if test "$$subdir" = "."; then \
334 | local_target="$$target-am"; \
335 | else \
336 | local_target="$$target"; \
337 | fi; \
338 | (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
339 | || eval $$failcom; \
340 | done && test -z "$$fail"
341 | tags-recursive:
342 | list='$(SUBDIRS)'; for subdir in $$list; do \
343 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
344 | done
345 | ctags-recursive:
346 | list='$(SUBDIRS)'; for subdir in $$list; do \
347 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
348 | done
349 |
350 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
351 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
352 | unique=`for i in $$list; do \
353 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
354 | done | \
355 | $(AWK) ' { files[$$0] = 1; } \
356 | END { for (i in files) print i; }'`; \
357 | mkid -fID $$unique
358 | tags: TAGS
359 |
360 | TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
361 | $(TAGS_FILES) $(LISP)
362 | tags=; \
363 | here=`pwd`; \
364 | if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
365 | include_option=--etags-include; \
366 | empty_fix=.; \
367 | else \
368 | include_option=--include; \
369 | empty_fix=; \
370 | fi; \
371 | list='$(SUBDIRS)'; for subdir in $$list; do \
372 | if test "$$subdir" = .; then :; else \
373 | test ! -f $$subdir/TAGS || \
374 | tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
375 | fi; \
376 | done; \
377 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
378 | unique=`for i in $$list; do \
379 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
380 | done | \
381 | $(AWK) ' { files[$$0] = 1; } \
382 | END { for (i in files) print i; }'`; \
383 | if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
384 | test -n "$$unique" || unique=$$empty_fix; \
385 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
386 | $$tags $$unique; \
387 | fi
388 | ctags: CTAGS
389 | CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
390 | $(TAGS_FILES) $(LISP)
391 | tags=; \
392 | here=`pwd`; \
393 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
394 | unique=`for i in $$list; do \
395 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
396 | done | \
397 | $(AWK) ' { files[$$0] = 1; } \
398 | END { for (i in files) print i; }'`; \
399 | test -z "$(CTAGS_ARGS)$$tags$$unique" \
400 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
401 | $$tags $$unique
402 |
403 | GTAGS:
404 | here=`$(am__cd) $(top_builddir) && pwd` \
405 | && cd $(top_srcdir) \
406 | && gtags -i $(GTAGS_ARGS) $$here
407 |
408 | distclean-tags:
409 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
410 |
411 | distdir: $(DISTFILES)
412 | @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
413 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
414 | list='$(DISTFILES)'; for file in $$list; do \
415 | case $$file in \
416 | $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
417 | $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
418 | esac; \
419 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
420 | dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
421 | if test "$$dir" != "$$file" && test "$$dir" != "."; then \
422 | dir="/$$dir"; \
423 | $(mkdir_p) "$(distdir)$$dir"; \
424 | else \
425 | dir=''; \
426 | fi; \
427 | if test -d $$d/$$file; then \
428 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
429 | cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
430 | fi; \
431 | cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
432 | else \
433 | test -f $(distdir)/$$file \
434 | || cp -p $$d/$$file $(distdir)/$$file \
435 | || exit 1; \
436 | fi; \
437 | done
438 | list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
439 | if test "$$subdir" = .; then :; else \
440 | test -d "$(distdir)/$$subdir" \
441 | || $(mkdir_p) "$(distdir)/$$subdir" \
442 | || exit 1; \
443 | distdir=`$(am__cd) $(distdir) && pwd`; \
444 | top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
445 | (cd $$subdir && \
446 | $(MAKE) $(AM_MAKEFLAGS) \
447 | top_distdir="$$top_distdir" \
448 | distdir="$$distdir/$$subdir" \
449 | distdir) \
450 | || exit 1; \
451 | fi; \
452 | done
453 | check-am: all-am
454 | check: check-recursive
455 | all-am: Makefile
456 | installdirs: installdirs-recursive
457 | installdirs-am:
458 | install: install-recursive
459 | install-exec: install-exec-recursive
460 | install-data: install-data-recursive
461 | uninstall: uninstall-recursive
462 |
463 | install-am: all-am
464 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
465 |
466 | installcheck: installcheck-recursive
467 | install-strip:
468 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
469 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
470 | `test -z '$(STRIP)' || \
471 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
472 | mostlyclean-generic:
473 |
474 | clean-generic:
475 |
476 | distclean-generic:
477 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
478 |
479 | maintainer-clean-generic:
480 | @echo "This command is intended for maintainers to use"
481 | @echo "it deletes files that may require special tools to rebuild."
482 | clean: clean-recursive
483 |
484 | clean-am: clean-generic clean-libtool mostlyclean-am
485 |
486 | distclean: distclean-recursive
487 | -rm -f Makefile
488 | distclean-am: clean-am distclean-generic distclean-libtool \
489 | distclean-tags
490 |
491 | dvi: dvi-recursive
492 |
493 | dvi-am:
494 |
495 | html: html-recursive
496 |
497 | info: info-recursive
498 |
499 | info-am:
500 |
501 | install-data-am:
502 |
503 | install-exec-am:
504 |
505 | install-info: install-info-recursive
506 |
507 | install-man:
508 |
509 | installcheck-am:
510 |
511 | maintainer-clean: maintainer-clean-recursive
512 | -rm -f Makefile
513 | maintainer-clean-am: distclean-am maintainer-clean-generic
514 |
515 | mostlyclean: mostlyclean-recursive
516 |
517 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool
518 |
519 | pdf: pdf-recursive
520 |
521 | pdf-am:
522 |
523 | ps: ps-recursive
524 |
525 | ps-am:
526 |
527 | uninstall-am: uninstall-info-am
528 |
529 | uninstall-info: uninstall-info-recursive
530 |
531 | .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
532 | clean clean-generic clean-libtool clean-recursive ctags \
533 | ctags-recursive distclean distclean-generic distclean-libtool \
534 | distclean-recursive distclean-tags distdir dvi dvi-am html \
535 | html-am info info-am install install-am install-data \
536 | install-data-am install-exec install-exec-am install-info \
537 | install-info-am install-man install-strip installcheck \
538 | installcheck-am installdirs installdirs-am maintainer-clean \
539 | maintainer-clean-generic maintainer-clean-recursive \
540 | mostlyclean mostlyclean-generic mostlyclean-libtool \
541 | mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
542 | uninstall uninstall-am uninstall-info-am
543 |
544 | # Tell versions [3.59,3.63) of GNU make to not export all variables.
545 | # Otherwise a system limit (for SysV at least) may be exceeded.
546 | .NOEXPORT:
547 |
--------------------------------------------------------------------------------
/vendor-lib/include/README:
--------------------------------------------------------------------------------
1 | _ _ ____ _
2 | ___| | | | _ \| |
3 | / __| | | | |_) | |
4 | | (__| |_| | _ <| |___
5 | \___|\___/|_| \_\_____|
6 |
7 | Include files for libcurl, external users.
8 |
9 | They're all placed in the curl subdirectory here for better fit in any kind
10 | of environment. You must include files from here using...
11 |
12 | #include
13 |
14 | ... style and point the compiler's include path to the directory holding the
15 | curl subdirectory. It makes it more likely to survive future modifications.
16 |
17 | NOTE FOR LIBCURL HACKERS
18 |
19 | The following notes apply to libcurl version 7.19.0 and later.
20 |
21 | * The distributed curl/curlbuild.h file is only intended to be used on systems
22 | which can not run the also distributed configure script.
23 |
24 | * The distributed curlbuild.h file is generated as a copy of curlbuild.h.dist
25 | when the libcurl source code distribution archive file is originally created.
26 |
27 | * If you check out from CVS on a non-configure platform, you must run the
28 | appropriate buildconf* script to set up curlbuild.h and other local files
29 | before being able of compiling the library.
30 |
31 | * On systems capable of running the configure script, the configure process
32 | will overwrite the distributed include/curl/curlbuild.h file with one that
33 | is suitable and specific to the library being configured and built, which
34 | is generated from the include/curl/curlbuild.h.in template file.
35 |
36 | * If you intend to distribute an already compiled libcurl library you _MUST_
37 | also distribute along with it the generated curl/curlbuild.h which has been
38 | used to compile it. Otherwise the library will be of no use for the users of
39 | the library that you have built. It is _your_ responsability to provide this
40 | file. No one at the cURL project can know how you have built the library.
41 |
42 | * File curl/curlbuild.h includes platform and configuration dependant info,
43 | and must not be modified by anyone. Configure script generates it for you.
44 |
45 | * We cannot assume anything else but very basic compiler features being
46 | present. While libcurl requires an ANSI C compiler to build, some of the
47 | earlier ANSI compilers clearly can't deal with some preprocessor operators.
48 |
49 | * Newlines must remain unix-style for older compilers' sake.
50 |
51 | * Comments must be written in the old-style /* unnested C-fashion */
52 |
53 | To figure out how to do good and portable checks for features, operating
54 | systems or specific hardwarare, a very good resource is Bjorn Reese's
55 | collection at http://predef.sf.net/
56 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/Makefile.am:
--------------------------------------------------------------------------------
1 | pkginclude_HEADERS = \
2 | curl.h curlver.h easy.h mprintf.h stdcheaders.h types.h multi.h \
3 | typecheck-gcc.h curlbuild.h curlrules.h
4 |
5 | pkgincludedir= $(includedir)/curl
6 |
7 | # curlbuild.h does not exist in the CVS tree. When the original libcurl
8 | # source code distribution archive file is created, curlbuild.h.dist is
9 | # renamed to curlbuild.h and included in the tarball so that it can be
10 | # used directly on non-configure systems.
11 | #
12 | # The distributed curlbuild.h will be overwritten on configure systems
13 | # when the configure script runs, with one that is suitable and specific
14 | # to the library being configured and built.
15 | #
16 | # curlbuild.h.in is the distributed template file from which the configure
17 | # script creates curlbuild.h at library configuration time, overwiting the
18 | # one included in the distribution archive.
19 | #
20 | # curlbuild.h.dist is not included in the source code distribution archive.
21 |
22 | EXTRA_DIST = curlbuild.h.in
23 |
24 | DISTCLEANFILES = curlbuild.h
25 |
26 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/Makefile.in:
--------------------------------------------------------------------------------
1 | # Makefile.in generated by automake 1.9.6 from Makefile.am.
2 | # @configure_input@
3 |
4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5 | # 2003, 2004, 2005 Free Software Foundation, Inc.
6 | # This Makefile.in is free software; the Free Software Foundation
7 | # gives unlimited permission to copy and/or distribute it,
8 | # with or without modifications, as long as this notice is preserved.
9 |
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 | # PARTICULAR PURPOSE.
14 |
15 | @SET_MAKE@
16 |
17 | srcdir = @srcdir@
18 | top_srcdir = @top_srcdir@
19 | VPATH = @srcdir@
20 | pkgdatadir = $(datadir)/@PACKAGE@
21 | pkglibdir = $(libdir)/@PACKAGE@
22 | top_builddir = ../..
23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24 | INSTALL = @INSTALL@
25 | install_sh_DATA = $(install_sh) -c -m 644
26 | install_sh_PROGRAM = $(install_sh) -c
27 | install_sh_SCRIPT = $(install_sh) -c
28 | INSTALL_HEADER = $(INSTALL_DATA)
29 | transform = $(program_transform_name)
30 | NORMAL_INSTALL = :
31 | PRE_INSTALL = :
32 | POST_INSTALL = :
33 | NORMAL_UNINSTALL = :
34 | PRE_UNINSTALL = :
35 | POST_UNINSTALL = :
36 | build_triplet = @build@
37 | host_triplet = @host@
38 | subdir = include/curl
39 | DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
40 | $(srcdir)/Makefile.in $(srcdir)/curlbuild.h.in
41 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42 | am__aclocal_m4_deps = $(top_srcdir)/m4/curl-compilers.m4 \
43 | $(top_srcdir)/m4/curl-confopts.m4 \
44 | $(top_srcdir)/m4/curl-functions.m4 \
45 | $(top_srcdir)/m4/curl-override.m4 \
46 | $(top_srcdir)/m4/curl-reentrant.m4 \
47 | $(top_srcdir)/m4/curl-system.m4 $(top_srcdir)/m4/libtool.m4 \
48 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
49 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
50 | $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
51 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
52 | $(ACLOCAL_M4)
53 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
54 | CONFIG_HEADER = $(top_builddir)/lib/config.h \
55 | $(top_builddir)/src/config.h curlbuild.h
56 | CONFIG_CLEAN_FILES =
57 | SOURCES =
58 | DIST_SOURCES =
59 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
60 | am__vpath_adj = case $$p in \
61 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
62 | *) f=$$p;; \
63 | esac;
64 | am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
65 | am__installdirs = "$(DESTDIR)$(pkgincludedir)"
66 | pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
67 | HEADERS = $(pkginclude_HEADERS)
68 | ETAGS = etags
69 | CTAGS = ctags
70 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
71 | pkgincludedir = $(includedir)/curl
72 | ACLOCAL = @ACLOCAL@
73 | AMDEP_FALSE = @AMDEP_FALSE@
74 | AMDEP_TRUE = @AMDEP_TRUE@
75 | AMTAR = @AMTAR@
76 | AR = @AR@
77 | AS = @AS@
78 | AUTOCONF = @AUTOCONF@
79 | AUTOHEADER = @AUTOHEADER@
80 | AUTOMAKE = @AUTOMAKE@
81 | AWK = @AWK@
82 | CC = @CC@
83 | CCDEPMODE = @CCDEPMODE@
84 | CFLAGS = @CFLAGS@
85 | CPP = @CPP@
86 | CPPFLAGS = @CPPFLAGS@
87 | CROSSCOMPILING_FALSE = @CROSSCOMPILING_FALSE@
88 | CROSSCOMPILING_TRUE = @CROSSCOMPILING_TRUE@
89 | CURL_CA_BUNDLE = @CURL_CA_BUNDLE@
90 | CURL_DISABLE_DICT = @CURL_DISABLE_DICT@
91 | CURL_DISABLE_FILE = @CURL_DISABLE_FILE@
92 | CURL_DISABLE_FTP = @CURL_DISABLE_FTP@
93 | CURL_DISABLE_HTTP = @CURL_DISABLE_HTTP@
94 | CURL_DISABLE_LDAP = @CURL_DISABLE_LDAP@
95 | CURL_DISABLE_LDAPS = @CURL_DISABLE_LDAPS@
96 | CURL_DISABLE_PROXY = @CURL_DISABLE_PROXY@
97 | CURL_DISABLE_TELNET = @CURL_DISABLE_TELNET@
98 | CURL_DISABLE_TFTP = @CURL_DISABLE_TFTP@
99 | CURL_LIBS = @CURL_LIBS@
100 | CYGPATH_W = @CYGPATH_W@
101 | DEFS = @DEFS@
102 | DEPDIR = @DEPDIR@
103 | DLLTOOL = @DLLTOOL@
104 | DSYMUTIL = @DSYMUTIL@
105 | DUMPBIN = @DUMPBIN@
106 | ECHO_C = @ECHO_C@
107 | ECHO_N = @ECHO_N@
108 | ECHO_T = @ECHO_T@
109 | EGREP = @EGREP@
110 | EXEEXT = @EXEEXT@
111 | FGREP = @FGREP@
112 | GREP = @GREP@
113 | HAVE_ARES = @HAVE_ARES@
114 | HAVE_LIBZ = @HAVE_LIBZ@
115 | HAVE_LIBZ_FALSE = @HAVE_LIBZ_FALSE@
116 | HAVE_LIBZ_TRUE = @HAVE_LIBZ_TRUE@
117 | HAVE_PK11_CREATEGENERICOBJECT = @HAVE_PK11_CREATEGENERICOBJECT@
118 | IDN_ENABLED = @IDN_ENABLED@
119 | INSTALL_DATA = @INSTALL_DATA@
120 | INSTALL_PROGRAM = @INSTALL_PROGRAM@
121 | INSTALL_SCRIPT = @INSTALL_SCRIPT@
122 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
123 | IPV6_ENABLED = @IPV6_ENABLED@
124 | KRB4_ENABLED = @KRB4_ENABLED@
125 | LD = @LD@
126 | LDFLAGS = @LDFLAGS@
127 | LIBCURL_LIBS = @LIBCURL_LIBS@
128 | LIBOBJS = @LIBOBJS@
129 | LIBS = @LIBS@
130 | LIBTOOL = @LIBTOOL@
131 | LIPO = @LIPO@
132 | LN_S = @LN_S@
133 | LTLIBOBJS = @LTLIBOBJS@
134 | MAINT = @MAINT@
135 | MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
136 | MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
137 | MAKEINFO = @MAKEINFO@
138 | MANOPT = @MANOPT@
139 | MIMPURE_FALSE = @MIMPURE_FALSE@
140 | MIMPURE_TRUE = @MIMPURE_TRUE@
141 | NM = @NM@
142 | NMEDIT = @NMEDIT@
143 | NO_UNDEFINED_FALSE = @NO_UNDEFINED_FALSE@
144 | NO_UNDEFINED_TRUE = @NO_UNDEFINED_TRUE@
145 | NROFF = @NROFF@
146 | OBJDUMP = @OBJDUMP@
147 | OBJEXT = @OBJEXT@
148 | OTOOL = @OTOOL@
149 | OTOOL64 = @OTOOL64@
150 | PACKAGE = @PACKAGE@
151 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
152 | PACKAGE_NAME = @PACKAGE_NAME@
153 | PACKAGE_STRING = @PACKAGE_STRING@
154 | PACKAGE_TARNAME = @PACKAGE_TARNAME@
155 | PACKAGE_VERSION = @PACKAGE_VERSION@
156 | PATH = @PATH@
157 | PATH_SEPARATOR = @PATH_SEPARATOR@
158 | PERL = @PERL@
159 | PKGADD_NAME = @PKGADD_NAME@
160 | PKGADD_PKG = @PKGADD_PKG@
161 | PKGADD_VENDOR = @PKGADD_VENDOR@
162 | PKGCONFIG = @PKGCONFIG@
163 | RANDOM_FILE = @RANDOM_FILE@
164 | RANLIB = @RANLIB@
165 | REQUIRE_LIB_DEPS = @REQUIRE_LIB_DEPS@
166 | SED = @SED@
167 | SET_MAKE = @SET_MAKE@
168 | SHELL = @SHELL@
169 | SONAME_BUMP_FALSE = @SONAME_BUMP_FALSE@
170 | SONAME_BUMP_TRUE = @SONAME_BUMP_TRUE@
171 | SSL_ENABLED = @SSL_ENABLED@
172 | STATICLIB_FALSE = @STATICLIB_FALSE@
173 | STATICLIB_TRUE = @STATICLIB_TRUE@
174 | STRIP = @STRIP@
175 | SUPPORT_FEATURES = @SUPPORT_FEATURES@
176 | SUPPORT_PROTOCOLS = @SUPPORT_PROTOCOLS@
177 | TEST_SERVER_LIBS = @TEST_SERVER_LIBS@
178 | USE_GNUTLS = @USE_GNUTLS@
179 | USE_LIBSSH2 = @USE_LIBSSH2@
180 | USE_MANUAL_FALSE = @USE_MANUAL_FALSE@
181 | USE_MANUAL_TRUE = @USE_MANUAL_TRUE@
182 | USE_NSS = @USE_NSS@
183 | USE_SSLEAY = @USE_SSLEAY@
184 | USE_WINDOWS_SSPI = @USE_WINDOWS_SSPI@
185 | VERSION = @VERSION@
186 | VERSIONNUM = @VERSIONNUM@
187 | ac_ct_CC = @ac_ct_CC@
188 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
189 | am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
190 | am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
191 | am__include = @am__include@
192 | am__leading_dot = @am__leading_dot@
193 | am__quote = @am__quote@
194 | am__tar = @am__tar@
195 | am__untar = @am__untar@
196 | bindir = @bindir@
197 | build = @build@
198 | build_alias = @build_alias@
199 | build_cpu = @build_cpu@
200 | build_os = @build_os@
201 | build_vendor = @build_vendor@
202 | datadir = @datadir@
203 | datarootdir = @datarootdir@
204 | docdir = @docdir@
205 | dvidir = @dvidir@
206 | exec_prefix = @exec_prefix@
207 | host = @host@
208 | host_alias = @host_alias@
209 | host_cpu = @host_cpu@
210 | host_os = @host_os@
211 | host_vendor = @host_vendor@
212 | htmldir = @htmldir@
213 | includedir = @includedir@
214 | infodir = @infodir@
215 | install_sh = @install_sh@
216 | libdir = @libdir@
217 | libexecdir = @libexecdir@
218 | libext = @libext@
219 | localedir = @localedir@
220 | localstatedir = @localstatedir@
221 | lt_ECHO = @lt_ECHO@
222 | mandir = @mandir@
223 | mkdir_p = @mkdir_p@
224 | oldincludedir = @oldincludedir@
225 | pdfdir = @pdfdir@
226 | prefix = @prefix@
227 | program_transform_name = @program_transform_name@
228 | psdir = @psdir@
229 | sbindir = @sbindir@
230 | sharedstatedir = @sharedstatedir@
231 | subdirs = @subdirs@
232 | sysconfdir = @sysconfdir@
233 | target_alias = @target_alias@
234 | pkginclude_HEADERS = \
235 | curl.h curlver.h easy.h mprintf.h stdcheaders.h types.h multi.h \
236 | typecheck-gcc.h curlbuild.h curlrules.h
237 |
238 |
239 | # curlbuild.h does not exist in the CVS tree. When the original libcurl
240 | # source code distribution archive file is created, curlbuild.h.dist is
241 | # renamed to curlbuild.h and included in the tarball so that it can be
242 | # used directly on non-configure systems.
243 | #
244 | # The distributed curlbuild.h will be overwritten on configure systems
245 | # when the configure script runs, with one that is suitable and specific
246 | # to the library being configured and built.
247 | #
248 | # curlbuild.h.in is the distributed template file from which the configure
249 | # script creates curlbuild.h at library configuration time, overwiting the
250 | # one included in the distribution archive.
251 | #
252 | # curlbuild.h.dist is not included in the source code distribution archive.
253 | EXTRA_DIST = curlbuild.h.in
254 | DISTCLEANFILES = curlbuild.h
255 | all: curlbuild.h
256 | $(MAKE) $(AM_MAKEFLAGS) all-am
257 |
258 | .SUFFIXES:
259 | $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
260 | @for dep in $?; do \
261 | case '$(am__configure_deps)' in \
262 | *$$dep*) \
263 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
264 | && exit 0; \
265 | exit 1;; \
266 | esac; \
267 | done; \
268 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/curl/Makefile'; \
269 | cd $(top_srcdir) && \
270 | $(AUTOMAKE) --foreign include/curl/Makefile
271 | .PRECIOUS: Makefile
272 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
273 | @case '$?' in \
274 | *config.status*) \
275 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
276 | *) \
277 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
278 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
279 | esac;
280 |
281 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
282 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
283 |
284 | $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
285 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
286 | $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
287 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
288 |
289 | curlbuild.h: stamp-h3
290 | @if test ! -f $@; then \
291 | rm -f stamp-h3; \
292 | $(MAKE) stamp-h3; \
293 | else :; fi
294 |
295 | stamp-h3: $(srcdir)/curlbuild.h.in $(top_builddir)/config.status
296 | @rm -f stamp-h3
297 | cd $(top_builddir) && $(SHELL) ./config.status include/curl/curlbuild.h
298 | $(srcdir)/curlbuild.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
299 | cd $(top_srcdir) && $(AUTOHEADER)
300 | rm -f stamp-h3
301 | touch $@
302 |
303 | distclean-hdr:
304 | -rm -f curlbuild.h stamp-h3
305 |
306 | mostlyclean-libtool:
307 | -rm -f *.lo
308 |
309 | clean-libtool:
310 | -rm -rf .libs _libs
311 |
312 | distclean-libtool:
313 | -rm -f libtool
314 | uninstall-info-am:
315 | install-pkgincludeHEADERS: $(pkginclude_HEADERS)
316 | @$(NORMAL_INSTALL)
317 | test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
318 | @list='$(pkginclude_HEADERS)'; for p in $$list; do \
319 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
320 | f=$(am__strip_dir) \
321 | echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
322 | $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
323 | done
324 |
325 | uninstall-pkgincludeHEADERS:
326 | @$(NORMAL_UNINSTALL)
327 | @list='$(pkginclude_HEADERS)'; for p in $$list; do \
328 | f=$(am__strip_dir) \
329 | echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
330 | rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
331 | done
332 |
333 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
334 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
335 | unique=`for i in $$list; do \
336 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
337 | done | \
338 | $(AWK) ' { files[$$0] = 1; } \
339 | END { for (i in files) print i; }'`; \
340 | mkid -fID $$unique
341 | tags: TAGS
342 |
343 | TAGS: $(HEADERS) $(SOURCES) curlbuild.h.in $(TAGS_DEPENDENCIES) \
344 | $(TAGS_FILES) $(LISP)
345 | tags=; \
346 | here=`pwd`; \
347 | list='$(SOURCES) $(HEADERS) curlbuild.h.in $(LISP) $(TAGS_FILES)'; \
348 | unique=`for i in $$list; do \
349 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
350 | done | \
351 | $(AWK) ' { files[$$0] = 1; } \
352 | END { for (i in files) print i; }'`; \
353 | if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
354 | test -n "$$unique" || unique=$$empty_fix; \
355 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
356 | $$tags $$unique; \
357 | fi
358 | ctags: CTAGS
359 | CTAGS: $(HEADERS) $(SOURCES) curlbuild.h.in $(TAGS_DEPENDENCIES) \
360 | $(TAGS_FILES) $(LISP)
361 | tags=; \
362 | here=`pwd`; \
363 | list='$(SOURCES) $(HEADERS) curlbuild.h.in $(LISP) $(TAGS_FILES)'; \
364 | unique=`for i in $$list; do \
365 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
366 | done | \
367 | $(AWK) ' { files[$$0] = 1; } \
368 | END { for (i in files) print i; }'`; \
369 | test -z "$(CTAGS_ARGS)$$tags$$unique" \
370 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
371 | $$tags $$unique
372 |
373 | GTAGS:
374 | here=`$(am__cd) $(top_builddir) && pwd` \
375 | && cd $(top_srcdir) \
376 | && gtags -i $(GTAGS_ARGS) $$here
377 |
378 | distclean-tags:
379 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
380 |
381 | distdir: $(DISTFILES)
382 | @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
383 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
384 | list='$(DISTFILES)'; for file in $$list; do \
385 | case $$file in \
386 | $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
387 | $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
388 | esac; \
389 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
390 | dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
391 | if test "$$dir" != "$$file" && test "$$dir" != "."; then \
392 | dir="/$$dir"; \
393 | $(mkdir_p) "$(distdir)$$dir"; \
394 | else \
395 | dir=''; \
396 | fi; \
397 | if test -d $$d/$$file; then \
398 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
399 | cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
400 | fi; \
401 | cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
402 | else \
403 | test -f $(distdir)/$$file \
404 | || cp -p $$d/$$file $(distdir)/$$file \
405 | || exit 1; \
406 | fi; \
407 | done
408 | check-am: all-am
409 | check: check-am
410 | all-am: Makefile $(HEADERS) curlbuild.h
411 | installdirs:
412 | for dir in "$(DESTDIR)$(pkgincludedir)"; do \
413 | test -z "$$dir" || $(mkdir_p) "$$dir"; \
414 | done
415 | install: install-am
416 | install-exec: install-exec-am
417 | install-data: install-data-am
418 | uninstall: uninstall-am
419 |
420 | install-am: all-am
421 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
422 |
423 | installcheck: installcheck-am
424 | install-strip:
425 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
426 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
427 | `test -z '$(STRIP)' || \
428 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
429 | mostlyclean-generic:
430 |
431 | clean-generic:
432 |
433 | distclean-generic:
434 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
435 | -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
436 |
437 | maintainer-clean-generic:
438 | @echo "This command is intended for maintainers to use"
439 | @echo "it deletes files that may require special tools to rebuild."
440 | clean: clean-am
441 |
442 | clean-am: clean-generic clean-libtool mostlyclean-am
443 |
444 | distclean: distclean-am
445 | -rm -f Makefile
446 | distclean-am: clean-am distclean-generic distclean-hdr \
447 | distclean-libtool distclean-tags
448 |
449 | dvi: dvi-am
450 |
451 | dvi-am:
452 |
453 | html: html-am
454 |
455 | info: info-am
456 |
457 | info-am:
458 |
459 | install-data-am: install-pkgincludeHEADERS
460 |
461 | install-exec-am:
462 |
463 | install-info: install-info-am
464 |
465 | install-man:
466 |
467 | installcheck-am:
468 |
469 | maintainer-clean: maintainer-clean-am
470 | -rm -f Makefile
471 | maintainer-clean-am: distclean-am maintainer-clean-generic
472 |
473 | mostlyclean: mostlyclean-am
474 |
475 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool
476 |
477 | pdf: pdf-am
478 |
479 | pdf-am:
480 |
481 | ps: ps-am
482 |
483 | ps-am:
484 |
485 | uninstall-am: uninstall-info-am uninstall-pkgincludeHEADERS
486 |
487 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
488 | clean-libtool ctags distclean distclean-generic distclean-hdr \
489 | distclean-libtool distclean-tags distdir dvi dvi-am html \
490 | html-am info info-am install install-am install-data \
491 | install-data-am install-exec install-exec-am install-info \
492 | install-info-am install-man install-pkgincludeHEADERS \
493 | install-strip installcheck installcheck-am installdirs \
494 | maintainer-clean maintainer-clean-generic mostlyclean \
495 | mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
496 | tags uninstall uninstall-am uninstall-info-am \
497 | uninstall-pkgincludeHEADERS
498 |
499 | # Tell versions [3.59,3.63) of GNU make to not export all variables.
500 | # Otherwise a system limit (for SysV at least) may be exceeded.
501 | .NOEXPORT:
502 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/curlbuild.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_CURLBUILD_H
2 | #define __CURL_CURLBUILD_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: curlbuild.h.dist,v 1.16 2009-01-16 08:36:41 bagder Exp $
24 | ***************************************************************************/
25 |
26 | /* ================================================================ */
27 | /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
28 | /* ================================================================ */
29 |
30 | /*
31 | * NOTE 1:
32 | * -------
33 | *
34 | * See file include/curl/curlbuild.h.in, run configure, and forget
35 | * that this file exists it is only used for non-configure systems.
36 | * But you can keep reading if you want ;-)
37 | *
38 | */
39 |
40 | /* ================================================================ */
41 | /* NOTES FOR NON-CONFIGURE SYSTEMS */
42 | /* ================================================================ */
43 |
44 | /*
45 | * NOTE 1:
46 | * -------
47 | *
48 | * Nothing in this file is intended to be modified or adjusted by the
49 | * curl library user nor by the curl library builder.
50 | *
51 | * If you think that something actually needs to be changed, adjusted
52 | * or fixed in this file, then, report it on the libcurl development
53 | * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
54 | *
55 | * Try to keep one section per platform, compiler and architecture,
56 | * otherwise, if an existing section is reused for a different one and
57 | * later on the original is adjusted, probably the piggybacking one can
58 | * be adversely changed.
59 | *
60 | * In order to differentiate between platforms/compilers/architectures
61 | * use only compiler built in predefined preprocessor symbols.
62 | *
63 | * This header file shall only export symbols which are 'curl' or 'CURL'
64 | * prefixed, otherwise public name space would be polluted.
65 | *
66 | * NOTE 2:
67 | * -------
68 | *
69 | * For any given platform/compiler curl_off_t must be typedef'ed to a
70 | * 64-bit wide signed integral data type. The width of this data type
71 | * must remain constant and independant of any possible large file
72 | * support settings.
73 | *
74 | * As an exception to the above, curl_off_t shall be typedef'ed to a
75 | * 32-bit wide signed integral data type if there is no 64-bit type.
76 | *
77 | * As a general rule, curl_off_t shall not be mapped to off_t. This
78 | * rule shall only be violated if off_t is the only 64-bit data type
79 | * available and the size of off_t is independant of large file support
80 | * settings. Keep your build on the safe side avoiding an off_t gating.
81 | * If you have a 64-bit off_t then take for sure that another 64-bit
82 | * data type exists, dig deeper and you will find it.
83 | *
84 | * NOTE 3:
85 | * -------
86 | *
87 | * Right now you might be staring at file include/curl/curlbuild.h.dist or
88 | * at file include/curl/curlbuild.h, this is due to the following reason:
89 | * file include/curl/curlbuild.h.dist is renamed to include/curl/curlbuild.h
90 | * when the libcurl source code distribution archive file is created.
91 | *
92 | * File include/curl/curlbuild.h.dist is not included in the distribution
93 | * archive. File include/curl/curlbuild.h is not present in the CVS tree.
94 | *
95 | * The distributed include/curl/curlbuild.h file is only intended to be used
96 | * on systems which can not run the also distributed configure script.
97 | *
98 | * On systems capable of running the configure script, the configure process
99 | * will overwrite the distributed include/curl/curlbuild.h file with one that
100 | * is suitable and specific to the library being configured and built, which
101 | * is generated from the include/curl/curlbuild.h.in template file.
102 | *
103 | * If you check out from CVS on a non-configure platform, you must run the
104 | * appropriate buildconf* script to set up curlbuild.h and other local files.
105 | *
106 | */
107 |
108 | /* ================================================================ */
109 | /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
110 | /* ================================================================ */
111 |
112 | #ifdef CURL_SIZEOF_LONG
113 | # error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
114 | Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
115 | #endif
116 |
117 | #ifdef CURL_TYPEOF_CURL_OFF_T
118 | # error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
119 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
120 | #endif
121 |
122 | #ifdef CURL_FORMAT_CURL_OFF_T
123 | # error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
124 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined
125 | #endif
126 |
127 | #ifdef CURL_FORMAT_CURL_OFF_TU
128 | # error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
129 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined
130 | #endif
131 |
132 | #ifdef CURL_FORMAT_OFF_T
133 | # error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
134 | Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined
135 | #endif
136 |
137 | #ifdef CURL_SIZEOF_CURL_OFF_T
138 | # error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
139 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined
140 | #endif
141 |
142 | #ifdef CURL_SUFFIX_CURL_OFF_T
143 | # error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
144 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined
145 | #endif
146 |
147 | #ifdef CURL_SUFFIX_CURL_OFF_TU
148 | # error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
149 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined
150 | #endif
151 |
152 | /* ================================================================ */
153 | /* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */
154 | /* ================================================================ */
155 |
156 | #if defined(__DJGPP__) || defined(__GO32__)
157 | # if defined(__DJGPP__) && (__DJGPP__ > 1)
158 | # define CURL_SIZEOF_LONG 4
159 | # define CURL_TYPEOF_CURL_OFF_T long long
160 | # define CURL_FORMAT_CURL_OFF_T "lld"
161 | # define CURL_FORMAT_CURL_OFF_TU "llu"
162 | # define CURL_FORMAT_OFF_T "%lld"
163 | # define CURL_SIZEOF_CURL_OFF_T 8
164 | # define CURL_SUFFIX_CURL_OFF_T LL
165 | # define CURL_SUFFIX_CURL_OFF_TU ULL
166 | # else
167 | # define CURL_SIZEOF_LONG 4
168 | # define CURL_TYPEOF_CURL_OFF_T long
169 | # define CURL_FORMAT_CURL_OFF_T "ld"
170 | # define CURL_FORMAT_CURL_OFF_TU "lu"
171 | # define CURL_FORMAT_OFF_T "%ld"
172 | # define CURL_SIZEOF_CURL_OFF_T 4
173 | # define CURL_SUFFIX_CURL_OFF_T L
174 | # define CURL_SUFFIX_CURL_OFF_TU UL
175 | # endif
176 |
177 | #elif defined(__SALFORDC__)
178 | # define CURL_SIZEOF_LONG 4
179 | # define CURL_TYPEOF_CURL_OFF_T long
180 | # define CURL_FORMAT_CURL_OFF_T "ld"
181 | # define CURL_FORMAT_CURL_OFF_TU "lu"
182 | # define CURL_FORMAT_OFF_T "%ld"
183 | # define CURL_SIZEOF_CURL_OFF_T 4
184 | # define CURL_SUFFIX_CURL_OFF_T L
185 | # define CURL_SUFFIX_CURL_OFF_TU UL
186 |
187 | #elif defined(__BORLANDC__)
188 | # if (__BORLANDC__ < 0x520)
189 | # define CURL_SIZEOF_LONG 4
190 | # define CURL_TYPEOF_CURL_OFF_T long
191 | # define CURL_FORMAT_CURL_OFF_T "ld"
192 | # define CURL_FORMAT_CURL_OFF_TU "lu"
193 | # define CURL_FORMAT_OFF_T "%ld"
194 | # define CURL_SIZEOF_CURL_OFF_T 4
195 | # define CURL_SUFFIX_CURL_OFF_T L
196 | # define CURL_SUFFIX_CURL_OFF_TU UL
197 | # else
198 | # define CURL_SIZEOF_LONG 4
199 | # define CURL_TYPEOF_CURL_OFF_T __int64
200 | # define CURL_FORMAT_CURL_OFF_T "I64d"
201 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
202 | # define CURL_FORMAT_OFF_T "%I64d"
203 | # define CURL_SIZEOF_CURL_OFF_T 8
204 | # define CURL_SUFFIX_CURL_OFF_T i64
205 | # define CURL_SUFFIX_CURL_OFF_TU ui64
206 | # endif
207 |
208 | #elif defined(__TURBOC__)
209 | # define CURL_SIZEOF_LONG 4
210 | # define CURL_TYPEOF_CURL_OFF_T long
211 | # define CURL_FORMAT_CURL_OFF_T "ld"
212 | # define CURL_FORMAT_CURL_OFF_TU "lu"
213 | # define CURL_FORMAT_OFF_T "%ld"
214 | # define CURL_SIZEOF_CURL_OFF_T 4
215 | # define CURL_SUFFIX_CURL_OFF_T L
216 | # define CURL_SUFFIX_CURL_OFF_TU UL
217 |
218 | #elif defined(__WATCOMC__)
219 | # if defined(__386__)
220 | # define CURL_SIZEOF_LONG 4
221 | # define CURL_TYPEOF_CURL_OFF_T __int64
222 | # define CURL_FORMAT_CURL_OFF_T "I64d"
223 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
224 | # define CURL_FORMAT_OFF_T "%I64d"
225 | # define CURL_SIZEOF_CURL_OFF_T 8
226 | # define CURL_SUFFIX_CURL_OFF_T i64
227 | # define CURL_SUFFIX_CURL_OFF_TU ui64
228 | # else
229 | # define CURL_SIZEOF_LONG 4
230 | # define CURL_TYPEOF_CURL_OFF_T long
231 | # define CURL_FORMAT_CURL_OFF_T "ld"
232 | # define CURL_FORMAT_CURL_OFF_TU "lu"
233 | # define CURL_FORMAT_OFF_T "%ld"
234 | # define CURL_SIZEOF_CURL_OFF_T 4
235 | # define CURL_SUFFIX_CURL_OFF_T L
236 | # define CURL_SUFFIX_CURL_OFF_TU UL
237 | # endif
238 |
239 | #elif defined(__POCC__)
240 | # if (__POCC__ < 280)
241 | # define CURL_SIZEOF_LONG 4
242 | # define CURL_TYPEOF_CURL_OFF_T long
243 | # define CURL_FORMAT_CURL_OFF_T "ld"
244 | # define CURL_FORMAT_CURL_OFF_TU "lu"
245 | # define CURL_FORMAT_OFF_T "%ld"
246 | # define CURL_SIZEOF_CURL_OFF_T 4
247 | # define CURL_SUFFIX_CURL_OFF_T L
248 | # define CURL_SUFFIX_CURL_OFF_TU UL
249 | # elif defined(_MSC_VER)
250 | # define CURL_SIZEOF_LONG 4
251 | # define CURL_TYPEOF_CURL_OFF_T __int64
252 | # define CURL_FORMAT_CURL_OFF_T "I64d"
253 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
254 | # define CURL_FORMAT_OFF_T "%I64d"
255 | # define CURL_SIZEOF_CURL_OFF_T 8
256 | # define CURL_SUFFIX_CURL_OFF_T i64
257 | # define CURL_SUFFIX_CURL_OFF_TU ui64
258 | # else
259 | # define CURL_SIZEOF_LONG 4
260 | # define CURL_TYPEOF_CURL_OFF_T long long
261 | # define CURL_FORMAT_CURL_OFF_T "lld"
262 | # define CURL_FORMAT_CURL_OFF_TU "llu"
263 | # define CURL_FORMAT_OFF_T "%lld"
264 | # define CURL_SIZEOF_CURL_OFF_T 8
265 | # define CURL_SUFFIX_CURL_OFF_T LL
266 | # define CURL_SUFFIX_CURL_OFF_TU ULL
267 | # endif
268 |
269 | #elif defined(__LCC__)
270 | # define CURL_SIZEOF_LONG 4
271 | # define CURL_TYPEOF_CURL_OFF_T long
272 | # define CURL_FORMAT_CURL_OFF_T "ld"
273 | # define CURL_FORMAT_CURL_OFF_TU "lu"
274 | # define CURL_FORMAT_OFF_T "%ld"
275 | # define CURL_SIZEOF_CURL_OFF_T 4
276 | # define CURL_SUFFIX_CURL_OFF_T L
277 | # define CURL_SUFFIX_CURL_OFF_TU UL
278 |
279 | #elif defined(__SYMBIAN32__)
280 | # if defined(__EABI__) /* Treat all ARM compilers equally */
281 | # define CURL_SIZEOF_LONG 4
282 | # define CURL_TYPEOF_CURL_OFF_T long long
283 | # define CURL_FORMAT_CURL_OFF_T "lld"
284 | # define CURL_FORMAT_CURL_OFF_TU "llu"
285 | # define CURL_FORMAT_OFF_T "%lld"
286 | # define CURL_SIZEOF_CURL_OFF_T 8
287 | # define CURL_SUFFIX_CURL_OFF_T LL
288 | # define CURL_SUFFIX_CURL_OFF_TU ULL
289 | # elif defined(__CW32__)
290 | # pragma longlong on
291 | # define CURL_SIZEOF_LONG 4
292 | # define CURL_TYPEOF_CURL_OFF_T long long
293 | # define CURL_FORMAT_CURL_OFF_T "lld"
294 | # define CURL_FORMAT_CURL_OFF_TU "llu"
295 | # define CURL_FORMAT_OFF_T "%lld"
296 | # define CURL_SIZEOF_CURL_OFF_T 8
297 | # define CURL_SUFFIX_CURL_OFF_T LL
298 | # define CURL_SUFFIX_CURL_OFF_TU ULL
299 | # elif defined(__VC32__)
300 | # define CURL_SIZEOF_LONG 4
301 | # define CURL_TYPEOF_CURL_OFF_T __int64
302 | # define CURL_FORMAT_CURL_OFF_T "lld"
303 | # define CURL_FORMAT_CURL_OFF_TU "llu"
304 | # define CURL_FORMAT_OFF_T "%lld"
305 | # define CURL_SIZEOF_CURL_OFF_T 8
306 | # define CURL_SUFFIX_CURL_OFF_T LL
307 | # define CURL_SUFFIX_CURL_OFF_TU ULL
308 | # endif
309 |
310 | #elif defined(__MWERKS__)
311 | # define CURL_SIZEOF_LONG 4
312 | # define CURL_TYPEOF_CURL_OFF_T long long
313 | # define CURL_FORMAT_CURL_OFF_T "lld"
314 | # define CURL_FORMAT_CURL_OFF_TU "llu"
315 | # define CURL_FORMAT_OFF_T "%lld"
316 | # define CURL_SIZEOF_CURL_OFF_T 8
317 | # define CURL_SUFFIX_CURL_OFF_T LL
318 | # define CURL_SUFFIX_CURL_OFF_TU ULL
319 |
320 | #elif defined(_WIN32_WCE)
321 | # define CURL_SIZEOF_LONG 4
322 | # define CURL_TYPEOF_CURL_OFF_T __int64
323 | # define CURL_FORMAT_CURL_OFF_T "I64d"
324 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
325 | # define CURL_FORMAT_OFF_T "%I64d"
326 | # define CURL_SIZEOF_CURL_OFF_T 8
327 | # define CURL_SUFFIX_CURL_OFF_T i64
328 | # define CURL_SUFFIX_CURL_OFF_TU ui64
329 |
330 | #elif defined(__MINGW32__)
331 | # define CURL_SIZEOF_LONG 4
332 | # define CURL_TYPEOF_CURL_OFF_T long long
333 | # define CURL_FORMAT_CURL_OFF_T "I64d"
334 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
335 | # define CURL_FORMAT_OFF_T "%I64d"
336 | # define CURL_SIZEOF_CURL_OFF_T 8
337 | # define CURL_SUFFIX_CURL_OFF_T LL
338 | # define CURL_SUFFIX_CURL_OFF_TU ULL
339 |
340 | #elif defined(__VMS)
341 | # if defined(__alpha) || defined(__ia64)
342 | # define CURL_SIZEOF_LONG 4
343 | # define CURL_TYPEOF_CURL_OFF_T long long
344 | # define CURL_FORMAT_CURL_OFF_T "lld"
345 | # define CURL_FORMAT_CURL_OFF_TU "llu"
346 | # define CURL_FORMAT_OFF_T "%lld"
347 | # define CURL_SIZEOF_CURL_OFF_T 8
348 | # define CURL_SUFFIX_CURL_OFF_T LL
349 | # define CURL_SUFFIX_CURL_OFF_TU ULL
350 | # else
351 | # define CURL_SIZEOF_LONG 4
352 | # define CURL_TYPEOF_CURL_OFF_T long
353 | # define CURL_FORMAT_CURL_OFF_T "ld"
354 | # define CURL_FORMAT_CURL_OFF_TU "lu"
355 | # define CURL_FORMAT_OFF_T "%ld"
356 | # define CURL_SIZEOF_CURL_OFF_T 4
357 | # define CURL_SUFFIX_CURL_OFF_T L
358 | # define CURL_SUFFIX_CURL_OFF_TU UL
359 | # endif
360 |
361 | #elif defined(__OS400__)
362 | # if defined(__ILEC400__)
363 | # define CURL_SIZEOF_LONG 4
364 | # define CURL_TYPEOF_CURL_OFF_T long long
365 | # define CURL_FORMAT_CURL_OFF_T "lld"
366 | # define CURL_FORMAT_CURL_OFF_TU "llu"
367 | # define CURL_FORMAT_OFF_T "%lld"
368 | # define CURL_SIZEOF_CURL_OFF_T 8
369 | # define CURL_SUFFIX_CURL_OFF_T LL
370 | # define CURL_SUFFIX_CURL_OFF_TU ULL
371 | # endif
372 |
373 | #elif defined(__MVS__)
374 | # if defined(__IBMC__) || defined(__IBMCPP__)
375 | # if defined(_ILP32)
376 | # define CURL_SIZEOF_LONG 4
377 | # elif defined(_LP64)
378 | # define CURL_SIZEOF_LONG 8
379 | # endif
380 | # if defined(_LONG_LONG)
381 | # define CURL_TYPEOF_CURL_OFF_T long long
382 | # define CURL_FORMAT_CURL_OFF_T "lld"
383 | # define CURL_FORMAT_CURL_OFF_TU "llu"
384 | # define CURL_FORMAT_OFF_T "%lld"
385 | # define CURL_SIZEOF_CURL_OFF_T 8
386 | # define CURL_SUFFIX_CURL_OFF_T LL
387 | # define CURL_SUFFIX_CURL_OFF_TU ULL
388 | # elif defined(_LP64)
389 | # define CURL_TYPEOF_CURL_OFF_T long
390 | # define CURL_FORMAT_CURL_OFF_T "ld"
391 | # define CURL_FORMAT_CURL_OFF_TU "lu"
392 | # define CURL_FORMAT_OFF_T "%ld"
393 | # define CURL_SIZEOF_CURL_OFF_T 8
394 | # define CURL_SUFFIX_CURL_OFF_T L
395 | # define CURL_SUFFIX_CURL_OFF_TU UL
396 | # else
397 | # define CURL_TYPEOF_CURL_OFF_T long
398 | # define CURL_FORMAT_CURL_OFF_T "ld"
399 | # define CURL_FORMAT_CURL_OFF_TU "lu"
400 | # define CURL_FORMAT_OFF_T "%ld"
401 | # define CURL_SIZEOF_CURL_OFF_T 4
402 | # define CURL_SUFFIX_CURL_OFF_T L
403 | # define CURL_SUFFIX_CURL_OFF_TU UL
404 | # endif
405 | # endif
406 |
407 | #elif defined(__370__)
408 | # if defined(__IBMC__) || defined(__IBMCPP__)
409 | # if defined(_ILP32)
410 | # define CURL_SIZEOF_LONG 4
411 | # elif defined(_LP64)
412 | # define CURL_SIZEOF_LONG 8
413 | # endif
414 | # if defined(_LONG_LONG)
415 | # define CURL_TYPEOF_CURL_OFF_T long long
416 | # define CURL_FORMAT_CURL_OFF_T "lld"
417 | # define CURL_FORMAT_CURL_OFF_TU "llu"
418 | # define CURL_FORMAT_OFF_T "%lld"
419 | # define CURL_SIZEOF_CURL_OFF_T 8
420 | # define CURL_SUFFIX_CURL_OFF_T LL
421 | # define CURL_SUFFIX_CURL_OFF_TU ULL
422 | # elif defined(_LP64)
423 | # define CURL_TYPEOF_CURL_OFF_T long
424 | # define CURL_FORMAT_CURL_OFF_T "ld"
425 | # define CURL_FORMAT_CURL_OFF_TU "lu"
426 | # define CURL_FORMAT_OFF_T "%ld"
427 | # define CURL_SIZEOF_CURL_OFF_T 8
428 | # define CURL_SUFFIX_CURL_OFF_T L
429 | # define CURL_SUFFIX_CURL_OFF_TU UL
430 | # else
431 | # define CURL_TYPEOF_CURL_OFF_T long
432 | # define CURL_FORMAT_CURL_OFF_T "ld"
433 | # define CURL_FORMAT_CURL_OFF_TU "lu"
434 | # define CURL_FORMAT_OFF_T "%ld"
435 | # define CURL_SIZEOF_CURL_OFF_T 4
436 | # define CURL_SUFFIX_CURL_OFF_T L
437 | # define CURL_SUFFIX_CURL_OFF_TU UL
438 | # endif
439 | # endif
440 |
441 | /* ===================================== */
442 | /* SunPro Compilers */
443 | /* ===================================== */
444 |
445 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
446 | #include
447 | #include
448 |
449 | # define CURL_TYPEOF_CURL_OFF_T off_t
450 | # define CURL_SIZEOF_CURL_OFF_T 8
451 | # if defined(__amd64) || defined(__sparcv9)
452 | # define CURL_SIZEOF_LONG 8
453 | # define CURL_FORMAT_CURL_OFF_T "ld"
454 | # define CURL_FORMAT_CURL_OFF_TU "lu"
455 | # define CURL_FORMAT_OFF_T "%ld"
456 | # define CURL_SUFFIX_CURL_OFF_T L
457 | # define CURL_SUFFIX_CURL_OFF_TU UL
458 | # else
459 | # define CURL_SIZEOF_LONG 4
460 | # define CURL_FORMAT_CURL_OFF_T "lld"
461 | # define CURL_FORMAT_CURL_OFF_TU "llu"
462 | # define CURL_FORMAT_OFF_T "%lld"
463 | # define CURL_SUFFIX_CURL_OFF_T LL
464 | # define CURL_SUFFIX_CURL_OFF_TU ULL
465 | # endif
466 |
467 | /* ===================================== */
468 | /* KEEP MSVC THE PENULTIMATE ENTRY */
469 | /* ===================================== */
470 |
471 | #elif defined(_MSC_VER)
472 | # if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
473 | # define CURL_SIZEOF_LONG 4
474 | # define CURL_TYPEOF_CURL_OFF_T __int64
475 | # define CURL_FORMAT_CURL_OFF_T "I64d"
476 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
477 | # define CURL_FORMAT_OFF_T "%I64d"
478 | # define CURL_SIZEOF_CURL_OFF_T 8
479 | # define CURL_SUFFIX_CURL_OFF_T i64
480 | # define CURL_SUFFIX_CURL_OFF_TU ui64
481 | # else
482 | # define CURL_SIZEOF_LONG 4
483 | # define CURL_TYPEOF_CURL_OFF_T long
484 | # define CURL_FORMAT_CURL_OFF_T "ld"
485 | # define CURL_FORMAT_CURL_OFF_TU "lu"
486 | # define CURL_FORMAT_OFF_T "%ld"
487 | # define CURL_SIZEOF_CURL_OFF_T 4
488 | # define CURL_SUFFIX_CURL_OFF_T L
489 | # define CURL_SUFFIX_CURL_OFF_TU UL
490 | # endif
491 |
492 | /* ===================================== */
493 | /* KEEP GENERIC GCC THE LAST ENTRY */
494 | /* ===================================== */
495 |
496 | #elif defined(__GNUC__)
497 | # if defined(__i386__) || defined(__ppc__)
498 | # define CURL_SIZEOF_LONG 4
499 | # define CURL_TYPEOF_CURL_OFF_T long long
500 | # define CURL_FORMAT_CURL_OFF_T "lld"
501 | # define CURL_FORMAT_CURL_OFF_TU "llu"
502 | # define CURL_FORMAT_OFF_T "%lld"
503 | # define CURL_SIZEOF_CURL_OFF_T 8
504 | # define CURL_SUFFIX_CURL_OFF_T LL
505 | # define CURL_SUFFIX_CURL_OFF_TU ULL
506 | # elif defined(__x86_64__) || defined(__ppc64__)
507 | # define CURL_SIZEOF_LONG 8
508 | # define CURL_TYPEOF_CURL_OFF_T long
509 | # define CURL_FORMAT_CURL_OFF_T "ld"
510 | # define CURL_FORMAT_CURL_OFF_TU "lu"
511 | # define CURL_FORMAT_OFF_T "%ld"
512 | # define CURL_SIZEOF_CURL_OFF_T 8
513 | # define CURL_SUFFIX_CURL_OFF_T L
514 | # define CURL_SUFFIX_CURL_OFF_TU UL
515 | # endif
516 |
517 | #else
518 | # error "Unknown non-configure build target!"
519 | Error Compilation_aborted_Unknown_non_configure_build_target
520 | #endif
521 |
522 | /* Data type definition of curl_off_t. */
523 |
524 | #ifdef CURL_TYPEOF_CURL_OFF_T
525 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
526 | #endif
527 |
528 | #endif /* __CURL_CURLBUILD_H */
529 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/curlbuild.h.in:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_CURLBUILD_H
2 | #define __CURL_CURLBUILD_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: curlbuild.h.in,v 1.6 2008-08-25 13:42:53 yangtse Exp $
24 | ***************************************************************************/
25 |
26 | /* ================================================================ */
27 | /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
28 | /* ================================================================ */
29 |
30 | /*
31 | * NOTE 1:
32 | * -------
33 | *
34 | * Nothing in this file is intended to be modified or adjusted by the
35 | * curl library user nor by the curl library builder.
36 | *
37 | * If you think that something actually needs to be changed, adjusted
38 | * or fixed in this file, then, report it on the libcurl development
39 | * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
40 | *
41 | * This header file shall only export symbols which are 'curl' or 'CURL'
42 | * prefixed, otherwise public name space would be polluted.
43 | *
44 | * NOTE 2:
45 | * -------
46 | *
47 | * Right now you might be staring at file include/curl/curlbuild.h.in or
48 | * at file include/curl/curlbuild.h, this is due to the following reason:
49 | *
50 | * On systems capable of running the configure script, the configure process
51 | * will overwrite the distributed include/curl/curlbuild.h file with one that
52 | * is suitable and specific to the library being configured and built, which
53 | * is generated from the include/curl/curlbuild.h.in template file.
54 | *
55 | */
56 |
57 | /* ================================================================ */
58 | /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
59 | /* ================================================================ */
60 |
61 | #ifdef CURL_SIZEOF_LONG
62 | # error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
63 | Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
64 | #endif
65 |
66 | #ifdef CURL_TYPEOF_CURL_OFF_T
67 | # error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
68 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
69 | #endif
70 |
71 | #ifdef CURL_FORMAT_CURL_OFF_T
72 | # error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
73 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined
74 | #endif
75 |
76 | #ifdef CURL_FORMAT_CURL_OFF_TU
77 | # error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
78 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined
79 | #endif
80 |
81 | #ifdef CURL_FORMAT_OFF_T
82 | # error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
83 | Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined
84 | #endif
85 |
86 | #ifdef CURL_SIZEOF_CURL_OFF_T
87 | # error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
88 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined
89 | #endif
90 |
91 | #ifdef CURL_SUFFIX_CURL_OFF_T
92 | # error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
93 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined
94 | #endif
95 |
96 | #ifdef CURL_SUFFIX_CURL_OFF_TU
97 | # error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
98 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined
99 | #endif
100 |
101 | /* ================================================================ */
102 | /* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
103 | /* ================================================================ */
104 |
105 | /* Configure process defines this to 1 when it finds out that system */
106 | /* header file sys/types.h must be included by the external interface. */
107 | #undef CURL_PULL_SYS_TYPES_H
108 | #ifdef CURL_PULL_SYS_TYPES_H
109 | # include
110 | #endif
111 |
112 | /* Configure process defines this to 1 when it finds out that system */
113 | /* header file stdint.h must be included by the external interface. */
114 | #undef CURL_PULL_STDINT_H
115 | #ifdef CURL_PULL_STDINT_H
116 | # include
117 | #endif
118 |
119 | /* Configure process defines this to 1 when it finds out that system */
120 | /* header file inttypes.h must be included by the external interface. */
121 | #undef CURL_PULL_INTTYPES_H
122 | #ifdef CURL_PULL_INTTYPES_H
123 | # include
124 | #endif
125 |
126 | /* The size of `long', as computed by sizeof. */
127 | #undef CURL_SIZEOF_LONG
128 |
129 | /* Signed integral data type used for curl_off_t. */
130 | #undef CURL_TYPEOF_CURL_OFF_T
131 |
132 | /* Data type definition of curl_off_t. */
133 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
134 |
135 | /* curl_off_t formatting string directive without "%" conversion specifier. */
136 | #undef CURL_FORMAT_CURL_OFF_T
137 |
138 | /* unsigned curl_off_t formatting string without "%" conversion specifier. */
139 | #undef CURL_FORMAT_CURL_OFF_TU
140 |
141 | /* curl_off_t formatting string directive with "%" conversion specifier. */
142 | #undef CURL_FORMAT_OFF_T
143 |
144 | /* The size of `curl_off_t', as computed by sizeof. */
145 | #undef CURL_SIZEOF_CURL_OFF_T
146 |
147 | /* curl_off_t constant suffix. */
148 | #undef CURL_SUFFIX_CURL_OFF_T
149 |
150 | /* unsigned curl_off_t constant suffix. */
151 | #undef CURL_SUFFIX_CURL_OFF_TU
152 |
153 | #endif /* __CURL_CURLBUILD_H */
154 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/curlrules.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_CURLRULES_H
2 | #define __CURL_CURLRULES_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: curlrules.h,v 1.5 2008-08-25 01:18:49 yangtse Exp $
24 | ***************************************************************************/
25 |
26 | /* ================================================================ */
27 | /* COMPILE TIME SANITY CHECKS */
28 | /* ================================================================ */
29 |
30 | /*
31 | * NOTE 1:
32 | * -------
33 | *
34 | * All checks done in this file are intentionally placed in a public
35 | * header file which is pulled by curl/curl.h when an application is
36 | * being built using an already built libcurl library. Additionally
37 | * this file is also included and used when building the library.
38 | *
39 | * If compilation fails on this file it is certainly sure that the
40 | * problem is elsewhere. It could be a problem in the curlbuild.h
41 | * header file, or simply that you are using different compilation
42 | * settings than those used to build the library.
43 | *
44 | * Nothing in this file is intended to be modified or adjusted by the
45 | * curl library user nor by the curl library builder.
46 | *
47 | * Do not deactivate any check, these are done to make sure that the
48 | * library is properly built and used.
49 | *
50 | * You can find further help on the libcurl development mailing list:
51 | * http://cool.haxx.se/mailman/listinfo/curl-library/
52 | *
53 | * NOTE 2
54 | * ------
55 | *
56 | * Some of the following compile time checks are based on the fact
57 | * that the dimension of a constant array can not be a negative one.
58 | * In this way if the compile time verification fails, the compilation
59 | * will fail issuing an error. The error description wording is compiler
60 | * dependant but it will be quite similar to one of the following:
61 | *
62 | * "negative subscript or subscript is too large"
63 | * "array must have at least one element"
64 | * "-1 is an illegal array size"
65 | * "size of array is negative"
66 | *
67 | * If you are building an application which tries to use an already
68 | * built libcurl library and you are getting this kind of errors on
69 | * this file, it is a clear indication that there is a mismatch between
70 | * how the library was built and how you are trying to use it for your
71 | * application. Your already compiled or binary library provider is the
72 | * only one who can give you the details you need to properly use it.
73 | */
74 |
75 | /*
76 | * Verify that some macros are actually defined.
77 | */
78 |
79 | #ifndef CURL_SIZEOF_LONG
80 | # error "CURL_SIZEOF_LONG definition is missing!"
81 | Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
82 | #endif
83 |
84 | #ifndef CURL_TYPEOF_CURL_OFF_T
85 | # error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
86 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing
87 | #endif
88 |
89 | #ifndef CURL_FORMAT_CURL_OFF_T
90 | # error "CURL_FORMAT_CURL_OFF_T definition is missing!"
91 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing
92 | #endif
93 |
94 | #ifndef CURL_FORMAT_CURL_OFF_TU
95 | # error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
96 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing
97 | #endif
98 |
99 | #ifndef CURL_FORMAT_OFF_T
100 | # error "CURL_FORMAT_OFF_T definition is missing!"
101 | Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing
102 | #endif
103 |
104 | #ifndef CURL_SIZEOF_CURL_OFF_T
105 | # error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
106 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
107 | #endif
108 |
109 | #ifndef CURL_SUFFIX_CURL_OFF_T
110 | # error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
111 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
112 | #endif
113 |
114 | #ifndef CURL_SUFFIX_CURL_OFF_TU
115 | # error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
116 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
117 | #endif
118 |
119 | /*
120 | * Macros private to this header file.
121 | */
122 |
123 | #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
124 |
125 | #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
126 |
127 | /*
128 | * Verify that the size previously defined and expected for long
129 | * is the same as the one reported by sizeof() at compile time.
130 | */
131 |
132 | typedef char
133 | __curl_rule_01__
134 | [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
135 |
136 | /*
137 | * Verify that the size previously defined and expected for
138 | * curl_off_t is actually the the same as the one reported
139 | * by sizeof() at compile time.
140 | */
141 |
142 | typedef char
143 | __curl_rule_02__
144 | [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
145 |
146 | /*
147 | * Verify at compile time that the size of curl_off_t as reported
148 | * by sizeof() is greater or equal than the one reported for long
149 | * for the current compilation.
150 | */
151 |
152 | typedef char
153 | __curl_rule_03__
154 | [CurlchkszGE(curl_off_t, long)];
155 |
156 | /* ================================================================ */
157 | /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
158 | /* ================================================================ */
159 |
160 | /*
161 | * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
162 | * these to be visible and exported by the external libcurl interface API,
163 | * while also making them visible to the library internals, simply including
164 | * setup.h, without actually needing to include curl.h internally.
165 | * If some day this section would grow big enough, all this should be moved
166 | * to its own header file.
167 | */
168 |
169 | /*
170 | * Figure out if we can use the ## preprocessor operator, which is supported
171 | * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
172 | * or __cplusplus so we need to carefully check for them too.
173 | */
174 |
175 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
176 | defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
177 | defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
178 | defined(__ILEC400__)
179 | /* This compiler is believed to have an ISO compatible preprocessor */
180 | #define CURL_ISOCPP
181 | #else
182 | /* This compiler is believed NOT to have an ISO compatible preprocessor */
183 | #undef CURL_ISOCPP
184 | #endif
185 |
186 | /*
187 | * Macros for minimum-width signed and unsigned curl_off_t integer constants.
188 | */
189 |
190 | #ifdef CURL_ISOCPP
191 | # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix
192 | #else
193 | # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix
194 | #endif
195 | #define __CURL_OFF_T_C_HELPER1(Val,Suffix) __CURL_OFF_T_C_HELPER2(Val,Suffix)
196 | #define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_T)
197 | #define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_TU)
198 |
199 | /*
200 | * Get rid of macros private to this header file.
201 | */
202 |
203 | #undef CurlchkszEQ
204 | #undef CurlchkszGE
205 |
206 | /*
207 | * Get rid of macros not intended to exist beyond this point.
208 | */
209 |
210 | #undef CURL_PULL_SYS_TYPES_H
211 | #undef CURL_PULL_STDINT_H
212 | #undef CURL_PULL_INTTYPES_H
213 |
214 | #undef CURL_TYPEOF_CURL_OFF_T
215 |
216 | #endif /* __CURL_CURLRULES_H */
217 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/curlver.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_CURLVER_H
2 | #define __CURL_CURLVER_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: curlver.h,v 1.44 2009-01-17 14:56:33 gknauf Exp $
24 | ***************************************************************************/
25 |
26 | /* This header file contains nothing but libcurl version info, generated by
27 | a script at release-time. This was made its own header file in 7.11.2 */
28 |
29 | /* This is the global package copyright */
30 | #define LIBCURL_COPYRIGHT "1996 - 2009 Daniel Stenberg, ."
31 |
32 | /* This is the version number of the libcurl package from which this header
33 | file origins: */
34 | #define LIBCURL_VERSION "7.19.3"
35 |
36 | /* The numeric version number is also available "in parts" by using these
37 | defines: */
38 | #define LIBCURL_VERSION_MAJOR 7
39 | #define LIBCURL_VERSION_MINOR 19
40 | #define LIBCURL_VERSION_PATCH 3
41 |
42 | /* This is the numeric version of the libcurl version number, meant for easier
43 | parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
44 | always follow this syntax:
45 |
46 | 0xXXYYZZ
47 |
48 | Where XX, YY and ZZ are the main version, release and patch numbers in
49 | hexadecimal (using 8 bits each). All three numbers are always represented
50 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7
51 | appears as "0x090b07".
52 |
53 | This 6-digit (24 bits) hexadecimal number does not show pre-release number,
54 | and it is always a greater number in a more recent release. It makes
55 | comparisons with greater than and less than work.
56 | */
57 | #define LIBCURL_VERSION_NUM 0x071303
58 |
59 | /*
60 | * This is the date and time when the full source package was created. The
61 | * timestamp is not stored in CVS, as the timestamp is properly set in the
62 | * tarballs by the maketgz script.
63 | *
64 | * The format of the date should follow this template:
65 | *
66 | * "Mon Feb 12 11:35:33 UTC 2007"
67 | */
68 | #define LIBCURL_TIMESTAMP "Mon Jan 19 09:59:36 UTC 2009"
69 |
70 | #endif /* __CURL_CURLVER_H */
71 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/easy.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_EASY_H
2 | #define __CURL_EASY_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: easy.h,v 1.14 2008-05-12 21:43:28 bagder Exp $
24 | ***************************************************************************/
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | CURL_EXTERN CURL *curl_easy_init(void);
30 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
31 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
32 | CURL_EXTERN void curl_easy_cleanup(CURL *curl);
33 |
34 | /*
35 | * NAME curl_easy_getinfo()
36 | *
37 | * DESCRIPTION
38 | *
39 | * Request internal information from the curl session with this function. The
40 | * third argument MUST be a pointer to a long, a pointer to a char * or a
41 | * pointer to a double (as the documentation describes elsewhere). The data
42 | * pointed to will be filled in accordingly and can be relied upon only if the
43 | * function returns CURLE_OK. This function is intended to get used *AFTER* a
44 | * performed transfer, all results from this function are undefined until the
45 | * transfer is completed.
46 | */
47 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
48 |
49 |
50 | /*
51 | * NAME curl_easy_duphandle()
52 | *
53 | * DESCRIPTION
54 | *
55 | * Creates a new curl session handle with the same options set for the handle
56 | * passed in. Duplicating a handle could only be a matter of cloning data and
57 | * options, internal state info and things like persistant connections cannot
58 | * be transfered. It is useful in multithreaded applications when you can run
59 | * curl_easy_duphandle() for each new thread to avoid a series of identical
60 | * curl_easy_setopt() invokes in every thread.
61 | */
62 | CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl);
63 |
64 | /*
65 | * NAME curl_easy_reset()
66 | *
67 | * DESCRIPTION
68 | *
69 | * Re-initializes a CURL handle to the default values. This puts back the
70 | * handle to the same state as it was in when it was just created.
71 | *
72 | * It does keep: live connections, the Session ID cache, the DNS cache and the
73 | * cookies.
74 | */
75 | CURL_EXTERN void curl_easy_reset(CURL *curl);
76 |
77 | /*
78 | * NAME curl_easy_recv()
79 | *
80 | * DESCRIPTION
81 | *
82 | * Receives data from the connected socket. Use after successful
83 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
84 | */
85 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
86 | size_t *n);
87 |
88 | /*
89 | * NAME curl_easy_send()
90 | *
91 | * DESCRIPTION
92 | *
93 | * Sends data over the connected socket. Use after successful
94 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
95 | */
96 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
97 | size_t buflen, size_t *n);
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif
104 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/mprintf.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_MPRINTF_H
2 | #define __CURL_MPRINTF_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: mprintf.h,v 1.16 2008-05-20 10:21:50 patrickm Exp $
24 | ***************************************************************************/
25 |
26 | #include
27 | #include /* needed for FILE */
28 |
29 | #include "curl.h"
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | CURL_EXTERN int curl_mprintf(const char *format, ...);
36 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
37 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
38 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
39 | const char *format, ...);
40 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
41 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
42 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
43 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
44 | const char *format, va_list args);
45 | CURL_EXTERN char *curl_maprintf(const char *format, ...);
46 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
47 |
48 | #ifdef _MPRINTF_REPLACE
49 | # undef printf
50 | # undef fprintf
51 | # undef sprintf
52 | # undef vsprintf
53 | # undef snprintf
54 | # undef vprintf
55 | # undef vfprintf
56 | # undef vsnprintf
57 | # undef aprintf
58 | # undef vaprintf
59 | # define printf curl_mprintf
60 | # define fprintf curl_mfprintf
61 | #ifdef CURLDEBUG
62 | /* When built with CURLDEBUG we define away the sprintf() functions since we
63 | don't want internal code to be using them */
64 | # define sprintf sprintf_was_used
65 | # define vsprintf vsprintf_was_used
66 | #else
67 | # define sprintf curl_msprintf
68 | # define vsprintf curl_mvsprintf
69 | #endif
70 | # define snprintf curl_msnprintf
71 | # define vprintf curl_mvprintf
72 | # define vfprintf curl_mvfprintf
73 | # define vsnprintf curl_mvsnprintf
74 | # define aprintf curl_maprintf
75 | # define vaprintf curl_mvaprintf
76 | #endif
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif /* __CURL_MPRINTF_H */
83 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/multi.h:
--------------------------------------------------------------------------------
1 | #ifndef __CURL_MULTI_H
2 | #define __CURL_MULTI_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: multi.h,v 1.45 2008-05-20 10:21:50 patrickm Exp $
24 | ***************************************************************************/
25 | /*
26 | This is an "external" header file. Don't give away any internals here!
27 |
28 | GOALS
29 |
30 | o Enable a "pull" interface. The application that uses libcurl decides where
31 | and when to ask libcurl to get/send data.
32 |
33 | o Enable multiple simultaneous transfers in the same thread without making it
34 | complicated for the application.
35 |
36 | o Enable the application to select() on its own file descriptors and curl's
37 | file descriptors simultaneous easily.
38 |
39 | */
40 |
41 | /*
42 | * This header file should not really need to include "curl.h" since curl.h
43 | * itself includes this file and we expect user applications to do #include
44 | * without the need for especially including multi.h.
45 | *
46 | * For some reason we added this include here at one point, and rather than to
47 | * break existing (wrongly written) libcurl applications, we leave it as-is
48 | * but with this warning attached.
49 | */
50 | #include "curl.h"
51 |
52 | #ifdef __cplusplus
53 | extern "C" {
54 | #endif
55 |
56 | typedef void CURLM;
57 |
58 | typedef enum {
59 | CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
60 | curl_multi_socket*() soon */
61 | CURLM_OK,
62 | CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
63 | CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
64 | CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
65 | CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
66 | CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
67 | CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
68 | CURLM_LAST
69 | } CURLMcode;
70 |
71 | /* just to make code nicer when using curl_multi_socket() you can now check
72 | for CURLM_CALL_MULTI_SOCKET too in the same style it works for
73 | curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
74 | #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
75 |
76 | typedef enum {
77 | CURLMSG_NONE, /* first, not used */
78 | CURLMSG_DONE, /* This easy handle has completed. 'result' contains
79 | the CURLcode of the transfer */
80 | CURLMSG_LAST /* last, not used */
81 | } CURLMSG;
82 |
83 | struct CURLMsg {
84 | CURLMSG msg; /* what this message means */
85 | CURL *easy_handle; /* the handle it concerns */
86 | union {
87 | void *whatever; /* message-specific data */
88 | CURLcode result; /* return code for transfer */
89 | } data;
90 | };
91 | typedef struct CURLMsg CURLMsg;
92 |
93 | /*
94 | * Name: curl_multi_init()
95 | *
96 | * Desc: inititalize multi-style curl usage
97 | *
98 | * Returns: a new CURLM handle to use in all 'curl_multi' functions.
99 | */
100 | CURL_EXTERN CURLM *curl_multi_init(void);
101 |
102 | /*
103 | * Name: curl_multi_add_handle()
104 | *
105 | * Desc: add a standard curl handle to the multi stack
106 | *
107 | * Returns: CURLMcode type, general multi error code.
108 | */
109 | CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
110 | CURL *curl_handle);
111 |
112 | /*
113 | * Name: curl_multi_remove_handle()
114 | *
115 | * Desc: removes a curl handle from the multi stack again
116 | *
117 | * Returns: CURLMcode type, general multi error code.
118 | */
119 | CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
120 | CURL *curl_handle);
121 |
122 | /*
123 | * Name: curl_multi_fdset()
124 | *
125 | * Desc: Ask curl for its fd_set sets. The app can use these to select() or
126 | * poll() on. We want curl_multi_perform() called as soon as one of
127 | * them are ready.
128 | *
129 | * Returns: CURLMcode type, general multi error code.
130 | */
131 | CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
132 | fd_set *read_fd_set,
133 | fd_set *write_fd_set,
134 | fd_set *exc_fd_set,
135 | int *max_fd);
136 |
137 | /*
138 | * Name: curl_multi_perform()
139 | *
140 | * Desc: When the app thinks there's data available for curl it calls this
141 | * function to read/write whatever there is right now. This returns
142 | * as soon as the reads and writes are done. This function does not
143 | * require that there actually is data available for reading or that
144 | * data can be written, it can be called just in case. It returns
145 | * the number of handles that still transfer data in the second
146 | * argument's integer-pointer.
147 | *
148 | * Returns: CURLMcode type, general multi error code. *NOTE* that this only
149 | * returns errors etc regarding the whole multi stack. There might
150 | * still have occurred problems on invidual transfers even when this
151 | * returns OK.
152 | */
153 | CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
154 | int *running_handles);
155 |
156 | /*
157 | * Name: curl_multi_cleanup()
158 | *
159 | * Desc: Cleans up and removes a whole multi stack. It does not free or
160 | * touch any individual easy handles in any way. We need to define
161 | * in what state those handles will be if this function is called
162 | * in the middle of a transfer.
163 | *
164 | * Returns: CURLMcode type, general multi error code.
165 | */
166 | CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
167 |
168 | /*
169 | * Name: curl_multi_info_read()
170 | *
171 | * Desc: Ask the multi handle if there's any messages/informationals from
172 | * the individual transfers. Messages include informationals such as
173 | * error code from the transfer or just the fact that a transfer is
174 | * completed. More details on these should be written down as well.
175 | *
176 | * Repeated calls to this function will return a new struct each
177 | * time, until a special "end of msgs" struct is returned as a signal
178 | * that there is no more to get at this point.
179 | *
180 | * The data the returned pointer points to will not survive calling
181 | * curl_multi_cleanup().
182 | *
183 | * The 'CURLMsg' struct is meant to be very simple and only contain
184 | * very basic informations. If more involved information is wanted,
185 | * we will provide the particular "transfer handle" in that struct
186 | * and that should/could/would be used in subsequent
187 | * curl_easy_getinfo() calls (or similar). The point being that we
188 | * must never expose complex structs to applications, as then we'll
189 | * undoubtably get backwards compatibility problems in the future.
190 | *
191 | * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
192 | * of structs. It also writes the number of messages left in the
193 | * queue (after this read) in the integer the second argument points
194 | * to.
195 | */
196 | CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
197 | int *msgs_in_queue);
198 |
199 | /*
200 | * Name: curl_multi_strerror()
201 | *
202 | * Desc: The curl_multi_strerror function may be used to turn a CURLMcode
203 | * value into the equivalent human readable error string. This is
204 | * useful for printing meaningful error messages.
205 | *
206 | * Returns: A pointer to a zero-terminated error message.
207 | */
208 | CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
209 |
210 | /*
211 | * Name: curl_multi_socket() and
212 | * curl_multi_socket_all()
213 | *
214 | * Desc: An alternative version of curl_multi_perform() that allows the
215 | * application to pass in one of the file descriptors that have been
216 | * detected to have "action" on them and let libcurl perform.
217 | * See man page for details.
218 | */
219 | #define CURL_POLL_NONE 0
220 | #define CURL_POLL_IN 1
221 | #define CURL_POLL_OUT 2
222 | #define CURL_POLL_INOUT 3
223 | #define CURL_POLL_REMOVE 4
224 |
225 | #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
226 |
227 | #define CURL_CSELECT_IN 0x01
228 | #define CURL_CSELECT_OUT 0x02
229 | #define CURL_CSELECT_ERR 0x04
230 |
231 | typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
232 | curl_socket_t s, /* socket */
233 | int what, /* see above */
234 | void *userp, /* private callback
235 | pointer */
236 | void *socketp); /* private socket
237 | pointer */
238 | /*
239 | * Name: curl_multi_timer_callback
240 | *
241 | * Desc: Called by libcurl whenever the library detects a change in the
242 | * maximum number of milliseconds the app is allowed to wait before
243 | * curl_multi_socket() or curl_multi_perform() must be called
244 | * (to allow libcurl's timed events to take place).
245 | *
246 | * Returns: The callback should return zero.
247 | */
248 | typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
249 | long timeout_ms, /* see above */
250 | void *userp); /* private callback
251 | pointer */
252 |
253 | CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
254 | int *running_handles);
255 |
256 | CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
257 | curl_socket_t s,
258 | int ev_bitmask,
259 | int *running_handles);
260 |
261 | CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
262 | int *running_handles);
263 |
264 | #ifndef CURL_ALLOW_OLD_MULTI_SOCKET
265 | /* This macro below was added in 7.16.3 to push users who recompile to use
266 | the new curl_multi_socket_action() instead of the old curl_multi_socket()
267 | */
268 | #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
269 | #endif
270 |
271 | /*
272 | * Name: curl_multi_timeout()
273 | *
274 | * Desc: Returns the maximum number of milliseconds the app is allowed to
275 | * wait before curl_multi_socket() or curl_multi_perform() must be
276 | * called (to allow libcurl's timed events to take place).
277 | *
278 | * Returns: CURLM error code.
279 | */
280 | CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
281 | long *milliseconds);
282 |
283 | #undef CINIT /* re-using the same name as in curl.h */
284 |
285 | #ifdef CURL_ISOCPP
286 | #define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
287 | #else
288 | /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
289 | #define LONG CURLOPTTYPE_LONG
290 | #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
291 | #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
292 | #define OFF_T CURLOPTTYPE_OFF_T
293 | #define CINIT(name,type,number) CURLMOPT_/**/name = type + number
294 | #endif
295 |
296 | typedef enum {
297 | /* This is the socket callback function pointer */
298 | CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
299 |
300 | /* This is the argument passed to the socket callback */
301 | CINIT(SOCKETDATA, OBJECTPOINT, 2),
302 |
303 | /* set to 1 to enable pipelining for this multi handle */
304 | CINIT(PIPELINING, LONG, 3),
305 |
306 | /* This is the timer callback function pointer */
307 | CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
308 |
309 | /* This is the argument passed to the timer callback */
310 | CINIT(TIMERDATA, OBJECTPOINT, 5),
311 |
312 | /* maximum number of entries in the connection cache */
313 | CINIT(MAXCONNECTS, LONG, 6),
314 |
315 | CURLMOPT_LASTENTRY /* the last unused */
316 | } CURLMoption;
317 |
318 |
319 | /*
320 | * Name: curl_multi_setopt()
321 | *
322 | * Desc: Sets options for the multi handle.
323 | *
324 | * Returns: CURLM error code.
325 | */
326 | CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
327 | CURLMoption option, ...);
328 |
329 |
330 | /*
331 | * Name: curl_multi_assign()
332 | *
333 | * Desc: This function sets an association in the multi handle between the
334 | * given socket and a private pointer of the application. This is
335 | * (only) useful for curl_multi_socket uses.
336 | *
337 | * Returns: CURLM error code.
338 | */
339 | CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
340 | curl_socket_t sockfd, void *sockp);
341 |
342 | #ifdef __cplusplus
343 | } /* end of extern "C" */
344 | #endif
345 |
346 | #endif
347 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/stdcheaders.h:
--------------------------------------------------------------------------------
1 | #ifndef __STDC_HEADERS_H
2 | #define __STDC_HEADERS_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at http://curl.haxx.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * $Id: stdcheaders.h,v 1.8 2004/01/07 09:19:34 bagder Exp $
24 | ***************************************************************************/
25 |
26 | #include
27 |
28 | size_t fread (void *, size_t, size_t, FILE *);
29 | size_t fwrite (const void *, size_t, size_t, FILE *);
30 |
31 | int strcasecmp(const char *, const char *);
32 | int strncasecmp(const char *, const char *, size_t);
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/vendor-lib/include/curl/types.h:
--------------------------------------------------------------------------------
1 | /* not used */
2 |
--------------------------------------------------------------------------------