... | ... |
@@ -82,6 +82,20 @@ int main(int argc, char **argv) |
82 | 82 |
} |
83 | 83 |
ctx->clamdopts = clamdopts; |
84 | 84 |
|
85 |
+ ret = startup_checks(ctx); |
|
86 |
+ if (ret) { |
|
87 |
+ goto clean_up; |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+#ifndef _WIN32 |
|
91 |
+ if (!optget(ctx->opts, "foreground")->enabled) { |
|
92 |
+ if (-1 == daemonize()) { |
|
93 |
+ logg("!Clamonacc: could not daemonize\n"); |
|
94 |
+ return 2; |
|
95 |
+ } |
|
96 |
+ } |
|
97 |
+#endif |
|
98 |
+ |
|
85 | 99 |
/* Setup our client */ |
86 | 100 |
switch(onas_setup_client(&ctx)) { |
87 | 101 |
case CL_SUCCESS: |
... | ... |
@@ -101,20 +115,6 @@ int main(int argc, char **argv) |
101 | 101 |
break; |
102 | 102 |
} |
103 | 103 |
|
104 |
- ret = startup_checks(ctx); |
|
105 |
- if (ret) { |
|
106 |
- goto clean_up; |
|
107 |
- } |
|
108 |
- |
|
109 |
-#ifndef _WIN32 |
|
110 |
- if (!optget(ctx->opts, "foreground")->enabled) { |
|
111 |
- if (-1 == daemonize()) { |
|
112 |
- logg("!Clamonacc: could not daemonize\n"); |
|
113 |
- return 2; |
|
114 |
- } |
|
115 |
- } |
|
116 |
-#endif |
|
117 |
- |
|
118 | 104 |
ctx->maxthreads = optget(ctx->clamdopts, "OnAccessMaxThreads")->numarg; |
119 | 105 |
|
120 | 106 |
/* Setup our event queue */ |
... | ... |
@@ -235,6 +235,11 @@ static int startup_checks(struct onas_context *ctx) { |
235 | 235 |
goto done; |
236 | 236 |
} |
237 | 237 |
|
238 |
+ if (curl_global_init(CURL_GLOBAL_NOTHING)) { |
|
239 |
+ ret = 2; |
|
240 |
+ goto done; |
|
241 |
+ } |
|
242 |
+ |
|
238 | 243 |
if (0 == onas_check_remote(&ctx, &err)) { |
239 | 244 |
if(!optget(ctx->clamdopts, "OnAccessExcludeUID")->enabled && |
240 | 245 |
!optget(ctx->clamdopts, "OnAccessExcludeUname")->enabled) { |
... | ... |
@@ -290,10 +290,6 @@ cl_error_t onas_setup_client (struct onas_context **ctx) { |
290 | 290 |
return CL_EARG; |
291 | 291 |
} |
292 | 292 |
|
293 |
- if (curl_global_init(CURL_GLOBAL_NOTHING)) { |
|
294 |
- return CL_EARG; |
|
295 |
- } |
|
296 |
- |
|
297 | 293 |
(*ctx)->timeout = optget((*ctx)->clamdopts, "OnAccessCurlTimeout")->numarg; |
298 | 294 |
(*ctx)->retry_attempts = optget((*ctx)->clamdopts, "OnAccessRetryAttempts")->numarg; |
299 | 295 |
(*ctx)->retry_attempts ? ((*ctx)->retry_on_error = 1) : ((*ctx)->retry_on_error = 0); |