Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 413 lines (350 sloc) 11.324 kb
188bc21 @falconindy copyright 2011
authored
1 /* Copyright (c) 2010-2011 Dave Reisner
f2388e9 @falconindy Initial commit
authored
2 *
1b6e92a @falconindy relicense as MIT/X
authored
3 * burp.c
f2388e9 @falconindy Initial commit
authored
4 *
1b6e92a @falconindy relicense as MIT/X
authored
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
f2388e9 @falconindy Initial commit
authored
13 *
1b6e92a @falconindy relicense as MIT/X
authored
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
f2388e9 @falconindy Initial commit
authored
25 */
26
78ea2ae @falconindy main: catch errors reported from creating a cookie file and bail accordi...
authored
27 #include <errno.h>
f2388e9 @falconindy Initial commit
authored
28 #include <getopt.h>
6008100 @diegonc Fix non-portable include.
diegonc authored
29 #include <limits.h>
b4c1ce5 @falconindy burp: catch SIGINT and cleanup after ourselves as to not pollute /tmp
authored
30 #include <signal.h>
becad7c @falconindy use stdbool instead of TRUE/FALSE macros
authored
31 #include <stdbool.h>
f2388e9 @falconindy Initial commit
authored
32 #include <stdio.h>
33 #include <stdlib.h>
edb5f76 @falconindy Ensure ECHO is set on terminal on SIGINT
authored
34 #include <termios.h>
2661d62 @falconindy Dynamically create a cookie file in /tmp based on the PID. Delete when w...
authored
35 #include <unistd.h>
67bf08a @falconindy config: use POSIX wordexp.h to expand path to cookie file
authored
36 #include <wordexp.h>
f2388e9 @falconindy Initial commit
authored
37
feba613 @falconindy burp.c: split off majority of functions to separate files
authored
38 #include "conf.h"
39 #include "curl.h"
40 #include "util.h"
f2388e9 @falconindy Initial commit
authored
41
3925d94 @falconindy main: semantic rearrangement
authored
42 #define NUM_CATEGORIES (sizeof(categories)/sizeof(categories[0]))
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
43 #define COOKIE_SIZE 1024
ff3b541 @falconindy remove llist. (ab)use a simple bounded stack
authored
44 #define TARGETMAX 32
3925d94 @falconindy main: semantic rearrangement
authored
45
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
46 /* forward decls */
47 static int category_is_valid(const char*);
48 static long cookie_expire_time(const char*, const char*, const char*);
49 static int fn_cmp_cat (const void*, const void*);
50 static int parseargs(int, char**);
51 static int read_config_file(void);
52 static void usage(void);
53 static void usage_categories(void);
54
3925d94 @falconindy main: semantic rearrangement
authored
55
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
56 /* structures */
88d54f4 @falconindy typedef struct definitions
authored
57 typedef struct __category_t {
3fd3671 @falconindy main: categories are sorted. use a binary search to determine validity
authored
58 const char *name;
1d5bfae @falconindy main: Create static array of structs for categories
authored
59 int num;
88d54f4 @falconindy typedef struct definitions
authored
60 } category_t;
1d5bfae @falconindy main: Create static array of structs for categories
authored
61
88d54f4 @falconindy typedef struct definitions
authored
62 static category_t categories[] = {
f7585c7 @falconindy main: remove 'none' category from array. users shouldn't be allowed to p...
authored
63 { "daemons", 2 }, { "devel", 3 }, { "editors", 4 },
64 { "emulators", 5 }, { "games", 6 }, { "gnome", 7 },
ccdba6d @falconindy main: fix silly ordering issue in category array. kernels must have been...
authored
65 { "i18n", 8 }, { "kde", 9 }, { "kernels", 19 },
66 { "lib", 10 }, { "modules", 11 }, { "multimedia", 12 },
67 { "network", 13 }, { "office", 14 }, { "science", 15 },
68 { "system", 16 }, { "x11", 17 }, { "xfce", 18 }
1d5bfae @falconindy main: Create static array of structs for categories
authored
69 };
70
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
71 int category_is_valid(const char *cat) {
72 category_t key, *res;
73
74 key.name = cat;
75
76 res = bsearch(&key, categories, NUM_CATEGORIES, sizeof(category_t), fn_cmp_cat);
77
78 return res ? res->num : -1;
79 }
80
81 long cookie_expire_time(const char *cookie_file,
82 const char *domain,
83 const char *name) {
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
84 FILE *fp;
85 long expire;
86 char cdomain[256], cname[256];
87
88 fp = fopen(cookie_file, "r");
89 if (!fp) {
90 return 0L;
91 }
92
93 for (;;) {
94 char l[COOKIE_SIZE];
95
96 cdomain[0] = cname[0] = '\0';
97 expire = 0L;
98
99 if(!(fgets(l, sizeof(l), fp))) {
100 break;
101 }
102
103 strtrim(l);
104
105 if (*l == '#' || strlen(l) == 0) {
106 continue;
107 }
108
e73eb74 @falconindy remove unused variable
authored
109 if (sscanf(l, "%s\t%*s\t%*s\t%*s\t%ld\t%s\t%*s", cdomain, &expire, cname) != 3) {
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
110 continue;
111 }
112
113 if (STREQ(domain, cdomain) && STREQ(name, cname)) {
73fa07c @falconindy use a sane debugging system
authored
114 debug("cookie found (expires %ld)\n", expire);
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
115 break;
116 }
117 }
118
119 fclose(fp);
120
e757d1f @falconindy return(val) => return val
authored
121 return expire;
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
122 }
123
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
124 int fn_cmp_cat (const void *c1, const void *c2) {
88d54f4 @falconindy typedef struct definitions
authored
125 category_t *cat1 = (category_t*)c1;
126 category_t *cat2 = (category_t*)c2;
3fd3671 @falconindy main: categories are sorted. use a binary search to determine validity
authored
127
e757d1f @falconindy return(val) => return val
authored
128 return strcmp(cat1->name, cat2->name);
3fd3671 @falconindy main: categories are sorted. use a binary search to determine validity
authored
129 }
130
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
131 int parseargs(int argc, char **argv) {
132 int opt;
133 int option_index = 0;
134 static struct option opts[] = {
135 {"help", no_argument, 0, 'h'},
136 {"user", required_argument, 0, 'u'},
137 {"password", required_argument, 0, 'p'},
138 {"keep-cookies", no_argument, 0, 'k'},
139 {"category", required_argument, 0, 'c'},
140 {"cookies", required_argument, 0, 'C'},
141 {"verbose", no_argument, 0, 'v'},
142 {0, 0, 0, 0}
143 };
3925d94 @falconindy main: semantic rearrangement
authored
144
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
145 while ((opt = getopt_long(argc, argv, "hu:p:kc:C:v", opts, &option_index))) {
146 if (opt < 0) {
147 break;
148 }
3925d94 @falconindy main: semantic rearrangement
authored
149
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
150 switch (opt) {
151 case 'h':
152 usage();
153 exit(0);
154 case 'c':
155 if (config->category) {
156 FREE(config->category);
157 }
158 config->category = strndup(optarg, 16);
159 break;
160 case 'C':
161 if (config->cookies) {
162 FREE(config->cookies);
163 }
164 config->cookies = strndup(optarg, PATH_MAX);
165 break;
166 case 'k':
becad7c @falconindy use stdbool instead of TRUE/FALSE macros
authored
167 config->persist = true;
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
168 break;
169 case 'p':
170 if (config->password) {
171 FREE(config->password);
172 }
173 config->password = strndup(optarg, AUR_PASSWORD_MAX);
174 break;
175 case 'u':
176 if (config->user) {
177 FREE(config->user);
178 }
179 config->user = strndup(optarg, AUR_USER_MAX);
180 break;
181 case 'v':
182 config->verbose++;
183 break;
dffbe41 @falconindy main: bugfix: fix stupid logical error that prevented the correct catego...
authored
184
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
185 case '?':
186 return 1;
187 default:
188 return 1;
189 }
190 }
191
192 return 0;
3925d94 @falconindy main: semantic rearrangement
authored
193 }
f2388e9 @falconindy Initial commit
authored
194
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
195 int read_config_file() {
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
196 int ret = 0;
197 char *ptr, *xdg_config_home;
a9978b7 @falconindy util: pre-increment maxlen and reuse it in fgets, since fgets will read ...
authored
198 char config_path[PATH_MAX + 1], line[BUFSIZ];
697c7c2 @falconindy check for config file before trying to open it
authored
199 FILE *conf_fd;
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
200
201 xdg_config_home = getenv("XDG_CONFIG_HOME");
0a494c8 @falconindy cleanup for style
authored
202 if (xdg_config_home) {
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
203 snprintf(&config_path[0], PATH_MAX, "%s/burp/burp.conf", xdg_config_home);
0a494c8 @falconindy cleanup for style
authored
204 } else {
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
205 snprintf(&config_path[0], PATH_MAX, "%s/.config/burp/burp.conf",
206 getenv("HOME"));
0a494c8 @falconindy cleanup for style
authored
207 }
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
208
697c7c2 @falconindy check for config file before trying to open it
authored
209 conf_fd = fopen(config_path, "r");
73fa07c @falconindy use a sane debugging system
authored
210 if (!conf_fd) {
211 debug("no config file found or not readable\n");
212 return ret;
0a494c8 @falconindy cleanup for style
authored
213 }
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
214
215 while (fgets(line, BUFSIZ, conf_fd)) {
cbabfd2 @falconindy minor cleanup, mostly to adhere to c89
authored
216 char *key;
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
217 strtrim(line);
218
0a494c8 @falconindy cleanup for style
authored
219 if (line[0] == '#' || strlen(line) == 0) {
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
220 continue;
0a494c8 @falconindy cleanup for style
authored
221 }
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
222
223 if ((ptr = strchr(line, '#'))) {
224 *ptr = '\0';
225 }
226
227 key = ptr = line;
228 strsep(&ptr, "=");
229 strtrim(key);
230 strtrim(ptr);
231
232 if (STREQ(key, "User")) {
233 if (config->user == NULL) {
234 config->user = strndup(ptr, AUR_USER_MAX);
73fa07c @falconindy use a sane debugging system
authored
235 debug("using username: %s\n", config->user);
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
236 }
237 } else if (STREQ(key, "Password")) {
238 if (config->password == NULL) {
239 config->password = strndup(ptr, AUR_PASSWORD_MAX);
73fa07c @falconindy use a sane debugging system
authored
240 debug("using password from config file.\n");
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
241 }
242 } else if (STREQ(key, "Cookies")) {
243 if (config->cookies == NULL) {
67bf08a @falconindy config: use POSIX wordexp.h to expand path to cookie file
authored
244 wordexp_t p;
245 if (wordexp(ptr, &p, 0) == 0) {
246 if (p.we_wordc == 1) {
247 config->cookies = strdup(p.we_wordv[0]);
73fa07c @falconindy use a sane debugging system
authored
248 debug("using cookie file: %s\n", config->cookies);
bb856cd @falconindy cookies: bugfix: break outside debug statement
authored
249 } else {
250 fprintf(stderr, "Ambiguous path to cookie file. Ignoring config option.\n");
67bf08a @falconindy config: use POSIX wordexp.h to expand path to cookie file
authored
251 }
252 wordfree(&p);
94f9aad @falconindy config: throw non-fatal perror on wordexp failure
authored
253 } else {
254 perror("wordexp");
255 ret = errno;
256 break;
67bf08a @falconindy config: use POSIX wordexp.h to expand path to cookie file
authored
257 }
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
258 }
259 } else if (STREQ(key, "Persist")) {
becad7c @falconindy use stdbool instead of TRUE/FALSE macros
authored
260 config->persist = true;
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
261 } else {
262 fprintf(stderr, "Error parsing config file: bad option '%s'\n", key);
263 ret = 1;
264 break;
265 }
266 }
267
268 fclose(conf_fd);
269
e757d1f @falconindy return(val) => return val
authored
270 return ret;
0ef2482 @falconindy conf: read config file from main and declare it static. it's a one time ...
authored
271 }
272
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
273 void usage() {
cbabfd2 @falconindy minor cleanup, mostly to adhere to c89
authored
274 fprintf(stderr, "burp %s\n"
275 "Usage: burp [options] targets...\n\n"
276 " Options:\n"
277 " -h, --help Shows this help message.\n"
278 " -u, --user AUR login username.\n"
279 " -p, --password AUR login password.\n", VERSION);
280 fprintf(stderr,
281 " -c CAT, --category=CAT Assign the uploaded package with category CAT.\n"
282 " This will default to the current category\n"
283 " for pre-existing packages and 'None' for new\n"
284 " packages. -c help will give a list of valid\n"
285 " categories.\n");
286 fprintf(stderr,
287 " -C FILE, --cookies=FILE Use FILE to store cookies rather than the default\n"
288 " temporary file. Useful with the -k option.\n"
289 " -k, --keep-cookies Cookies will be persistent and reused for logins.\n"
290 " If you specify this option, you must also provide\n"
291 " a path to a cookie file.\n"
292 " -v, --verbose be more verbose. Pass twice for debug info.\n\n"
293 " burp also honors a config file. See burp(1) for more information.\n\n");
f2388e9 @falconindy Initial commit
authored
294 }
295
2d6b3f9 @falconindy alphabetize functions. add forward decls
authored
296 void usage_categories() {
7cdc001 @falconindy fix compiler warning from -Wextra
authored
297 unsigned i;
cbabfd2 @falconindy minor cleanup, mostly to adhere to c89
authored
298
299 printf("Valid categories are:\n");
0a494c8 @falconindy cleanup for style
authored
300 for (i = 0; i < NUM_CATEGORIES; i++) {
1d5bfae @falconindy main: Create static array of structs for categories
authored
301 printf("\t%s\n", categories[i].name);
0a494c8 @falconindy cleanup for style
authored
302 }
67f5814 @falconindy Reuse curl connection to upload packages. Only call for easy_cleanup onc...
authored
303 putchar('\n');
304 }
305
f2388e9 @falconindy Initial commit
authored
306 int main(int argc, char **argv) {
becad7c @falconindy use stdbool instead of TRUE/FALSE macros
authored
307 int ret = 0, cookie_valid = false;
b4c1ce5 @falconindy burp: catch SIGINT and cleanup after ourselves as to not pollute /tmp
authored
308
feba613 @falconindy burp.c: split off majority of functions to separate files
authored
309 config = config_new();
5633157 @falconindy burp.c: minor cleanup. Only allocate a pointer for linked list traversel...
authored
310
f2388e9 @falconindy Initial commit
authored
311 ret = parseargs(argc, argv);
0a494c8 @falconindy cleanup for style
authored
312 if (ret != 0) {
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
313 goto finish;
0a494c8 @falconindy cleanup for style
authored
314 }
f2388e9 @falconindy Initial commit
authored
315
67f5814 @falconindy Reuse curl connection to upload packages. Only call for easy_cleanup onc...
authored
316 /* Ensure we have a proper config environment */
0a494c8 @falconindy cleanup for style
authored
317 if (config->category == NULL) {
67f5814 @falconindy Reuse curl connection to upload packages. Only call for easy_cleanup onc...
authored
318 config->category = "None";
0a494c8 @falconindy cleanup for style
authored
319 } else {
dffbe41 @falconindy main: bugfix: fix stupid logical error that prevented the correct catego...
authored
320 config->catnum = category_is_valid(config->category);
0a494c8 @falconindy cleanup for style
authored
321 }
322
6e36158 @falconindy dont explicitly zero out config struct. calloc does this for us
authored
323 if (config->catnum < 0) {
0a494c8 @falconindy cleanup for style
authored
324 usage_categories();
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
325 goto finish;
0a494c8 @falconindy cleanup for style
authored
326 }
67f5814 @falconindy Reuse curl connection to upload packages. Only call for easy_cleanup onc...
authored
327
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
328 if (optind == argc) {
755de9b @falconindy cleanup error output
authored
329 fprintf(stderr, "error: no packages specified (use -h for help)\n");
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
330 goto finish;
f2388e9 @falconindy Initial commit
authored
331 }
332
bb856cd @falconindy cookies: bugfix: break outside debug statement
authored
333 /* We can't read the config file without having verbosity set, but the
334 * command line options need to take precedence over the config. file.
335 * Therefore, if ((user && pass) || cookie file) is supplied on the command
336 * line, we won't read the config file.
9b452ab @falconindy main: only read config file if we weren't given enough information on th...
authored
337 */
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
338 if (!(config->user || config->cookies)) {
9b452ab @falconindy main: only read config file if we weren't given enough information on th...
authored
339 read_config_file();
0a494c8 @falconindy cleanup for style
authored
340 }
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
341
64d778d @falconindy main: Do a simple sanity check on the user's config before doing any hea...
authored
342 /* Quick sanity check */
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
343 if (config->persist && !config->cookies) {
755de9b @falconindy cleanup error output
authored
344 fprintf(stderr, "error: do not specify persistent "
345 "cookies without providing a path to a cookie file.\n");
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
346 goto finish;
64d778d @falconindy main: Do a simple sanity check on the user's config before doing any hea...
authored
347 }
348
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
349 /* Determine how we'll login -- either by cookie or credentials */
350 if (config->cookies != NULL) { /* User specified cookie file */
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
351 if (!access(config->cookies, R_OK) == 0) {
78ea2ae @falconindy main: catch errors reported from creating a cookie file and bail accordi...
authored
352 if (touch(config->cookies) != 0) {
353 fprintf(stderr, "Error creating cookie file: ");
354 perror(config->cookies);
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
355 goto finish;
78ea2ae @falconindy main: catch errors reported from creating a cookie file and bail accordi...
authored
356 }
fe3e994 @falconindy main: use more robust method of validating a cookie file
authored
357 } else { /* assume its a real cookie file and evaluate it */
7e00f72 @falconindy Check cookie for expiration before using.
authored
358 long expire = cookie_expire_time(config->cookies, AUR_URL_NO_PROTO , AUR_COOKIE_NAME);
359 if (expire > 0) {
21e6a86 @falconindy cookies: refactor parsing of cookie file
authored
360 if (time(NULL) < expire) {
becad7c @falconindy use stdbool instead of TRUE/FALSE macros
authored
361 cookie_valid = true;
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
362 } else {
7e00f72 @falconindy Check cookie for expiration before using.
authored
363 fprintf(stderr, "Your cookie has expired. Gathering user and password...\n");
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
364 }
7e00f72 @falconindy Check cookie for expiration before using.
authored
365 }
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
366 }
367 } else { /* create PID based file in /tmp */
8021660 @falconindy main: alter fallback cookie file creation to follow new signature
authored
368 if ((config->cookies = get_tmpfile(COOKIEFILE_FORMAT)) == NULL) {
78ea2ae @falconindy main: catch errors reported from creating a cookie file and bail accordi...
authored
369 fprintf(stderr, "error creating cookie file.\n");
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
370 goto finish;
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
371 }
372 }
f2388e9 @falconindy Initial commit
authored
373
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
374 if (!cookie_valid) {
73fa07c @falconindy use a sane debugging system
authored
375 debug("cookie auth will fail. Falling back to user/pass\n");
0342f73 @falconindy util: alter signature of get_username and get_password to return a char ...
authored
376
0a494c8 @falconindy cleanup for style
authored
377 if (config->user == NULL) {
58ed0b0 @falconindy merge get_{username,password} into read_stdin
authored
378 config->user = read_stdin("Enter username", AUR_USER_MAX, 1);
0a494c8 @falconindy cleanup for style
authored
379 }
e55945e @falconindy burp.c: present password prompt with name of user to auth as
authored
380
381 if (config->password == NULL) {
382 printf("[%s] ", config->user);
58ed0b0 @falconindy merge get_{username,password} into read_stdin
authored
383 config->password = read_stdin("Enter password", AUR_PASSWORD_MAX, 0);
e55945e @falconindy burp.c: present password prompt with name of user to auth as
authored
384 }
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
385 }
f2388e9 @falconindy Initial commit
authored
386
6fded30 @falconindy cleanup curl initialization/teardown routines. removes global curl var
authored
387 if (curl_init() != 0) {
b9f12a0 @falconindy main: check for errors while initializing curl and exit hard if either t...
authored
388 fprintf(stderr, "Error: An error occurred while initializing curl\n");
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
389 goto finish;
b9f12a0 @falconindy main: check for errors while initializing curl and exit hard if either t...
authored
390 }
30bdaa2 @falconindy Make sure to cleanup curl transaction, even after a failure.
authored
391
e614d76 @falconindy main: Add handling of -C and -k options. Reorganize logic in main to ski...
authored
392 if (cookie_valid || aur_login() == 0) {
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
393 while (optind < argc) {
394 aur_upload(argv[optind++]);
ff3b541 @falconindy remove llist. (ab)use a simple bounded stack
authored
395 }
8021660 @falconindy main: alter fallback cookie file creation to follow new signature
authored
396 }
f2388e9 @falconindy Initial commit
authored
397
73fa07c @falconindy use a sane debugging system
authored
398 debug("Cleaning up curl handle\n");
0a494c8 @falconindy cleanup for style
authored
399
6fded30 @falconindy cleanup curl initialization/teardown routines. removes global curl var
authored
400 curl_cleanup();
f2388e9 @falconindy Initial commit
authored
401
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
402 finish:
58e0259 @falconindy brainfart! remove stack, since argc/optind are useable in main
authored
403 if (config->cookies != NULL && !config->persist) {
73fa07c @falconindy use a sane debugging system
authored
404 debug("Deleting file %s\n", config->cookies);
e39c695 @falconindy exit in main. remove cleanup function and use a label
authored
405 unlink(config->cookies);
406 }
407
408 config_free(config);
409
e757d1f @falconindy return(val) => return val
authored
410 return ret;
f2388e9 @falconindy Initial commit
authored
411 }
6fded30 @falconindy cleanup curl initialization/teardown routines. removes global curl var
authored
412
Something went wrong with that request. Please try again.