diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-01 22:25:33 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-01 22:25:33 +0000 |
commit | 10aea3e84e2715fb2a4b265faac273d11e8116ef (patch) | |
tree | d7a8398b77e6c028e89b4c965bea781e4dfec80f | |
parent | c6753c1666d11391da56ebd5a2048af07f3bc9be (diff) | |
download | busybox-w32-10aea3e84e2715fb2a4b265faac273d11e8116ef.tar.gz busybox-w32-10aea3e84e2715fb2a4b265faac273d11e8116ef.tar.bz2 busybox-w32-10aea3e84e2715fb2a4b265faac273d11e8116ef.zip |
devfsd: futher sanitization by Tito <farmatito@tiscali.it>
-rw-r--r-- | miscutils/devfsd.c | 181 |
1 files changed, 63 insertions, 118 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 3ab36cc3c..814fbd686 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -234,11 +234,8 @@ static char get_old_ide_name(unsigned , unsigned); | |||
234 | static char *write_old_sd_name(char *, unsigned, unsigned, const char *); | 234 | static char *write_old_sd_name(char *, unsigned, unsigned, const char *); |
235 | 235 | ||
236 | /* busybox functions */ | 236 | /* busybox functions */ |
237 | static void msg_logger(int pri, const char * fmt, ...)__attribute__((format(printf, 2, 3))); | 237 | static void do_ioctl_or_die(int fd, int request, unsigned long event_mask_flag); |
238 | static void msg_logger_and_die(int pri, const char * fmt, ...)__attribute__((noreturn, format(printf, 2, 3))); | 238 | static int get_uid_gid(int flag, const char *string); |
239 | static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag); | ||
240 | static void fork_and_execute(int die, char *arg0, char **arg); | ||
241 | static int get_uid_gid(int, const char *); | ||
242 | static void safe_memcpy(char * dest, const char * src, int len); | 239 | static void safe_memcpy(char * dest, const char * src, int len); |
243 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr); | 240 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr); |
244 | static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr); | 241 | static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr); |
@@ -246,7 +243,7 @@ static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr | |||
246 | /* Structs and vars */ | 243 | /* Structs and vars */ |
247 | static struct config_entry_struct *first_config = NULL; | 244 | static struct config_entry_struct *first_config = NULL; |
248 | static struct config_entry_struct *last_config = NULL; | 245 | static struct config_entry_struct *last_config = NULL; |
249 | static const char *mount_point = NULL; | 246 | static char *mount_point = NULL; |
250 | static volatile int caught_signal = FALSE; | 247 | static volatile int caught_signal = FALSE; |
251 | static volatile int caught_sighup = FALSE; | 248 | static volatile int caught_sighup = FALSE; |
252 | static struct initial_symlink_struct | 249 | static struct initial_symlink_struct |
@@ -286,83 +283,27 @@ static const char * const bb_msg_bad_config = "bad %s config file: %s"; | |||
286 | static const char * const bb_msg_small_buffer = "buffer too small"; | 283 | static const char * const bb_msg_small_buffer = "buffer too small"; |
287 | static const char * const bb_msg_variable_not_found = "variable: %s not found"; | 284 | static const char * const bb_msg_variable_not_found = "variable: %s not found"; |
288 | 285 | ||
289 | /* Busybox functions */ | ||
290 | static void msg_logger(int pri, const char * fmt, ...) | ||
291 | { | ||
292 | va_list ap; | ||
293 | int ret; | ||
294 | |||
295 | va_start(ap, fmt); | ||
296 | ret = access("/dev/log", F_OK); | ||
297 | if (ret == 0) { | ||
298 | openlog(applet_name, 0, LOG_DAEMON); | ||
299 | vsyslog(pri , fmt, ap); | ||
300 | /* Man: A trailing newline is added when needed. */ | ||
301 | closelog(); | ||
302 | } | ||
303 | /* ENABLE_DEVFSD_VERBOSE is always enabled if msg_logger is used */ | ||
304 | if ((ENABLE_DEVFSD_VERBOSE && ret) || ENABLE_DEBUG) { | ||
305 | bb_error_msg(fmt, ap); | ||
306 | } | ||
307 | va_end(ap); | ||
308 | } | ||
309 | |||
310 | static void msg_logger_and_die(int pri, const char* fmt, ...) | ||
311 | { | ||
312 | va_list ap; | ||
313 | |||
314 | va_start(ap, fmt); | ||
315 | msg_logger(pri, fmt, ap); | ||
316 | va_end(ap); | ||
317 | exit(EXIT_FAILURE); | ||
318 | } | ||
319 | |||
320 | /* Busybox stuff */ | 286 | /* Busybox stuff */ |
321 | #if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG) | 287 | #if ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG |
322 | #define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args) | 288 | #define info_logger(p, fmt, args...) bb_info_msg(fmt, ## args) |
323 | #define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args) | 289 | #define msg_logger(p, fmt, args...) bb_error_msg(fmt, ## args) |
324 | #define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args) | 290 | #define msg_logger_and_die(p, fmt, args...) bb_error_msg_and_die(fmt, ## args) |
291 | #define error_logger(p, fmt, args...) bb_perror_msg(fmt, ## args) | ||
292 | #define error_logger_and_die(p, fmt, args...) bb_perror_msg_and_die(fmt, ## args) | ||
325 | #else | 293 | #else |
294 | #define info_logger(p, fmt, args...) | ||
326 | #define msg_logger(p, fmt, args...) | 295 | #define msg_logger(p, fmt, args...) |
327 | #define msg_logger_and_die(p, fmt, args...) exit(1) | 296 | #define msg_logger_and_die(p, fmt, args...) exit(1) |
328 | #define devfsd_perror_msg_and_die(fmt, args...) exit(1) | 297 | #define error_logger(p, fmt, args...) |
329 | #define devfsd_error_msg_and_die(fmt, args...) exit(1) | 298 | #define error_logger_and_die(p, fmt, args...) exit(1) |
330 | #define devfsd_error_msg(fmt, args...) | ||
331 | #endif | 299 | #endif |
332 | 300 | ||
333 | static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag) | 301 | static void do_ioctl_or_die(int fd, int request, unsigned long event_mask_flag) |
334 | { | 302 | { |
335 | if (ioctl(fd, request, event_mask_flag) == -1) | 303 | if (ioctl(fd, request, event_mask_flag) == -1) |
336 | msg_logger_and_die(LOG_ERR, "ioctl"); | 304 | msg_logger_and_die(LOG_ERR, "ioctl"); |
337 | } | 305 | } |
338 | 306 | ||
339 | static void fork_and_execute(int die, char *arg0, char **arg) | ||
340 | { | ||
341 | switch (fork()) { | ||
342 | case 0: | ||
343 | /* Child */ | ||
344 | break; | ||
345 | case -1: | ||
346 | /* Parent: Error : die or return */ | ||
347 | msg_logger(LOG_ERR,(char *)bb_msg_memory_exhausted); | ||
348 | if (die) | ||
349 | exit(EXIT_FAILURE); | ||
350 | return; | ||
351 | default: | ||
352 | /* Parent : ok : return or exit */ | ||
353 | if (arg0 != NULL) { | ||
354 | wait(NULL); | ||
355 | return; | ||
356 | } | ||
357 | exit(EXIT_SUCCESS); | ||
358 | } | ||
359 | /* Child : if arg0 != NULL do execvp */ | ||
360 | if (arg0 != NULL) { | ||
361 | BB_EXECVP(arg0, arg); | ||
362 | msg_logger_and_die(LOG_ERR, "execvp"); | ||
363 | } | ||
364 | } | ||
365 | |||
366 | static void safe_memcpy(char *dest, const char *src, int len) | 307 | static void safe_memcpy(char *dest, const char *src, int len) |
367 | { | 308 | { |
368 | memcpy(dest , src, len); | 309 | memcpy(dest , src, len); |
@@ -436,21 +377,17 @@ int devfsd_main(int argc, char **argv) | |||
436 | } | 377 | } |
437 | } | 378 | } |
438 | 379 | ||
439 | /* strip last / from mount point, so we don't need to check for it later */ | 380 | mount_point = bb_simplify_path(argv[1]); |
440 | while (argv[1][1] != '\0' && argv[1][strlen(argv[1]) - 1] == '/') | ||
441 | argv[1][strlen(argv[1]) - 1] = '\0'; | ||
442 | |||
443 | mount_point = argv[1]; | ||
444 | 381 | ||
445 | xchdir(mount_point); | 382 | xchdir(mount_point); |
446 | 383 | ||
447 | fd = xopen(".devfsd", O_RDONLY); | 384 | fd = xopen(".devfsd", O_RDONLY); |
448 | 385 | ||
449 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) | 386 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) |
450 | devfsd_perror_msg_and_die("FD_CLOEXEC"); | 387 | bb_perror_msg_and_die("FD_CLOEXEC"); |
451 | 388 | ||
452 | if (ioctl(fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev) == -1) | 389 | if (ioctl(fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev) == -1) |
453 | msg_logger_and_die(LOG_ERR, "ioctl"); | 390 | bb_perror_msg_and_die("ioctl"); |
454 | 391 | ||
455 | /*setup initial entries */ | 392 | /*setup initial entries */ |
456 | for (curr = initial_symlinks; curr->dest != NULL; ++curr) | 393 | for (curr = initial_symlinks; curr->dest != NULL; ++curr) |
@@ -467,7 +404,7 @@ int devfsd_main(int argc, char **argv) | |||
467 | exit(EXIT_SUCCESS); /* -v */ | 404 | exit(EXIT_SUCCESS); /* -v */ |
468 | } | 405 | } |
469 | /* Tell kernel we are special(i.e. we get to see hidden entries) */ | 406 | /* Tell kernel we are special(i.e. we get to see hidden entries) */ |
470 | do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0); | 407 | do_ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0); |
471 | 408 | ||
472 | sigemptyset(&new_action.sa_mask); | 409 | sigemptyset(&new_action.sa_mask); |
473 | new_action.sa_flags = 0; | 410 | new_action.sa_flags = 0; |
@@ -475,7 +412,7 @@ int devfsd_main(int argc, char **argv) | |||
475 | /* Set up SIGHUP and SIGUSR1 handlers */ | 412 | /* Set up SIGHUP and SIGUSR1 handlers */ |
476 | new_action.sa_handler = signal_handler; | 413 | new_action.sa_handler = signal_handler; |
477 | if (sigaction(SIGHUP, &new_action, NULL) != 0 || sigaction(SIGUSR1, &new_action, NULL) != 0) | 414 | if (sigaction(SIGHUP, &new_action, NULL) != 0 || sigaction(SIGUSR1, &new_action, NULL) != 0) |
478 | devfsd_error_msg_and_die("sigaction"); | 415 | bb_error_msg_and_die("sigaction"); |
479 | 416 | ||
480 | printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point); | 417 | printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point); |
481 | 418 | ||
@@ -487,15 +424,23 @@ int devfsd_main(int argc, char **argv) | |||
487 | 424 | ||
488 | if (ENABLE_DEVFSD_FG_NP && no_polling) | 425 | if (ENABLE_DEVFSD_FG_NP && no_polling) |
489 | exit(0); | 426 | exit(0); |
427 | |||
428 | if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG) | ||
429 | logmode = LOGMODE_BOTH; | ||
430 | else if (do_daemon == TRUE) | ||
431 | logmode = LOGMODE_SYSLOG; | ||
432 | /* This is the default */ | ||
433 | /*else | ||
434 | logmode = LOGMODE_STDIO; */ | ||
435 | |||
490 | if (do_daemon) { | 436 | if (do_daemon) { |
491 | /* Release so that the child can grab it */ | 437 | /* Release so that the child can grab it */ |
492 | do_ioctl_and_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0); | 438 | do_ioctl_or_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0); |
493 | fork_and_execute(DIE, NULL, NULL); | 439 | bb_daemonize_or_rexec(0, argv); |
494 | setsid(); /* Prevent hangups and become pgrp leader */ | ||
495 | } else if (ENABLE_DEVFSD_FG_NP) { | 440 | } else if (ENABLE_DEVFSD_FG_NP) { |
496 | setpgid(0, 0); /* Become process group leader */ | 441 | setpgid(0, 0); /* Become process group leader */ |
497 | } | 442 | } |
498 | 443 | ||
499 | while (TRUE) { | 444 | while (TRUE) { |
500 | do_scan = do_servicing(fd, event_mask); | 445 | do_scan = do_servicing(fd, event_mask); |
501 | 446 | ||
@@ -504,6 +449,7 @@ int devfsd_main(int argc, char **argv) | |||
504 | if (do_scan) | 449 | if (do_scan) |
505 | dir_operation(SERVICE, mount_point, 0, NULL); | 450 | dir_operation(SERVICE, mount_point, 0, NULL); |
506 | } | 451 | } |
452 | if (ENABLE_FEATURE_CLEAN_UP) free(mount_point); | ||
507 | } /* End Function main */ | 453 | } /* End Function main */ |
508 | 454 | ||
509 | 455 | ||
@@ -522,24 +468,23 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask | |||
522 | FILE *fp; | 468 | FILE *fp; |
523 | char buf[STRING_LENGTH]; | 469 | char buf[STRING_LENGTH]; |
524 | char *line = NULL; | 470 | char *line = NULL; |
471 | char *p; | ||
525 | 472 | ||
526 | if (stat(path, &statbuf) == 0) { | 473 | if (stat(path, &statbuf) == 0) { |
527 | /* Don't read 0 length files: ignored */ | 474 | /* Don't read 0 length files: ignored */ |
528 | /*if (statbuf.st_size == 0) | 475 | /*if (statbuf.st_size == 0) |
529 | return;*/ | 476 | return;*/ |
530 | if (S_ISDIR(statbuf.st_mode)) { | 477 | if (S_ISDIR(statbuf.st_mode)) { |
531 | /* strip last / from dirname so we don't need to check for it later */ | 478 | p = bb_simplify_path(path); |
532 | while (path && path[1] != '\0' && path[strlen(path) - 1] == '/') | 479 | dir_operation(READ_CONFIG, p, 0, event_mask); |
533 | path[strlen(path) - 1] = '\0'; | 480 | free(p); |
534 | |||
535 | dir_operation(READ_CONFIG, path, 0, event_mask); | ||
536 | return; | 481 | return; |
537 | } | 482 | } |
538 | if ((fp = fopen(path, "r")) != NULL) { | 483 | if ((fp = fopen(path, "r")) != NULL) { |
539 | while (fgets(buf, STRING_LENGTH, fp) != NULL) { | 484 | while (fgets(buf, STRING_LENGTH, fp) != NULL) { |
540 | /* Skip whitespace */ | 485 | /* Skip whitespace */ |
541 | for (line = buf; isspace(*line); ++line) | 486 | line = buf; |
542 | /*VOID*/; | 487 | line = skip_whitespace(line); |
543 | if (line[0] == '\0' || line[0] == '#') | 488 | if (line[0] == '\0' || line[0] == '#') |
544 | continue; | 489 | continue; |
545 | process_config_line(line, event_mask); | 490 | process_config_line(line, event_mask); |
@@ -550,8 +495,8 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask | |||
550 | } | 495 | } |
551 | } else { | 496 | } else { |
552 | read_config_file_err: | 497 | read_config_file_err: |
553 | if (optional == 0 && errno == ENOENT) | 498 | if (optional == 0 && errno == ENOENT) |
554 | msg_logger_and_die(LOG_ERR, "read config file: %s: %m", path); | 499 | error_logger_and_die(LOG_ERR, "read config file: %s", path); |
555 | } | 500 | } |
556 | } /* End Function read_config_file */ | 501 | } /* End Function read_config_file */ |
557 | 502 | ||
@@ -600,7 +545,7 @@ static void process_config_line(const char *line, unsigned long *event_mask) | |||
600 | /* "INCLUDE" & "OPTIONAL_INCLUDE" */ | 545 | /* "INCLUDE" & "OPTIONAL_INCLUDE" */ |
601 | if (i == 1 || i == 2) { | 546 | if (i == 1 || i == 2) { |
602 | st_expr_expand(name, STRING_LENGTH, name, get_variable, NULL); | 547 | st_expr_expand(name, STRING_LENGTH, name, get_variable, NULL); |
603 | msg_logger(LOG_INFO, "%sinclude: %s", (toupper(when[0]) == 'I') ? "": "optional_", name); | 548 | info_logger(LOG_INFO, "%sinclude: %s", (toupper(when[0]) == 'I') ? "": "optional_", name); |
604 | read_config_file(name, (toupper(when[0]) == 'I') ? FALSE : TRUE, event_mask); | 549 | read_config_file(name, (toupper(when[0]) == 'I') ? FALSE : TRUE, event_mask); |
605 | return; | 550 | return; |
606 | } | 551 | } |
@@ -716,7 +661,7 @@ static int do_servicing(int fd, unsigned long event_mask) | |||
716 | 661 | ||
717 | /* Tell devfs what events we care about */ | 662 | /* Tell devfs what events we care about */ |
718 | tmp_event_mask = event_mask; | 663 | tmp_event_mask = event_mask; |
719 | do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask); | 664 | do_ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask); |
720 | while (!caught_signal) { | 665 | while (!caught_signal) { |
721 | errno = 0; | 666 | errno = 0; |
722 | bytes = read(fd,(char *) &info, sizeof info); | 667 | bytes = read(fd,(char *) &info, sizeof info); |
@@ -809,11 +754,11 @@ static void action_permissions(const struct devfsd_notify_struct *info, | |||
809 | { | 754 | { |
810 | struct stat statbuf; | 755 | struct stat statbuf; |
811 | 756 | ||
812 | if (stat(info->devname, &statbuf) != 0 || | 757 | if (stat(info->devname, &statbuf) != 0 |
813 | chmod(info->devname,(statbuf.st_mode & S_IFMT) |(entry->u.permissions.mode & ~S_IFMT)) != 0 || | 758 | || chmod(info->devname, (statbuf.st_mode & S_IFMT) | (entry->u.permissions.mode & ~S_IFMT)) != 0 |
814 | chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0 | 759 | || chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0 |
815 | ) | 760 | ) |
816 | msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m", info->devname); | 761 | error_logger(LOG_ERR, "Can't chmod or chown: %s", info->devname); |
817 | } /* End Function action_permissions */ | 762 | } /* End Function action_permissions */ |
818 | 763 | ||
819 | static void action_modload(const struct devfsd_notify_struct *info, | 764 | static void action_modload(const struct devfsd_notify_struct *info, |
@@ -826,14 +771,14 @@ static void action_modload(const struct devfsd_notify_struct *info, | |||
826 | { | 771 | { |
827 | char *argv[6]; | 772 | char *argv[6]; |
828 | 773 | ||
829 | argv[0] =(char*)MODPROBE; | 774 | argv[0] = (char*)MODPROBE; |
830 | argv[1] =(char*)MODPROBE_SWITCH_1; /* "-k" */ | 775 | argv[1] = (char*)MODPROBE_SWITCH_1; /* "-k" */ |
831 | argv[2] =(char*)MODPROBE_SWITCH_2; /* "-C" */ | 776 | argv[2] = (char*)MODPROBE_SWITCH_2; /* "-C" */ |
832 | argv[3] =(char*)CONFIG_MODULES_DEVFS; | 777 | argv[3] = (char*)CONFIG_MODULES_DEVFS; |
833 | argv[4] = concat_path_file("/dev", info->devname); /* device */ | 778 | argv[4] = concat_path_file("/dev", info->devname); /* device */ |
834 | argv[5] = NULL; | 779 | argv[5] = NULL; |
835 | 780 | ||
836 | fork_and_execute(DIE, argv[0], argv); | 781 | wait4pid(xspawn(argv)); |
837 | free(argv[4]); | 782 | free(argv[4]); |
838 | } /* End Function action_modload */ | 783 | } /* End Function action_modload */ |
839 | 784 | ||
@@ -865,7 +810,7 @@ static void action_execute(const struct devfsd_notify_struct *info, | |||
865 | argv[count] = largv[count]; | 810 | argv[count] = largv[count]; |
866 | } | 811 | } |
867 | argv[count] = NULL; | 812 | argv[count] = NULL; |
868 | fork_and_execute(NO_DIE, argv[0], argv); | 813 | wait4pid(spawn(argv)); |
869 | } /* End Function action_execute */ | 814 | } /* End Function action_execute */ |
870 | 815 | ||
871 | 816 | ||
@@ -913,7 +858,7 @@ static void action_copy(const struct devfsd_notify_struct *info, | |||
913 | new_mode |= S_ISVTX; | 858 | new_mode |= S_ISVTX; |
914 | ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat); | 859 | ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat); |
915 | if (ENABLE_DEBUG && ret && (errno != EEXIST)) | 860 | if (ENABLE_DEBUG && ret && (errno != EEXIST)) |
916 | msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination); | 861 | error_logger(LOG_ERR, "copy_inode: %s to %s", source, destination); |
917 | } /* End Function action_copy */ | 862 | } /* End Function action_copy */ |
918 | 863 | ||
919 | static void action_compat(const struct devfsd_notify_struct *info, unsigned int action) | 864 | static void action_compat(const struct devfsd_notify_struct *info, unsigned int action) |
@@ -1007,7 +952,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int | |||
1007 | case AC_RMNEWCOMPAT: | 952 | case AC_RMNEWCOMPAT: |
1008 | ret = unlink(compat_name); | 953 | ret = unlink(compat_name); |
1009 | if (ENABLE_DEBUG && ret) | 954 | if (ENABLE_DEBUG && ret) |
1010 | msg_logger(LOG_ERR, "unlink: %s: %m", compat_name); | 955 | error_logger(LOG_ERR, "unlink: %s", compat_name); |
1011 | break; | 956 | break; |
1012 | /*esac*/ | 957 | /*esac*/ |
1013 | } /* switch (action) */ | 958 | } /* switch (action) */ |
@@ -1022,7 +967,7 @@ static void restore(char *spath, struct stat source_stat, int rootlen) | |||
1022 | dpath = concat_path_file(mount_point, spath + rootlen); | 967 | dpath = concat_path_file(mount_point, spath + rootlen); |
1023 | lstat(dpath, &dest_stat); | 968 | lstat(dpath, &dest_stat); |
1024 | free(dpath); | 969 | free(dpath); |
1025 | if (S_ISLNK(source_stat.st_mode) ||(source_stat.st_mode & S_ISVTX)) | 970 | if (S_ISLNK(source_stat.st_mode) || (source_stat.st_mode & S_ISVTX)) |
1026 | copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat); | 971 | copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat); |
1027 | 972 | ||
1028 | if (S_ISDIR(source_stat.st_mode)) | 973 | if (S_ISDIR(source_stat.st_mode)) |
@@ -1198,7 +1143,7 @@ static void signal_handler(int sig) | |||
1198 | if (sig == SIGHUP) | 1143 | if (sig == SIGHUP) |
1199 | caught_sighup = TRUE; | 1144 | caught_sighup = TRUE; |
1200 | 1145 | ||
1201 | msg_logger(LOG_INFO, "Caught signal %d", sig); | 1146 | info_logger(LOG_INFO, "Caught signal %d", sig); |
1202 | } /* End Function signal_handler */ | 1147 | } /* End Function signal_handler */ |
1203 | 1148 | ||
1204 | static const char *get_variable(const char *variable, void *info) | 1149 | static const char *get_variable(const char *variable, void *info) |
@@ -1211,7 +1156,7 @@ static const char *get_variable(const char *variable, void *info) | |||
1211 | int i; | 1156 | int i; |
1212 | 1157 | ||
1213 | if (gethostname(hostname, STRING_LENGTH - 1) != 0) | 1158 | if (gethostname(hostname, STRING_LENGTH - 1) != 0) |
1214 | msg_logger_and_die(LOG_ERR, "gethostname: %m"); | 1159 | error_logger_and_die(LOG_ERR, "gethostname"); |
1215 | 1160 | ||
1216 | /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */ | 1161 | /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */ |
1217 | hostname[STRING_LENGTH - 1] = '\0'; | 1162 | hostname[STRING_LENGTH - 1] = '\0'; |
@@ -1651,7 +1596,7 @@ int st_expr_expand(char *output, unsigned int length, const char *input, | |||
1651 | if (isspace(ch) ||(ch == '/') ||(ch == '\0')) { | 1596 | if (isspace(ch) ||(ch == '/') ||(ch == '\0')) { |
1652 | /* User's own home directory: leave separator for next time */ | 1597 | /* User's own home directory: leave separator for next time */ |
1653 | if ((env = getenv("HOME")) == NULL) { | 1598 | if ((env = getenv("HOME")) == NULL) { |
1654 | msg_logger(LOG_INFO, bb_msg_variable_not_found, "HOME"); | 1599 | info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME"); |
1655 | return FALSE; | 1600 | return FALSE; |
1656 | } | 1601 | } |
1657 | len = strlen(env); | 1602 | len = strlen(env); |
@@ -1670,7 +1615,7 @@ int st_expr_expand(char *output, unsigned int length, const char *input, | |||
1670 | safe_memcpy(tmp, input, len); | 1615 | safe_memcpy(tmp, input, len); |
1671 | input = ptr - 1; | 1616 | input = ptr - 1; |
1672 | if ((pwent = getpwnam(tmp)) == NULL) { | 1617 | if ((pwent = getpwnam(tmp)) == NULL) { |
1673 | msg_logger(LOG_INFO, "no pwent for: %s", tmp); | 1618 | info_logger(LOG_INFO, "no pwent for: %s", tmp); |
1674 | return FALSE; | 1619 | return FALSE; |
1675 | } | 1620 | } |
1676 | len = strlen(pwent->pw_dir); | 1621 | len = strlen(pwent->pw_dir); |
@@ -1695,7 +1640,7 @@ int st_expr_expand(char *output, unsigned int length, const char *input, | |||
1695 | } | 1640 | } |
1696 | return FALSE; | 1641 | return FALSE; |
1697 | st_expr_expand_out: | 1642 | st_expr_expand_out: |
1698 | msg_logger(LOG_INFO, bb_msg_small_buffer); | 1643 | info_logger(LOG_INFO, bb_msg_small_buffer); |
1699 | return FALSE; | 1644 | return FALSE; |
1700 | } /* End Function st_expr_expand */ | 1645 | } /* End Function st_expr_expand */ |
1701 | 1646 | ||
@@ -1750,7 +1695,7 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1750 | safe_memcpy(tmp, input, len); | 1695 | safe_memcpy(tmp, input, len); |
1751 | input = ptr - 1; | 1696 | input = ptr - 1; |
1752 | if ((env = get_variable_v2(tmp, func, info)) == NULL) { | 1697 | if ((env = get_variable_v2(tmp, func, info)) == NULL) { |
1753 | msg_logger(LOG_INFO, bb_msg_variable_not_found, tmp); | 1698 | info_logger(LOG_INFO, bb_msg_variable_not_found, tmp); |
1754 | return NULL; | 1699 | return NULL; |
1755 | } | 1700 | } |
1756 | len = strlen(env); | 1701 | len = strlen(env); |
@@ -1778,7 +1723,7 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1778 | return input + len; | 1723 | return input + len; |
1779 | } | 1724 | } |
1780 | if (ch != ':' || ptr[1] != '-') { | 1725 | if (ch != ':' || ptr[1] != '-') { |
1781 | msg_logger(LOG_INFO, "illegal char in var name"); | 1726 | info_logger(LOG_INFO, "illegal char in var name"); |
1782 | return NULL; | 1727 | return NULL; |
1783 | } | 1728 | } |
1784 | /* It's that handy "${var:-word}" expression. Check if var is defined */ | 1729 | /* It's that handy "${var:-word}" expression. Check if var is defined */ |
@@ -1801,7 +1746,7 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1801 | --open_braces; | 1746 | --open_braces; |
1802 | break; | 1747 | break; |
1803 | case '\0': | 1748 | case '\0': |
1804 | msg_logger(LOG_INFO,"\"}\" not found in: %s", input); | 1749 | info_logger(LOG_INFO,"\"}\" not found in: %s", input); |
1805 | return NULL; | 1750 | return NULL; |
1806 | default: | 1751 | default: |
1807 | break; | 1752 | break; |
@@ -1840,7 +1785,7 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1840 | *out_pos += len; | 1785 | *out_pos += len; |
1841 | return input; | 1786 | return input; |
1842 | expand_variable_out: | 1787 | expand_variable_out: |
1843 | msg_logger(LOG_INFO, bb_msg_small_buffer); | 1788 | info_logger(LOG_INFO, bb_msg_small_buffer); |
1844 | return NULL; | 1789 | return NULL; |
1845 | } /* End Function expand_variable */ | 1790 | } /* End Function expand_variable */ |
1846 | 1791 | ||