Ignore:
Timestamp:
Nov 5, 2016, 6:12:23 PM (7 years ago)
Author:
Bruno Cornec
Message:
  • Change interfaces for the call_program_and_get_last_line_of_output and where_is_root_mounted(now return dynamically allocated string)
  • removes useless function store_netfs_config
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-tools.c

    r3539 r3610  
    230230    d = 5.2;                    // :-)
    231231#else
    232     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r"));
     232    tmp = call_program_and_get_last_line_of_output("uname -r");
    233233    p = strchr(tmp, '.');
    234234    if (p) {
     
    452452        if (getenv ("SUDO_COMMAND")) {
    453453            mr_asprintf(command, "strings `which growisofs` | grep -c SUDO_COMMAND");
    454             if (!strcmp(call_program_and_get_last_line_of_output(command), "1")) {
    455                 mr_free(command);
     454            tmp = call_program_and_get_last_line_of_output(command);
     455            mr_free(command);
     456            if (!strcmp(tmp, "1")) {
     457                mr_free(tmp);
    456458                popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    457459                fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    458460            }       
    459             mr_free(command);
     461            mr_free(tmp);
    460462        }
    461463        log_msg(2, "call_make_iso (DVD res) is ... %s", bkpinfo->call_make_iso);
     
    550552        mr_asprintf(command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir);
    551553        log_it("command = %s", command);
    552         mr_asprintf(iso_dev, "%s", call_program_and_get_last_line_of_output(command));
     554        iso_dev = call_program_and_get_last_line_of_output(command);
    553555        log_it("res of it = %s", iso_dev);
    554556        mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir);
     
    561563
    562564        log_it("command = %s", command);
    563         mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     565        iso_mnt = call_program_and_get_last_line_of_output(command);
    564566        log_it("res of it = %s", iso_mnt);
    565567        mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir);
     
    882884
    883885    mr_asprintf(command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", partition);
    884     mr_asprintf(out_sz, "%s", call_program_and_get_last_line_of_output(command));
     886    out_sz = call_program_and_get_last_line_of_output(command);
    885887    mr_free(command);
    886888
     
    923925        run_program_and_log_output("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE);
    924926    }
    925     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
     927    tmp = call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2");
    926928    if (atol(tmp) < 35000) {
    927929        retval++;
     
    986988    }
    987989    run_program_and_log_output("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
    988     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""));
     990    tmp = call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\"");
    989991    if (strcmp("", tmp)) {
    990992        if (strstr(tmp, "autofs")) {
     
    10501052    /*@ buffer ****************************************************** */
    10511053    char *command = NULL;
     1054    char *tmp = NULL;
    10521055
    10531056    /*@ end vars *************************************************** */
     
    10641067    } else {
    10651068        mr_asprintf(command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", label, config_file);
    1066         strcpy(value, call_program_and_get_last_line_of_output(command));
     1069        tmp = call_program_and_get_last_line_of_output(command);
     1070        strcpy(value, tmp);
    10671071        mr_free(command);
    10681072
     
    11931197    mr_asprintf(command, "%s", "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[   ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    11941198    log_msg(4, "Cool. Command = '%s'", command);
    1195     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1199    tmp = call_program_and_get_last_line_of_output(command);
    11961200    mr_free(command);
    11971201
     
    12011205    mr_free(tmp);
    12021206
    1203     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1207    tmp = call_program_and_get_last_line_of_output(command);
    12041208    mr_free(command);
    12051209
     
    13981402void stop_magicdev_if_necessary()
    13991403{
    1400     strcpy(g_magicdev_command, call_program_and_get_last_line_of_output("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99"));
     1404    char *tmp = NULL;
     1405
     1406    tmp = call_program_and_get_last_line_of_output("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99");
     1407    strcpy(g_magicdev_command, tmp);
    14011408    if (g_magicdev_command[0]) {
    14021409        log_msg(1, "g_magicdev_command = '%s'", g_magicdev_command);
    14031410        paranoid_system("killall magicdev");
    14041411    }
     1412    mr_free(tmp);
    14051413}
    14061414
Note: See TracChangeset for help on using the changeset viewer.