1 | /*************************************************************************** |
---|
2 | $Id: mondo-cli.c 1628 2007-09-09 01:14:36Z bruno $ |
---|
3 | *******************************************************************/ |
---|
4 | |
---|
5 | /** |
---|
6 | * @file |
---|
7 | * Functions for handling command-line arguments passed to mondoarchive. |
---|
8 | */ |
---|
9 | |
---|
10 | /** @def BOOT_LOADER_CHARS The characters allowed for boot loader on this platform. */ |
---|
11 | |
---|
12 | #include "my-stuff.h" |
---|
13 | #include "mondostructures.h" |
---|
14 | #include "mondo-cli-EXT.h" |
---|
15 | #include "libmondo.h" |
---|
16 | #include <pthread.h> |
---|
17 | |
---|
18 | #include "mr_mem.h" |
---|
19 | #include "mr_msg.h" |
---|
20 | #include "mr_gettext.h" |
---|
21 | #include "mr_conf.h" |
---|
22 | |
---|
23 | //static char cvsid[] = "$Id: mondo-cli.c 1628 2007-09-09 01:14:36Z bruno $"; |
---|
24 | |
---|
25 | extern bool g_text_mode; |
---|
26 | extern char g_startdir[MAX_STR_LEN]; ///< ????? @bug ????? |
---|
27 | extern char g_erase_tmpdir_and_scratchdir[MAX_STR_LEN]; |
---|
28 | extern char g_tmpfs_mountpt[MAX_STR_LEN]; |
---|
29 | extern bool g_sigpipe; |
---|
30 | |
---|
31 | extern struct mr_ar_conf *mr_conf; |
---|
32 | |
---|
33 | /*@ file pointer **************************************************/ |
---|
34 | extern FILE *g_tape_stream; |
---|
35 | |
---|
36 | /*@ long long *****************************************************/ |
---|
37 | extern long long g_tape_posK; |
---|
38 | |
---|
39 | /*@ long **********************************************************/ |
---|
40 | extern long g_noof_sets; |
---|
41 | |
---|
42 | /*@ bool******** **************************************************/ |
---|
43 | bool g_debugging = FALSE; ///< ????? @bug ????? @ingroup globalGroup |
---|
44 | bool g_running_live = FALSE; ///< ????? @bug ????? @ingroup globalGroup |
---|
45 | extern bool g_cd_recovery; |
---|
46 | |
---|
47 | /** |
---|
48 | * Whether we're restoring from ISOs. Obviously not, since this is the |
---|
49 | * backup program. |
---|
50 | * @note You @b MUST declare this variable somewhere in your program if |
---|
51 | * you use libmondo. Otherwise the link will fail. |
---|
52 | * @ingroup globalGroup |
---|
53 | */ |
---|
54 | bool g_ISO_restore_mode = FALSE; |
---|
55 | |
---|
56 | extern double g_kernel_version; |
---|
57 | extern int g_current_media_number; |
---|
58 | extern pid_t g_main_pid; |
---|
59 | extern char *resolve_softlinks_to_get_to_actual_device_file(char *); |
---|
60 | |
---|
61 | /* Do we use extended attributes and acl ? |
---|
62 | * By default no, use --acl & --attr options to force their usage */ |
---|
63 | char *g_getfacl = NULL; |
---|
64 | char *g_getfattr = NULL; |
---|
65 | |
---|
66 | /** |
---|
67 | * @addtogroup cliGroup |
---|
68 | * @{ |
---|
69 | */ |
---|
70 | /** |
---|
71 | * Populate @p bkpinfo from the command-line parameters stored in @p argc and @p argv. |
---|
72 | * @param argc The argument count, including the program name; @p argc passed to main(). |
---|
73 | * @param argv The argument vector; @p argv passed to main(). |
---|
74 | * @param bkpinfo The backup information structure to populate. |
---|
75 | * @return The number of problems with the command line (0 for success). |
---|
76 | */ |
---|
77 | int |
---|
78 | handle_incoming_parameters(int argc, char *argv[], |
---|
79 | struct s_bkpinfo *bkpinfo) |
---|
80 | { |
---|
81 | /*@ int *** */ |
---|
82 | int res = 0; |
---|
83 | int retval = 0; |
---|
84 | int i = 0; |
---|
85 | |
---|
86 | /*@ buffers *************** */ |
---|
87 | char *tmp = NULL; |
---|
88 | char flag_val[128][MAX_STR_LEN]; |
---|
89 | bool flag_set[128]; |
---|
90 | |
---|
91 | sensibly_set_tmpdir_and_scratchdir(bkpinfo); |
---|
92 | |
---|
93 | for (i = 0; i < 128; i++) { |
---|
94 | flag_val[i][0] = '\0'; |
---|
95 | flag_set[i] = FALSE; |
---|
96 | } |
---|
97 | res = retrieve_switches_from_command_line(argc, argv, flag_val, |
---|
98 | flag_set); |
---|
99 | retval += res; |
---|
100 | if (!retval) { |
---|
101 | res = process_switches(bkpinfo, flag_val, flag_set); |
---|
102 | retval += res; |
---|
103 | } |
---|
104 | /* |
---|
105 | if (!retval) |
---|
106 | { |
---|
107 | */ |
---|
108 | mr_msg(3, "Switches:-"); |
---|
109 | for (i = 0; i < 128; i++) { |
---|
110 | if (flag_set[i]) { |
---|
111 | mr_msg(3, "-%c %s", i, flag_val[i]); |
---|
112 | } |
---|
113 | } |
---|
114 | // } |
---|
115 | mr_asprintf(&tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir); |
---|
116 | paranoid_system(tmp); |
---|
117 | mr_free(tmp); |
---|
118 | |
---|
119 | mr_asprintf(&tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir); |
---|
120 | paranoid_system(tmp); |
---|
121 | mr_free(tmp); |
---|
122 | |
---|
123 | sprintf(bkpinfo->tmpdir + strlen(bkpinfo->tmpdir), "/tmp.mondo.%ld", |
---|
124 | random() % 32767); |
---|
125 | sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir), |
---|
126 | "/mondo.scratch.%ld", random() % 32767); |
---|
127 | |
---|
128 | mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); |
---|
129 | paranoid_system(tmp); |
---|
130 | mr_free(tmp); |
---|
131 | |
---|
132 | mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir); |
---|
133 | paranoid_system(tmp); |
---|
134 | mr_free(tmp); |
---|
135 | return (retval); |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | /** |
---|
140 | * Store the sizespec(s) stored in @p value into @p bkpinfo. |
---|
141 | * @param bkpinfo The backup information structure; the @c bkpinfo->media_size field will be populated. |
---|
142 | * @param value The sizespec (e.g. "2g", "40m"). |
---|
143 | * @return 0, always. |
---|
144 | * @bug Return code not needed. |
---|
145 | */ |
---|
146 | int process_the_s_switch(struct s_bkpinfo *bkpinfo, char *value) |
---|
147 | { |
---|
148 | char *tmp = NULL; |
---|
149 | char *q = NULL; |
---|
150 | |
---|
151 | assert(bkpinfo != NULL); |
---|
152 | assert(value != NULL); |
---|
153 | |
---|
154 | mr_asprintf(&tmp, value); |
---|
155 | q = strchr(tmp, ','); |
---|
156 | if (q != NULL) { |
---|
157 | *q = '\0'; |
---|
158 | } |
---|
159 | bkpinfo->media_size = friendly_sizestr_to_sizelong(tmp); |
---|
160 | mr_free(tmp); |
---|
161 | |
---|
162 | mr_msg(3, "media_size = %ld", bkpinfo->media_size); |
---|
163 | if (bkpinfo->media_size <= 0L) { |
---|
164 | mr_msg(1, "You gave media an invalid size\n"); |
---|
165 | return (-1); |
---|
166 | } |
---|
167 | return (0); |
---|
168 | } |
---|
169 | |
---|
170 | |
---|
171 | /** |
---|
172 | * Process mondoarchive's command-line switches. |
---|
173 | * @param bkpinfo The backup information structure to populate. |
---|
174 | * @param flag_val An array of the argument passed to each switch (the letter is the index). |
---|
175 | * If a switch is not set or has no argument, the field in @p flag_val doesn't matter. |
---|
176 | * @param flag_set An array of <tt>bool</tt>s indexed by switch letter: TRUE if it's set, |
---|
177 | * FALSE if it's not. |
---|
178 | * @return The number of problems with the switches, or 0 for success. |
---|
179 | * @bug Maybe include a list of all switches (inc. intentionally undocumented ones not in the manual!) here? |
---|
180 | */ |
---|
181 | int |
---|
182 | process_switches(struct s_bkpinfo *bkpinfo, |
---|
183 | char flag_val[128][MAX_STR_LEN], bool flag_set[128]) |
---|
184 | { |
---|
185 | |
---|
186 | /*@ ints *** */ |
---|
187 | int i = 0; |
---|
188 | int retval = 0; |
---|
189 | int percent = 0; |
---|
190 | |
---|
191 | /*@ buffers ** */ |
---|
192 | char *tmp = NULL; |
---|
193 | char *tmp1 = NULL; |
---|
194 | char *tmp2 = NULL; |
---|
195 | char *psz = NULL; |
---|
196 | char *p = NULL; |
---|
197 | char *q = NULL; |
---|
198 | |
---|
199 | long itbs = 0L; |
---|
200 | |
---|
201 | struct stat buf; |
---|
202 | |
---|
203 | malloc_string(tmp); |
---|
204 | |
---|
205 | assert(bkpinfo != NULL); |
---|
206 | assert(flag_val != NULL); |
---|
207 | assert(flag_set != NULL); |
---|
208 | |
---|
209 | bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; |
---|
210 | |
---|
211 | /* compulsory */ |
---|
212 | i = flag_set['i'] + flag_set['n'] + |
---|
213 | flag_set['t'] + flag_set['u'] + flag_set['r'] + |
---|
214 | flag_set['w'] + flag_set['C'] + flag_set['U']; |
---|
215 | if (i == 0) { |
---|
216 | retval++; |
---|
217 | log_to_screen(_("You must specify the media type\n")); |
---|
218 | } |
---|
219 | if (i > 1) { |
---|
220 | retval++; |
---|
221 | log_to_screen(_("Please specify only one media type\n")); |
---|
222 | } |
---|
223 | if (flag_set['K']) { |
---|
224 | mr_conf->log_level = atoi(flag_val['K']); |
---|
225 | if (mr_conf->log_level < 3) { |
---|
226 | mr_conf->log_level = 3; |
---|
227 | } |
---|
228 | } |
---|
229 | if (flag_set['L'] && flag_set['0']) { |
---|
230 | retval++; |
---|
231 | log_to_screen(_("You cannot have 'no compression' _and_ LZOP.\n")); |
---|
232 | } |
---|
233 | bkpinfo->backup_data = flag_set['O']; |
---|
234 | bkpinfo->verify_data = flag_set['V']; |
---|
235 | if (flag_set['I'] && !bkpinfo->backup_data) { |
---|
236 | log_to_screen(_("-I switch is ignored if just verifying")); |
---|
237 | } |
---|
238 | if (flag_set['E'] && !bkpinfo->backup_data) { |
---|
239 | log_to_screen(_("-E switch is ignored if just verifying")); |
---|
240 | } |
---|
241 | |
---|
242 | if (!find_home_of_exe("afio")) { |
---|
243 | if (find_home_of_exe("star")) { |
---|
244 | flag_set['R'] = TRUE; |
---|
245 | mr_msg(1, "Using star instead of afio"); |
---|
246 | } else { |
---|
247 | fatal_error |
---|
248 | ("Neither afio nor star is installed. Please install at least one."); |
---|
249 | } |
---|
250 | } |
---|
251 | |
---|
252 | if (flag_set['R']) { |
---|
253 | bkpinfo->use_star = TRUE; |
---|
254 | if (flag_set['L']) { |
---|
255 | fatal_error("You may not use star and lzop at the same time."); |
---|
256 | } |
---|
257 | if (!find_home_of_exe("star")) { |
---|
258 | fatal_error |
---|
259 | ("Please install 'star' RPM or tarball if you are going to use -R. Thanks."); |
---|
260 | } |
---|
261 | } |
---|
262 | if (flag_set['W']) { |
---|
263 | bkpinfo->nonbootable_backup = TRUE; |
---|
264 | log_to_screen("Warning - you have opted for non-bootable backup"); |
---|
265 | if (flag_set['f'] || flag_set['l']) { |
---|
266 | log_to_screen |
---|
267 | (_("You don't need to specify bootloader or bootdevice")); |
---|
268 | } |
---|
269 | } |
---|
270 | if (flag_set['t'] && flag_set['H']) { |
---|
271 | fatal_error |
---|
272 | ("Sorry, you may not nuke w/o warning from tape. Drop -H, please."); |
---|
273 | } |
---|
274 | if (flag_set['I']) { |
---|
275 | if (!strcmp(bkpinfo->include_paths, "/")) { |
---|
276 | mr_msg(2, "'/' is pleonastic."); |
---|
277 | bkpinfo->include_paths[0] = '\0'; |
---|
278 | } |
---|
279 | if (bkpinfo->include_paths[0]) { |
---|
280 | strcat(bkpinfo->include_paths, " "); |
---|
281 | } |
---|
282 | mr_asprintf(&tmp1, flag_val['I']); |
---|
283 | p = tmp1; |
---|
284 | q = tmp1; |
---|
285 | |
---|
286 | /* Cut the flag_val['I'] in parts containing all paths to test them */ |
---|
287 | while (p != NULL) { |
---|
288 | q = strchr(p, ' '); |
---|
289 | if (q != NULL) { |
---|
290 | *q = '\0'; |
---|
291 | if (stat(p, &buf) != 0) { |
---|
292 | mr_msg(1, "ERROR ! %s doesn't exist", p); |
---|
293 | fatal_error("ERROR ! You specified a directory to include which doesn't exist"); |
---|
294 | } |
---|
295 | p = q+1 ; |
---|
296 | } else { |
---|
297 | if (stat(p, &buf) != 0) { |
---|
298 | mr_msg(1, "ERROR ! %s doesn't exist", p); |
---|
299 | fatal_error("ERROR ! You specified a directory to include which doesn't exist"); |
---|
300 | } |
---|
301 | p = NULL; |
---|
302 | } |
---|
303 | } |
---|
304 | mr_free(tmp1); |
---|
305 | |
---|
306 | strncpy(bkpinfo->include_paths + strlen(bkpinfo->include_paths), |
---|
307 | flag_val['I'], |
---|
308 | 4*MAX_STR_LEN - strlen(bkpinfo->include_paths)); |
---|
309 | mr_msg(1, "include_paths is now '%s'", bkpinfo->include_paths); |
---|
310 | if (bkpinfo->include_paths[0] == '-') { |
---|
311 | retval++; |
---|
312 | log_to_screen(_("Please supply a sensible value with '-I'\n")); |
---|
313 | } |
---|
314 | } |
---|
315 | |
---|
316 | if (g_kernel_version >= 2.6 && !flag_set['d'] |
---|
317 | && flag_set['w']) { |
---|
318 | fatal_error |
---|
319 | ("If you are using the 2.6.x kernel, please specify the CD-R(W) device."); |
---|
320 | } |
---|
321 | |
---|
322 | if (flag_set['J']) { |
---|
323 | if (flag_set['I']) { |
---|
324 | retval++; |
---|
325 | log_to_screen |
---|
326 | (_("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't combine -J with -I. Thanks. :-)")); |
---|
327 | } |
---|
328 | bkpinfo->make_filelist = FALSE; |
---|
329 | strcpy(bkpinfo->include_paths, flag_val['J']); |
---|
330 | } |
---|
331 | |
---|
332 | if (flag_set['w'] || flag_set['C'] || flag_set['r']) { |
---|
333 | if (!flag_set['r'] && g_kernel_version <= 2.5 |
---|
334 | && strstr(flag_val['d'], "/dev/")) { |
---|
335 | fatal_error |
---|
336 | ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag."); |
---|
337 | } |
---|
338 | if (flag_set['r'] && g_kernel_version <= 2.5 |
---|
339 | && !strstr(flag_val['d'], "/dev/")) { |
---|
340 | fatal_error |
---|
341 | ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag."); |
---|
342 | } |
---|
343 | if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) { |
---|
344 | log_to_screen |
---|
345 | (_("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...")); |
---|
346 | } |
---|
347 | |
---|
348 | if (system("which cdrecord > /dev/null 2> /dev/null") |
---|
349 | && system("which dvdrecord > /dev/null 2> /dev/null")) { |
---|
350 | fatal_error |
---|
351 | ("Please install dvdrecord/cdrecord and try again."); |
---|
352 | } |
---|
353 | if (flag_set['w']) { |
---|
354 | mr_msg(3, "flag_val['w'] = %s", flag_val['w']); |
---|
355 | bkpinfo->writer_speed = atoi(flag_val['w']); |
---|
356 | } |
---|
357 | |
---|
358 | if (bkpinfo->writer_speed < 1) { |
---|
359 | fatal_error |
---|
360 | ("You specified a silly speed for a burner"); |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | if (flag_set['t'] && !flag_set['d']) { |
---|
365 | log_it("Hmm! No tape drive specified. Let's see what we can do."); |
---|
366 | if (find_tape_device_and_size(flag_val['d'], tmp)) { |
---|
367 | log_to_screen |
---|
368 | ("Tape device not specified. I had problems to find it either"); |
---|
369 | } |
---|
370 | flag_set['d'] = TRUE; |
---|
371 | mr_asprintf(&tmp2, |
---|
372 | _("You didn't specify a tape streamer device. I'm assuming %s"), |
---|
373 | flag_val['d']); |
---|
374 | log_to_screen(tmp2); |
---|
375 | mr_free(tmp2); |
---|
376 | percent = 0; |
---|
377 | } |
---|
378 | |
---|
379 | if (flag_set['U']) // USB |
---|
380 | { |
---|
381 | if (! flag_set['d']) { |
---|
382 | fatal_error |
---|
383 | ("You need to specify a device file with -d for bootable USB device creation"); |
---|
384 | } |
---|
385 | if (!flag_set['s']) { |
---|
386 | fatal_error("You did not specify a size (-s) for your USB device. Aborting"); |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | if (flag_set['r']) // DVD |
---|
391 | { |
---|
392 | if (flag_set['m']) { |
---|
393 | fatal_error |
---|
394 | ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m."); |
---|
395 | } |
---|
396 | if (!flag_set['d']) { |
---|
397 | if (!find_dvd_device(flag_val['d'], FALSE)) { |
---|
398 | flag_set['d'] = TRUE; |
---|
399 | log_to_screen(_("I guess DVD drive is at %s"), flag_val['d']); |
---|
400 | } |
---|
401 | } |
---|
402 | if (!find_home_of_exe("growisofs")) { |
---|
403 | fatal_error |
---|
404 | ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it."); |
---|
405 | } |
---|
406 | if (!find_home_of_exe("dvd+rw-format")) { |
---|
407 | fatal_error |
---|
408 | ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it."); |
---|
409 | } |
---|
410 | if (strchr(flag_val['d'], ',')) { |
---|
411 | fatal_error |
---|
412 | ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); |
---|
413 | } |
---|
414 | } |
---|
415 | |
---|
416 | if (flag_set['t'] || flag_set['u']) { /* tape size */ |
---|
417 | if (strchr(flag_val['d'], ',')) { |
---|
418 | fatal_error |
---|
419 | ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); |
---|
420 | } |
---|
421 | if (flag_set['O']) { |
---|
422 | if (flag_set['s']) { |
---|
423 | if (flag_set['t']) { |
---|
424 | fatal_error |
---|
425 | ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway."); |
---|
426 | } |
---|
427 | if (process_the_s_switch(bkpinfo, flag_val['s'])) { |
---|
428 | fatal_error("Bad -s switch"); |
---|
429 | } |
---|
430 | } else if (flag_set['u'] || flag_set['t']) { |
---|
431 | /* Force autidetection */ |
---|
432 | bkpinfo->media_size = 0L; |
---|
433 | } else { |
---|
434 | retval++; |
---|
435 | log_to_screen("Tape size not specified.\n"); |
---|
436 | } |
---|
437 | } |
---|
438 | } else { /* CD|USB size */ |
---|
439 | if (flag_set['s']) { |
---|
440 | if (process_the_s_switch(bkpinfo, flag_val['s'])) { |
---|
441 | fatal_error("Bad -s switch"); |
---|
442 | } |
---|
443 | } |
---|
444 | if (flag_set['w']) { |
---|
445 | bkpinfo->wipe_media_first = TRUE; |
---|
446 | } /* CD-RW */ |
---|
447 | } |
---|
448 | if (flag_set['n']) { |
---|
449 | strncpy(bkpinfo->nfs_mount, flag_val['n'], MAX_STR_LEN); |
---|
450 | if (!flag_set['d']) { |
---|
451 | strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN); |
---|
452 | } |
---|
453 | mr_asprintf(&tmp2, "mount | grep -E '^%s .*$' | cut -d' ' -f3", |
---|
454 | bkpinfo->nfs_mount); |
---|
455 | strncpy(bkpinfo->isodir, |
---|
456 | call_program_and_get_last_line_of_output(tmp2), |
---|
457 | MAX_STR_LEN / 4); |
---|
458 | mr_free(tmp2); |
---|
459 | if (strlen(bkpinfo->isodir) < 3) { |
---|
460 | retval++; |
---|
461 | log_to_screen(_("NFS share is not mounted. Please mount it.\n")); |
---|
462 | } |
---|
463 | mr_msg(3, "mount = %s", bkpinfo->nfs_mount); |
---|
464 | mr_msg(3, "isodir= %s", bkpinfo->isodir); |
---|
465 | } |
---|
466 | |
---|
467 | if (flag_set['C']) { |
---|
468 | bkpinfo->backup_media_type = cdstream; |
---|
469 | } |
---|
470 | if (flag_set['i']) { |
---|
471 | bkpinfo->backup_media_type = iso; |
---|
472 | } |
---|
473 | if (flag_set['n']) { |
---|
474 | bkpinfo->backup_media_type = nfs; |
---|
475 | } |
---|
476 | if (flag_set['r']) { |
---|
477 | bkpinfo->backup_media_type = dvd; |
---|
478 | } |
---|
479 | if (flag_set['t']) { |
---|
480 | bkpinfo->backup_media_type = tape; |
---|
481 | } |
---|
482 | if (flag_set['u']) { |
---|
483 | bkpinfo->backup_media_type = udev; |
---|
484 | } |
---|
485 | if (flag_set['w']) { |
---|
486 | bkpinfo->backup_media_type = cdrw; |
---|
487 | } |
---|
488 | if (flag_set['U']) { |
---|
489 | bkpinfo->backup_media_type = usb; |
---|
490 | } |
---|
491 | if (flag_set['z']) { |
---|
492 | if (find_home_of_exe("getfattr")) { |
---|
493 | mr_asprintf(&g_getfattr,"getfattr"); |
---|
494 | } |
---|
495 | if (find_home_of_exe("getfacl")) { |
---|
496 | mr_asprintf(&g_getfacl,"getfacl"); |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | /* optional, popular */ |
---|
501 | if (flag_set['g']) { |
---|
502 | g_text_mode = FALSE; |
---|
503 | } |
---|
504 | |
---|
505 | if (flag_set['E']) { |
---|
506 | if (bkpinfo->exclude_paths[0]) { |
---|
507 | strcat(bkpinfo->exclude_paths, " "); |
---|
508 | } |
---|
509 | mr_asprintf(&tmp1, flag_val['E']); |
---|
510 | p = tmp1; |
---|
511 | q = tmp1; |
---|
512 | |
---|
513 | /* Cut the flag_val['E'] in parts containing all paths to test them */ |
---|
514 | while (p != NULL) { |
---|
515 | q = strchr(p, ' '); |
---|
516 | if (q != NULL) { |
---|
517 | *q = '\0'; |
---|
518 | /* Fix bug 14 where ending / cause a problem later |
---|
519 | * so handled here for the moment */ |
---|
520 | q--; |
---|
521 | if (*q == '/') { |
---|
522 | *q = '\0'; |
---|
523 | } |
---|
524 | q++; |
---|
525 | /* End of bug fix */ |
---|
526 | if (stat(p, &buf) != 0) { |
---|
527 | mr_msg(1, "WARNING ! %s doesn't exist", p); |
---|
528 | } |
---|
529 | p = q+1 ; |
---|
530 | } else { |
---|
531 | if (stat(p, &buf) != 0) { |
---|
532 | mr_msg(1, "WARNING ! %s doesn't exist", p); |
---|
533 | } |
---|
534 | p = NULL; |
---|
535 | } |
---|
536 | } |
---|
537 | mr_free(tmp1); |
---|
538 | |
---|
539 | strncpy(bkpinfo->exclude_paths + strlen(bkpinfo->exclude_paths), |
---|
540 | flag_val['E'], |
---|
541 | 4*MAX_STR_LEN - strlen(bkpinfo->exclude_paths)); |
---|
542 | } |
---|
543 | if (flag_set['e']) { |
---|
544 | bkpinfo->please_dont_eject = TRUE; |
---|
545 | } |
---|
546 | if (flag_set['N']) // exclude NFS mounts & devices |
---|
547 | { |
---|
548 | mr_asprintf(&psz, list_of_NFS_mounts_only()); |
---|
549 | if (bkpinfo->exclude_paths[0]) { |
---|
550 | strncat(bkpinfo->exclude_paths, " ", 4*MAX_STR_LEN); |
---|
551 | } |
---|
552 | strncat(bkpinfo->exclude_paths, psz, 4*MAX_STR_LEN); |
---|
553 | mr_free(psz); |
---|
554 | mr_msg(3, "-N means we're now excluding %s", |
---|
555 | bkpinfo->exclude_paths); |
---|
556 | } |
---|
557 | if (strlen(bkpinfo->exclude_paths) >= 4*MAX_STR_LEN) { |
---|
558 | fatal_error |
---|
559 | ("Your '-E' parameter is too long. Increase MAX_STR_LEN"); |
---|
560 | } |
---|
561 | if (flag_set['b']) { |
---|
562 | mr_asprintf(&psz, flag_val['b']); |
---|
563 | mr_msg(1, "psz = '%s'", psz); |
---|
564 | if (psz[strlen(psz) - 1] == 'k') { |
---|
565 | psz[strlen(psz) - 1] = '\0'; |
---|
566 | itbs = atol(psz) * 1024L; |
---|
567 | } else { |
---|
568 | itbs = atol(psz); |
---|
569 | } |
---|
570 | mr_free(psz); |
---|
571 | |
---|
572 | mr_msg(1, "'%s' --> %ld", flag_val['b'], itbs); |
---|
573 | mr_msg(1, "Internal tape block size is now %ld bytes", itbs); |
---|
574 | if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) { |
---|
575 | fatal_error |
---|
576 | ("Are you nuts? Silly, your internal tape block size is. Abort, I shall."); |
---|
577 | } |
---|
578 | bkpinfo->internal_tape_block_size = itbs; |
---|
579 | } |
---|
580 | |
---|
581 | if (flag_set['D']) { |
---|
582 | bkpinfo->differential = 1; |
---|
583 | // bkpinfo->differential = atoi (flag_val['D']); |
---|
584 | if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) { |
---|
585 | fatal_error |
---|
586 | ("The D option should be between 1 and 9 inclusive"); |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | if (flag_set['x']) { |
---|
591 | strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4); |
---|
592 | if (run_program_and_log_output("which ntfsclone", 2)) { |
---|
593 | fatal_error("Please install ntfsprogs package/tarball."); |
---|
594 | } |
---|
595 | } |
---|
596 | if (flag_set['m']) { |
---|
597 | bkpinfo->manual_tray = TRUE; |
---|
598 | } |
---|
599 | if (flag_set['k']) { |
---|
600 | strncpy(bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN); |
---|
601 | if (!strcmp(bkpinfo->kernel_path, "failsafe")) { |
---|
602 | strcpy(bkpinfo->kernel_path, "FAILSAFE"); |
---|
603 | } |
---|
604 | if (strcmp(bkpinfo->kernel_path, "FAILSAFE") |
---|
605 | && !does_file_exist(bkpinfo->kernel_path)) { |
---|
606 | retval++; |
---|
607 | mr_asprintf(&tmp2, |
---|
608 | _("You specified kernel '%s', which does not exist\n"), |
---|
609 | bkpinfo->kernel_path); |
---|
610 | log_to_screen(tmp2); |
---|
611 | mr_free(tmp2); |
---|
612 | } |
---|
613 | } |
---|
614 | |
---|
615 | if (flag_set['p']) { |
---|
616 | mr_allocstr(bkpinfo->prefix, flag_val['p']); |
---|
617 | } |
---|
618 | |
---|
619 | if (flag_set['d']) { /* backup directory (if ISO/NFS/USB) */ |
---|
620 | if (flag_set['i']) { |
---|
621 | strncpy(bkpinfo->isodir, flag_val['d'], MAX_STR_LEN / 4); |
---|
622 | mr_asprintf(&tmp2, "ls -l %s", bkpinfo->isodir); |
---|
623 | if (run_program_and_log_output(tmp2, FALSE)) { |
---|
624 | fatal_error |
---|
625 | ("output folder does not exist - please create it"); |
---|
626 | } |
---|
627 | mr_free(tmp2); |
---|
628 | } else if (flag_set['n']) { |
---|
629 | strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN); |
---|
630 | } else { /* backup device (if tape/CD-R/CD-RW) */ |
---|
631 | mr_asprintf(&tmp2,flag_val['d']); |
---|
632 | mr_free(bkpinfo->media_device); |
---|
633 | bkpinfo->media_device = tmp2; |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|
637 | if (flag_set['n']) { |
---|
638 | mr_asprintf(&tmp2, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, |
---|
639 | bkpinfo->nfs_remote_dir); |
---|
640 | if (run_program_and_log_output(tmp2, FALSE)) { |
---|
641 | retval++; |
---|
642 | mr_free(tmp2); |
---|
643 | mr_asprintf(&tmp2, |
---|
644 | _("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n"), |
---|
645 | bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); |
---|
646 | log_to_screen(tmp2); |
---|
647 | } |
---|
648 | mr_free(tmp2); |
---|
649 | } |
---|
650 | |
---|
651 | if (!flag_set['d'] |
---|
652 | && (flag_set['w'] || flag_set['C'] || flag_set['U'])) { |
---|
653 | if (bkpinfo->media_device) { |
---|
654 | mr_msg(4, "Using device %s", bkpinfo->media_device); |
---|
655 | strncpy(flag_val['d'], bkpinfo->media_device, MAX_STR_LEN / 4); |
---|
656 | flag_set['d'] = TRUE; |
---|
657 | } else { |
---|
658 | fatal_error(_("No device provided either on command line or in the configuration file")); |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | if (!flag_set['d'] && !flag_set['n'] && !flag_set['C']) { |
---|
663 | retval++; |
---|
664 | log_to_screen(_("Please specify the backup device/directory.\n")); |
---|
665 | fatal_error |
---|
666 | ("You didn't use -d to specify the backup device/directory."); |
---|
667 | } |
---|
668 | /* optional, obscure */ |
---|
669 | for (i = '0'; i <= '9'; i++) { |
---|
670 | if (flag_set[i]) { |
---|
671 | bkpinfo->compression_level = i - '0'; |
---|
672 | } /* not '\0' but '0' */ |
---|
673 | } |
---|
674 | if (flag_set['S']) { |
---|
675 | sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'], |
---|
676 | random() % 32768); |
---|
677 | } |
---|
678 | if (flag_set['T']) { |
---|
679 | sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'], |
---|
680 | random() % 32768); |
---|
681 | mr_asprintf(&tmp2, "touch %s/.foo.dat", flag_val['T']); |
---|
682 | if (run_program_and_log_output(tmp2, 1)) { |
---|
683 | retval++; |
---|
684 | log_to_screen |
---|
685 | (_("Please specify a tempdir which I can write to. :)")); |
---|
686 | fatal_error("I cannot write to the tempdir you specified."); |
---|
687 | } |
---|
688 | mr_free(tmp2); |
---|
689 | |
---|
690 | mr_asprintf(&tmp2, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], |
---|
691 | flag_val['T']); |
---|
692 | if (run_program_and_log_output(tmp2, 1)) { |
---|
693 | retval++; |
---|
694 | log_to_screen |
---|
695 | (_("Please don't specify a SAMBA or VFAT or NFS tmpdir.")); |
---|
696 | fatal_error("I cannot write to the tempdir you specified."); |
---|
697 | } |
---|
698 | mr_free(tmp2); |
---|
699 | } |
---|
700 | |
---|
701 | if (flag_set['A']) { |
---|
702 | strncpy(bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN); |
---|
703 | } |
---|
704 | if (flag_set['B']) { |
---|
705 | strncpy(bkpinfo->call_before_iso, flag_val['B'], MAX_STR_LEN); |
---|
706 | } |
---|
707 | if (flag_set['H']) { |
---|
708 | g_cd_recovery = TRUE; |
---|
709 | } |
---|
710 | if (flag_set['l']) { |
---|
711 | #ifdef __FreeBSD__ |
---|
712 | # define BOOT_LOADER_CHARS "GLBMR" |
---|
713 | #else |
---|
714 | # ifdef __IA64__ |
---|
715 | # define BOOT_LOADER_CHARS "GER" |
---|
716 | # else |
---|
717 | # define BOOT_LOADER_CHARS "GLR" |
---|
718 | # endif |
---|
719 | #endif |
---|
720 | if (!strchr |
---|
721 | (BOOT_LOADER_CHARS, |
---|
722 | (bkpinfo->boot_loader = flag_val['l'][0]))) { |
---|
723 | mr_msg(1, "%c? What is %c? I need G, L, E or R.", |
---|
724 | bkpinfo->boot_loader, bkpinfo->boot_loader); |
---|
725 | fatal_error |
---|
726 | ("Please specify GRUB, LILO, ELILO or RAW with the -l switch"); |
---|
727 | } |
---|
728 | #undef BOOT_LOADER_CHARS |
---|
729 | } |
---|
730 | |
---|
731 | if (flag_set['f']) { |
---|
732 | strncpy(bkpinfo->boot_device, |
---|
733 | resolve_softlinks_to_get_to_actual_device_file(flag_val |
---|
734 | ['f']), |
---|
735 | MAX_STR_LEN / 4); |
---|
736 | } |
---|
737 | |
---|
738 | if (flag_set['Q']) { |
---|
739 | if (bkpinfo->boot_device == NULL) { |
---|
740 | fatal_error("-f option required when using -Q\n"); |
---|
741 | } |
---|
742 | i = which_boot_loader(bkpinfo->boot_device); |
---|
743 | mr_msg(3, "boot loader is %c, residing at %s", i, bkpinfo->boot_device); |
---|
744 | log_to_screen(_("boot loader is %c, residing at %s\n"), i, tmp); |
---|
745 | finish(0); |
---|
746 | } |
---|
747 | |
---|
748 | if (flag_set['P']) { |
---|
749 | strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN); |
---|
750 | } |
---|
751 | |
---|
752 | if (flag_set['L']) { |
---|
753 | bkpinfo->use_lzo = TRUE; |
---|
754 | if (run_program_and_log_output("which lzop", FALSE)) { |
---|
755 | retval++; |
---|
756 | log_to_screen |
---|
757 | (_("Please install LZOP. You can't use '-L' until you do.\n")); |
---|
758 | } |
---|
759 | } |
---|
760 | |
---|
761 | if (flag_set['G']) { |
---|
762 | bkpinfo->use_gzip = TRUE; |
---|
763 | if (run_program_and_log_output("which gzip", FALSE)) { |
---|
764 | retval++; |
---|
765 | log_to_screen |
---|
766 | ("Please install gzip. You can't use '-G' until you do.\n"); |
---|
767 | } |
---|
768 | } |
---|
769 | |
---|
770 | if (!flag_set['o'] |
---|
771 | && |
---|
772 | !run_program_and_log_output |
---|
773 | ("grep -Ei suse /etc/issue.net | grep -E '9.0' | grep 64", TRUE)) { |
---|
774 | bkpinfo->make_cd_use_lilo = TRUE; |
---|
775 | log_to_screen |
---|
776 | (_("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary.")); |
---|
777 | } |
---|
778 | |
---|
779 | if (flag_set['o']) { |
---|
780 | bkpinfo->make_cd_use_lilo = TRUE; |
---|
781 | } |
---|
782 | #ifndef __FreeBSD__ |
---|
783 | else { |
---|
784 | if (!is_this_a_valid_disk_format("vfat")) { |
---|
785 | bkpinfo->make_cd_use_lilo = TRUE; |
---|
786 | log_to_screen |
---|
787 | (_("Your kernel appears not to support vfat filesystems. I am therefore")); |
---|
788 | log_to_screen |
---|
789 | (_("using LILO instead of SYSLINUX as the CD's boot loader.")); |
---|
790 | } |
---|
791 | if (run_program_and_log_output("which mkfs.vfat", FALSE)) { |
---|
792 | bkpinfo->make_cd_use_lilo = TRUE; |
---|
793 | #ifdef __IA32__ |
---|
794 | log_to_screen |
---|
795 | (_("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as")); |
---|
796 | log_to_screen |
---|
797 | (_("your boot loader. I shall therefore use LILO instead.")); |
---|
798 | #endif |
---|
799 | #ifdef __IA64__ |
---|
800 | log_to_screen |
---|
801 | (_("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI")); |
---|
802 | log_to_screen(_("environment correctly. Please install it.")); |
---|
803 | fatal_error("Aborting"); |
---|
804 | #endif |
---|
805 | } |
---|
806 | #ifdef __IA64__ |
---|
807 | /* We force ELILO usage on IA64 */ |
---|
808 | bkpinfo->make_cd_use_lilo = TRUE; |
---|
809 | #endif |
---|
810 | } |
---|
811 | #endif |
---|
812 | |
---|
813 | if (bkpinfo->make_cd_use_lilo && !does_file_exist("/boot/boot.b")) { |
---|
814 | paranoid_system("touch /boot/boot.b"); |
---|
815 | } |
---|
816 | |
---|
817 | i = flag_set['O'] + flag_set['V']; |
---|
818 | if (i == 0) { |
---|
819 | retval++; |
---|
820 | log_to_screen(_("Specify backup (-O), verify (-V) or both (-OV).\n")); |
---|
821 | } |
---|
822 | |
---|
823 | /* and finally... */ |
---|
824 | |
---|
825 | mr_free(tmp); |
---|
826 | return (retval); |
---|
827 | } |
---|
828 | |
---|
829 | |
---|
830 | /** |
---|
831 | * Get the switches from @p argc and @p argv using getopt() and place them in |
---|
832 | * @p flag_set and @p flag_val. |
---|
833 | * @param argc The argument count (@p argc passed to main()). |
---|
834 | * @param argv The argument vector (@p argv passed to main()). |
---|
835 | * @param flag_val An array indexed by switch letter - if a switch is set and |
---|
836 | * has an argument then set flag_val[switch] to that argument. |
---|
837 | * @param flag_set An array indexed by switch letter - if a switch is set then |
---|
838 | * set flag_set[switch] to TRUE, else set it to FALSE. |
---|
839 | * @return The number of problems with the command line (0 for success). |
---|
840 | */ |
---|
841 | int |
---|
842 | retrieve_switches_from_command_line(int argc, char *argv[], |
---|
843 | char flag_val[128][MAX_STR_LEN], |
---|
844 | bool flag_set[128]) |
---|
845 | { |
---|
846 | /*@ ints ** */ |
---|
847 | int opt = 0; |
---|
848 | char *tmp = NULL; |
---|
849 | int i = 0; |
---|
850 | int len = 0; |
---|
851 | |
---|
852 | /*@ bools *** */ |
---|
853 | bool bad_switches = FALSE; |
---|
854 | |
---|
855 | assert(flag_val != NULL); |
---|
856 | assert(flag_set != NULL); |
---|
857 | |
---|
858 | for (i = 0; i < 128; i++) { |
---|
859 | flag_val[i][0] = '\0'; |
---|
860 | flag_set[i] = FALSE; |
---|
861 | } |
---|
862 | while ((opt = |
---|
863 | getopt(argc, argv, |
---|
864 | "0123456789A:B:C:DE:FGHI:J:K:LNOP:QRS:T:UVWb:c:d:ef:gik:l:mn:op:rs:tuw:x:z")) |
---|
865 | != -1) { |
---|
866 | if (opt == '?') { |
---|
867 | bad_switches = TRUE; |
---|
868 | /*log_it("Invalid option: %c\n",optopt); */ |
---|
869 | } else { |
---|
870 | if (flag_set[optopt]) { |
---|
871 | bad_switches = TRUE; |
---|
872 | mr_asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt, |
---|
873 | flag_val[i]); |
---|
874 | log_to_screen(tmp); |
---|
875 | mr_free(tmp); |
---|
876 | } else { |
---|
877 | flag_set[opt] = TRUE; |
---|
878 | if (optarg) { |
---|
879 | len = strlen(optarg); |
---|
880 | if (optarg[0] != '/' && optarg[len - 1] == '/') { |
---|
881 | optarg[--len] = '\0'; |
---|
882 | log_to_screen |
---|
883 | (_("Warning - param '%s' should not have trailing slash!"), |
---|
884 | optarg); |
---|
885 | } |
---|
886 | if (opt == 'd') { |
---|
887 | if (strchr(flag_val[opt], '/') |
---|
888 | && flag_val[opt][0] != '/') { |
---|
889 | mr_asprintf(&tmp, |
---|
890 | _("-%c flag --- must be absolute path --- '%s' isn't absolute"), |
---|
891 | opt, flag_val[opt]); |
---|
892 | log_to_screen(tmp); |
---|
893 | mr_free(tmp); |
---|
894 | bad_switches = TRUE; |
---|
895 | } |
---|
896 | } |
---|
897 | strcpy(flag_val[opt], optarg); |
---|
898 | } |
---|
899 | } |
---|
900 | } |
---|
901 | } |
---|
902 | for (i = optind; i < argc; i++) { |
---|
903 | bad_switches = TRUE; |
---|
904 | mr_asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]); |
---|
905 | log_to_screen(tmp); |
---|
906 | mr_free(tmp); |
---|
907 | } |
---|
908 | return (bad_switches); |
---|
909 | } |
---|
910 | |
---|
911 | |
---|
912 | /** |
---|
913 | * Terminate Mondo in response to a signal. |
---|
914 | * @param sig The signal number received. |
---|
915 | */ |
---|
916 | void terminate_daemon(int sig) |
---|
917 | { |
---|
918 | char *tmp = NULL; |
---|
919 | char *tmp2 = NULL; |
---|
920 | |
---|
921 | switch (sig) { |
---|
922 | case SIGINT: |
---|
923 | mr_asprintf(&tmp, _("SIGINT signal received from OS")); |
---|
924 | mr_asprintf(&tmp2, _("You interrupted me :-)")); |
---|
925 | break; |
---|
926 | case SIGKILL: |
---|
927 | mr_asprintf(&tmp, _("SIGKILL signal received from OS")); |
---|
928 | mr_asprintf(&tmp2, |
---|
929 | _("I seriously have no clue how this signal even got to me. Something's wrong with your system.")); |
---|
930 | break; |
---|
931 | case SIGTERM: |
---|
932 | mr_asprintf(&tmp, _("SIGTERM signal received from OS")); |
---|
933 | mr_asprintf(&tmp2, _("Got terminate signal")); |
---|
934 | break; |
---|
935 | case SIGHUP: |
---|
936 | mr_asprintf(&tmp, _("SIGHUP signal received from OS")); |
---|
937 | mr_asprintf(&tmp2, _("Hangup on line")); |
---|
938 | break; |
---|
939 | case SIGSEGV: |
---|
940 | mr_asprintf(&tmp, _("SIGSEGV signal received from OS")); |
---|
941 | mr_asprintf(&tmp2, |
---|
942 | _("Internal programming error. Please send a backtrace as well as your log.")); |
---|
943 | break; |
---|
944 | case SIGPIPE: |
---|
945 | mr_asprintf(&tmp, _("SIGPIPE signal received from OS")); |
---|
946 | mr_asprintf(&tmp2, _("Pipe was broken")); |
---|
947 | break; |
---|
948 | case SIGABRT: |
---|
949 | mr_asprintf(&tmp, _("SIGABRT signal received from OS")); |
---|
950 | mr_asprintf(&tmp2, |
---|
951 | _("Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.")); |
---|
952 | break; |
---|
953 | default: |
---|
954 | mr_asprintf(&tmp, _("(Unknown)")); |
---|
955 | mr_asprintf(&tmp2, _("(Unknown)")); |
---|
956 | } |
---|
957 | |
---|
958 | log_to_screen(tmp); |
---|
959 | log_to_screen(tmp2); |
---|
960 | mr_free(tmp); |
---|
961 | mr_free(tmp2); |
---|
962 | if (sig == SIGABRT) { |
---|
963 | sleep(10); |
---|
964 | } |
---|
965 | kill_buffer(); |
---|
966 | fatal_error |
---|
967 | ("Mondoarchive is terminating in response to a signal from the OS"); |
---|
968 | finish(254); // just in case |
---|
969 | } |
---|
970 | |
---|
971 | |
---|
972 | /** |
---|
973 | * Turn signal-trapping on or off. |
---|
974 | * @param on If TRUE, turn it on; if FALSE, turn it off (we still trap it, just don't do as much). |
---|
975 | */ |
---|
976 | void set_signals(int on) |
---|
977 | { |
---|
978 | int signals[] = |
---|
979 | { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 }; |
---|
980 | int i; |
---|
981 | |
---|
982 | signal(SIGPIPE, sigpipe_occurred); |
---|
983 | for (i = 0; signals[i]; i++) { |
---|
984 | if (on) { |
---|
985 | signal(signals[i], terminate_daemon); |
---|
986 | } else { |
---|
987 | signal(signals[i], termination_in_progress); |
---|
988 | } |
---|
989 | } |
---|
990 | } |
---|
991 | |
---|
992 | |
---|
993 | /** |
---|
994 | * Exit immediately without cleaning up. |
---|
995 | * @param sig The signal we are exiting due to. |
---|
996 | */ |
---|
997 | void termination_in_progress(int sig) |
---|
998 | { |
---|
999 | mr_msg(1, "Termination in progress"); |
---|
1000 | usleep(1000); |
---|
1001 | pthread_exit(0); |
---|
1002 | } |
---|
1003 | |
---|
1004 | /* @} - end of cliGroup */ |
---|