Changeset 3610 in MondoRescue


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
Location:
branches/3.2/mondo/src
Files:
15 edited

Legend:

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

    r3581 r3610  
    550550
    551551#ifdef __FreeBSD__
    552         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     552        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    553553        if (!bootdev[0]) {
    554554            mr_free(bootdev);
    555             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     555            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    556556        }
    557557#else
    558558        /* Linux */
    559559#ifdef __IA64__
    560         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     560        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    561561#else
    562         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     562        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    563563#endif
    564564        if (strstr(bootdev, "/dev/cciss/")) {
    565565            mr_free(bootdev);
    566566#ifdef __IA64__
    567             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     567            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    568568#else
    569             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     569            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    570570#endif
    571571        }
    572572        if (!bootdev[0]) {
    573573            mr_free(bootdev);
    574             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     574            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    575575            if (strstr(bootdev, "/dev/cciss/")) {
    576576                mr_free(bootdev);
    577                 mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     577                bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    578578            }
    579579        }
     
    620620        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
    621621            /* if UEFI then search under /boot/efi */
    622             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("find /boot/efi -name grub.c*"));
     622            tmp = call_program_and_get_last_line_of_output("find /boot/efi -name grub.c*");
    623623            if (strstr(tmp, "grub.c") == NULL) {
    624624                mr_free(bootldr_str);
    625625                fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg /boot/efi/.../grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    626626            }
    627         }
    628         mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version 2> /dev/null"));
     627                        mr_free(tmp);
     628        }
     629        bootldr_ver = call_program_and_get_last_line_of_output("grub --version 2> /dev/null");
    629630        if (strcmp(bootldr_ver,"") ==0) {
    630631            mr_free(bootldr_ver);
    631             mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub2-install --version"));
     632            bootldr_ver = call_program_and_get_last_line_of_output("grub2-install --version");
    632633        }
    633634    } else if (bkpinfo->boot_loader == 'E') {
     
    881882        log_to_screen("Mindi failed to create your boot+data disks.");
    882883        mr_asprintf(command, "grep 'Fatal error' %s", MINDI_LOGFILE);
    883         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     884        tmp = call_program_and_get_last_line_of_output(command);
    884885        mr_free(command);
    885886
     
    11321133    /*@ buffers *********************************** */
    11331134    char *command = NULL;
     1135    char *tmp = NULL;
    11341136    char *tmpfile = NULL;
    11351137    char *data_disks_file = NULL;
     
    11381140    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11391141
    1140     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));
     1142        tmp = call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1");
     1143    snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", tmp);
     1144        mr_free(tmp);
    11411145    strip_spaces(g_serial_string);
    11421146    strcat(g_serial_string, "...word.");
     
    18391843    mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname);
    18401844    log_msg(1, "command = '%s'", command);
    1841     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1845    tmp = call_program_and_get_last_line_of_output(command);
    18421846    mr_free(command);
    18431847
     
    25802584            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    25812585            mr_free(our_serial_str);
    2582             mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
     2586            our_serial_str = call_program_and_get_last_line_of_output(tmp);
    25832587            mr_free(tmp);
    25842588            // FIXME - should be able to use last_line_of_file(), surely?
     
    27642768        mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    27652769        log_it("command = %s", command);
    2766         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2770        tmp = call_program_and_get_last_line_of_output(command);
    27672771        mr_free(command);
    27682772        log_it("res of it = %s", tmp);
  • branches/3.2/mondo/src/common/libmondo-cli.c

    r3583 r3610  
    464464            mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    465465        }
    466         strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp1), MAX_STR_LEN / 4);
     466        tmp2 = call_program_and_get_last_line_of_output(tmp1);
    467467        mr_free(tmp1);
     468        strncpy(bkpinfo->isodir, tmp2, MAX_STR_LEN / 4);
     469        mr_free(tmp2);
    468470
    469471        log_msg(3, "proto = %s", bkpinfo->netfs_proto);
     
    511513                    mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    512514                }
    513                 strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp1), MAX_STR_LEN / 4);
     515                tmp2 = call_program_and_get_last_line_of_output(tmp1);
     516                strncpy(bkpinfo->isodir, tmp2, MAX_STR_LEN / 4);
     517                mr_free(tmp2);
    514518                if (strlen(bkpinfo->isodir) < 3) {
    515519                    retval++;
  • branches/3.2/mondo/src/common/libmondo-devices.c

    r3604 r3610  
    135135    bool is_this_a_ramdisk = FALSE;
    136136
    137     mr_asprintf(tmp, "%s", where_is_root_mounted());
     137    tmp = where_is_root_mounted();
    138138    log_msg(0, "root is mounted at %s", tmp);
    139139    log_msg(0, "That doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().", tmp);
     
    544544    if (find_home_of_exe(cdr_exe)) {
    545545        mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1", cdr_exe);
    546         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     546        tmp = call_program_and_get_last_line_of_output(command);
    547547        mr_free(command);
    548548    }
     
    550550        mr_free(tmp);
    551551        mr_free(cdr_exe);
    552         return 1;
     552        return (1);
    553553    } else {
    554554        strcpy(cdrw_device, tmp);
     
    754754    }
    755755    if (found_it) {
    756         sprintf(tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null", strrchr(output, '/') + 1);
     756        sprintf(tmp, "grep \"%s=ide-scsi\" "CMDLINE" &> /dev/null", strrchr(output, '/') + 1);
    757757        if (system(tmp) == 0) {
    758758            log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output);
     
    847847
    848848    log_msg(1, "command=%s", command);
    849     mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output(command));
     849    tmp1 = call_program_and_get_last_line_of_output(command);
    850850    mr_free(command);
    851851
     
    883883    }
    884884
    885     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));
     885    tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1");
    886886    log_msg(5, "tmp = '%s'", tmp);
    887887    if (!tmp[0]) {
    888888        mr_free(tmp);
    889         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));
     889        tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1");
    890890    }
    891891    if (tmp[0]) {
     
    11531153{
    11541154    char *device = (char *) malloc(MAX_STR_LEN);
    1155     char *mddevice = (char *) malloc(32);
    1156     char command[MAX_STR_LEN];
     1155    char *mddevice = NULL;
     1156    char *command = NULL;
     1157    char *tmp = NULL;
    11571158    int vndev = 2;
    1158     if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1159
     1160    tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate");
     1161    if (atoi(tmp) < 500000) {
    11591162        do {
    1160             sprintf(mddevice, "vn%ic", vndev++);
    1161             sprintf(command, "vnconfig %s %s", mddevice, fname);
     1163            mr_asprintf(mddevice, "vn%ic", vndev++);
     1164            mr_free(command);
     1165            mr_asprintf(command, "vnconfig %s %s", mddevice, fname);
    11621166            if (vndev > 10) {
     1167                mr_free(tmp);
     1168                mr_free(mddevice);
     1169                mr_free(command);
    11631170                return NULL;
    11641171            }
     
    11661173        while (system(command));
    11671174    } else {
    1168         sprintf(command, "mdconfig -a -t vnode -f %s", fname);
     1175        mr_asprintf(command, "mdconfig -a -t vnode -f %s", fname);
    11691176        mddevice = call_program_and_get_last_line_of_output(command);
    11701177        if (!strstr(mddevice, "md")) {
     1178            mr_free(tmp);
     1179            mr_free(command);
     1180            mr_free(mddevice);
    11711181            return NULL;
    11721182        }
    11731183    }
     1184    mr_free(tmp);
     1185    mr_free(command);
    11741186    sprintf(device, "/dev/%s", mddevice);
     1187    mr_free(mddevice);
    11751188    return device;
    11761189}
     
    11891202{
    11901203    char *command = NULL;
     1204    char *tmp = NULL;
    11911205    int res = 0;
    11921206
     
    11951209    }
    11961210
    1197     if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1211    tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate");
     1212    if (atoi(tmp) < 500000) {
    11981213        mr_asprintf(command, "vnconfig -d %s", dname);
    11991214    } else {
    12001215        mr_asprintf(command, "mdconfig -d -u %s", dname);
    12011216    }
     1217    mr_free(tmp);
    12021218    res = system(command);
    12031219    mr_free(command);
     
    16321648    mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
    16331649    log_msg(5, "Running: %s", command);
    1634     mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     1650    mounted_file_system = call_program_and_get_last_line_of_output(command);
    16351651    mr_free(command);
    16361652
     
    16421658        mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
    16431659        log_msg(5, "Running: %s", command);
    1644         mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     1660        mounted_file_system = call_program_and_get_last_line_of_output(command);
    16451661        mr_free(command);
    16461662
     
    17221738    mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf);
    17231739    log_msg(5, "  Executing: %s", command);
    1724     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1740    tmp = call_program_and_get_last_line_of_output(command);
    17251741    mr_free(command);
    17261742
     
    17481764    mr_asprintf(command, "mr-parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    17491765    log_msg(5, "Executing: %s", command);
    1750     mr_asprintf(partition_list, "%s", call_program_and_get_last_line_of_output(command));
     1766    partition_list = call_program_and_get_last_line_of_output(command);
    17511767    mr_free(command);
    17521768    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
     
    18141830        mr_asprintf(command, "mr-parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", ndsf, partitions[i]);
    18151831        log_msg(5, "  Running: %s", command);
    1816         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1832        tmp = call_program_and_get_last_line_of_output(command);
    18171833        mr_free(command);
    18181834
     
    18281844        /* It's not swap. See if we can find the mount point from the mount command. */
    18291845        mr_asprintf(command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    1830         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1846        tmp = call_program_and_get_last_line_of_output(command);
    18311847        mr_free(command);
    18321848
     
    18501866        mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]);
    18511867        log_msg(5, "  Running: %s", command);
    1852         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1868        tmp = call_program_and_get_last_line_of_output(command);
    18531869        mr_free(command);
    18541870
     
    18581874            mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    18591875            log_msg(5, "  Running: %s", command);
    1860             mr_asprintf(VG, "%s", call_program_and_get_last_line_of_output(command));
     1876            VG = call_program_and_get_last_line_of_output(command);
    18611877            mr_free(command);
    18621878
     
    18671883                mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
    18681884                log_msg(5, "  Running: %s", command);
    1869                 mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     1885                mount_list = call_program_and_get_last_line_of_output(command);
    18701886                mr_free(command);
    18711887
     
    18911907                mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    18921908                log_msg (5, "Running: %s", command);
    1893                 mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     1909                mount_list = call_program_and_get_last_line_of_output(command);
    18941910                mr_free(command);
    18951911                log_msg(4, "  Software raid device list: %s", mount_list);
     
    18991915                    log_msg (5, "Running: %s", command);
    19001916                    mr_free(tmp);
    1901                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1917                    tmp = call_program_and_get_last_line_of_output(command);
    19021918                    mr_free(command);
    19031919                    log_msg(4, "Number of Software raid device: %s", tmp);
     
    19341950        mr_asprintf(command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
    19351951        log_msg(4, "  Running: %s", command);
    1936         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1952        tmp = call_program_and_get_last_line_of_output(command);
    19371953        mr_free(command);
    19381954
     
    19471963        mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    19481964        log_msg (5, "  Running: %s", command);
    1949         mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     1965        mount_list = call_program_and_get_last_line_of_output(command);
    19501966        mr_free(command);
    19511967
     
    19571973            log_msg(4, "  Running: %s", command);
    19581974            mr_free(tmp);
    1959             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1975            tmp = call_program_and_get_last_line_of_output(command);
    19601976            mr_free(command);
    19611977
     
    21962212         */
    21972213#ifdef __FreeBSD__
    2198         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,vmhgfs,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done"));
     2214        tmp = call_program_and_get_last_line_of_output("df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,vmhgfs,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done");
    21992215#else
    2200         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("df -m -P -x nfs -x nfs4 -x fuse.sshfs -x fuse -x vfat -x ntfs -x ntfs-3g -x vmhgfs -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done"));
     2216        tmp = call_program_and_get_last_line_of_output("df -m -P -x nfs -x nfs4 -x fuse.sshfs -x fuse -x vfat -x ntfs -x ntfs-3g -x vmhgfs -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done");
    22012217#endif
    22022218
     
    24322448        /* Initiate bkpinfo netfs_mount path from running environment if not already done */
    24332449        if (bkpinfo->netfs_mount == NULL) {
    2434             mr_asprintf(bkpinfo->netfs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
     2450            bkpinfo->netfs_mount = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1");
    24352451        }
    24362452#ifdef __FreeBSD__
     
    24722488            }
    24732489            mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1);
    2474             strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(command));
     2490            tmp = call_program_and_get_last_line_of_output(command);
     2491            strcpy(bkpinfo->isodir, tmp);
     2492            mr_free(tmp);
    24752493            mr_free(command);
    24762494
     
    25352553        /* Initiate bkpinfo isodir path from running environment if mount already done */
    25362554        if (is_this_device_mounted(bkpinfo->netfs_mount)) {
    2537             strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     2555            tmp = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1");
     2556            strcpy(bkpinfo->isodir, tmp);
     2557            mr_free(tmp);
    25382558        } else {
    25392559            // Why netfsdir ?
     
    26412661        mr_free(bkpinfo->boot_device);
    26422662#ifdef __FreeBSD__
    2643         mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     2663        bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    26442664#else
    2645         mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     2665        bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    26462666#endif
    26472667        i = which_boot_loader(bkpinfo->boot_device);
     
    27062726        mr_free(tmp);
    27072727// NTFS
    2708         strcpy(tmp1, call_program_and_get_last_line_of_output("mr-parted2fdisk -l 2>/dev/null | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));
     2728        tmp = call_program_and_get_last_line_of_output("mr-parted2fdisk -l 2>/dev/null | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'");
     2729        strncpy(tmp1, tmp, MAX_STR_LEN / 4);
     2730        mr_free(tmp);
    27092731        if (strlen(tmp1) > 2) {
    27102732            if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1, MAX_STR_LEN / 4)) {
     
    28842906 * Get a |-separated list of NETFS mounts.
    28852907 * @return The list created.
    2886  * @note The return value points to allocated string that needs to be freed
     2908 * @note The return value points to allocated string that needs to be freed by
     2909 * caller
    28872910 * @bug Even though we only want the mounts, the devices are still checked.
    28882911 */
     
    28912914    char *exclude_these_directories = NULL;
    28922915
    2893     mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,vmhgfs,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' '|' | awk '{print $0;}'"));
     2916    exclude_these_directories = call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,vmhgfs,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' '|' | awk '{print $0;}'");
    28942917    log_msg(9,"list_of_NETFS_mounts_only returns %s",exclude_these_directories);
    28952918    return(exclude_these_directories);
     
    29883011//  log_it("Asking what_number_cd_is_this");
    29893012    if (g_ISO_restore_mode) {
    2990         mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'");
    2991 
    2992         mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
     3013        tmp = call_program_and_get_last_line_of_output("mount | grep iso9660 | awk '{print $3;}'");
     3014        mr_asprintf(mountdev, "%s%s", tmp, "/archives/THIS-CD-NUMBER");
     3015        mr_free(tmp);
    29933016        cd_number = atoi(last_line_of_file(mountdev));
    2994         paranoid_free(mountdev);
    2995         paranoid_free(tmp);
     3017        mr_free(mountdev);
    29963018
    29973019        return (cd_number);
     
    30113033        }
    30123034    }
    3013     paranoid_free(mountdev);
     3035    mr_free(mountdev);
    30143036
    30153037    cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
     
    30213043 * Find out what device is mounted as root (/).
    30223044 * @return Root device.
    3023  * @note The returned string points to static storage and will be overwritten with every call.
     3045 * @note The returned string points to storage that needs to be freed by
     3046 * caller
    30243047 * @bug A bit of a misnomer; it's actually finding out the root device.
    30253048 * The mountpoint (where it's mounted) will obviously be '/'.
     
    30283051
    30293052/*@ buffers **************** */
    3030 static char tmp[MAX_STR_LEN];
    3031 
     3053char *tmp = NULL;
    30323054
    30333055#ifdef __FreeBSD__
    3034     strcpy(tmp, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1"));
     3056    tmp = call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1");
    30353057#else
    3036     strcpy(tmp, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//"));
     3058    tmp = call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//");
    30373059    if (strstr(tmp, "/dev/cciss/")) {
    3038         strcpy(tmp, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1"));
     3060        mr_free(tmp);
     3061        tmp = call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1");
    30393062    }
    30403063    if (strstr(tmp, "/dev/md")) {
    3041         strcpy(tmp, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1"));
     3064        mr_free(tmp);
     3065        tmp = call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1");
    30423066    }
    30433067#endif
     
    31313155    assert(which_device != NULL);
    31323156
    3133     mr_asprintf(list_drives_cmd, "mr-parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted());
     3157    tmp = where_is_root_mounted();
     3158    mr_asprintf(list_drives_cmd, "mr-parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", tmp);
    31343159    log_it("list_drives_cmd = %s", list_drives_cmd);
    3135 
     3160    mr_free(tmp);
    31363161    if (!(pdrives = popen(list_drives_cmd, "r"))) {
    31373162        log_OS_error("Unable to open list of drives");
     
    32763301            log_msg(1, "curr_fname = %s", curr_fname);
    32773302            mr_asprintf(command, "file %s", curr_fname);
    3278             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     3303            tmp = call_program_and_get_last_line_of_output(command);
    32793304            mr_free(command);
    32803305            for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' ';
     
    33183343    char *output = NULL;
    33193344    char *command = NULL;
     3345
    33203346    mr_asprintf(command, "mr-disk-type %s", drive);
    3321     mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     3347    output = call_program_and_get_last_line_of_output(command);
    33223348    mr_free(command);
    33233349
  • branches/3.2/mondo/src/common/libmondo-fifo.c

    r3191 r3610  
    165165    mr_asprintf(command, "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $2;}' | grep -v PID | head -1", ps_options, g_sz_call_to_buffer);
    166166    log_msg(2, "kill_buffer() --- command = %s", command);
    167     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     167    tmp = call_program_and_get_last_line_of_output(command);
    168168    mr_free(command);
    169169
  • branches/3.2/mondo/src/common/libmondo-filelist.c

    r3381 r3610  
    861861    mr_asprintf(tmp1, "zcat %s | wc -l", filelist_fname);
    862862    log_msg(6, "tmp1 = %s", tmp1);
    863     lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp1));
     863    tmp = call_program_and_get_last_line_of_output(tmp1);
     864    lines_in_filelist = atol(tmp);
     865    mr_free(tmp);
    864866    mr_free(tmp1);
    865867
     
    13021304    char *new = NULL;
    13031305    char *tmp = NULL;
     1306    char *tmp2 = NULL;
    13041307    char *dir = NULL;
    13051308    static int percentage = 0;
     
    13581361
    13591362        mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1360         g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
     1363        tmp2 = call_program_and_get_last_line_of_output(tmp);
     1364        g_skeleton_entries = 1 + atol(tmp2);
     1365        mr_free(tmp2);
    13611366        mr_free(tmp);
    13621367
     
    15231528        }
    15241529        make_hole_for_file(sz_datefile);
    1525         write_one_liner_data_file(sz_datefile,
    1526                                   call_program_and_get_last_line_of_output
    1527                                   ("date +%s"));
     1530        tmp2 = call_program_and_get_last_line_of_output("date +%s");
     1531        write_one_liner_data_file(sz_datefile, tmp2);
     1532        mr_free(tmp2);
    15281533    } else if (lstat(sz_datefile, &statbuf)) {
    15291534        log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");
     
    15501555        }
    15511556        log_msg(1, "Calculating filelist");
    1552         mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     1557        tmp2 = call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'");
    15531558        if (strlen(tmp2) < 1) {
    15541559            mr_asprintf(tmp1," ");
     
    15571562            mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    15581563            mr_free(tmp2);
    1559             mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
     1564            tmp2 = call_program_and_get_last_line_of_output(tmp1);
    15601565            log_msg(2, "Found windows files: %s",tmp2);
    15611566        }
  • branches/3.2/mondo/src/common/libmondo-files-EXT.h

    r3191 r3610  
    3232extern long size_of_all_biggiefiles_K();
    3333extern void copy_mondo_and_mindi_stuff_to_scratchdir();
    34 extern void store_netfs_config();
    35 
    3634
    3735extern void estimate_noof_media_required(long);
  • branches/3.2/mondo/src/common/libmondo-files.c

    r3430 r3610  
    276276
    277277    if (!kernel[0]) {
    278         strcpy(kernel, call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     278        tmp = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
     279        strcpy(kernel, tmp);
     280        mr_free(tmp);
    279281    }
    280282    // If we didn't get anything back, check whether mindi raised a fatal error
    281283    if (!kernel[0]) {
    282284        mr_asprintf(command, "grep 'Fatal error' %s", MINDI_LOGFILE);
    283         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     285        tmp = call_program_and_get_last_line_of_output(command);
    284286        if (strlen(tmp) > 1) {
    285287            popup_and_OK(tmp);
     
    334336    assert_string_is_neither_NULL_nor_zerolength(fname);
    335337    mr_asprintf(command, "which %s 2> /dev/null", fname);
    336     mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     338    incoming = call_program_and_get_last_line_of_output(command);
    337339    mr_free(command);
    338340
     
    346348        mr_free(incoming);
    347349
    348         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     350        incoming = call_program_and_get_last_line_of_output(command);
    349351        mr_free(command);
    350352    }
     
    353355        mr_free(incoming);
    354356
    355         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     357        mr_free(command);
     358        incoming = call_program_and_get_last_line_of_output(command);
    356359        mr_free(command);
    357360    }
     
    435438    if (i < 0) {
    436439        mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    437         mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
     440        lastline = call_program_and_get_last_line_of_output(command);
    438441        mr_free(command);
    439442        if (!lastline[0]) {
     
    730733
    731734    log_it(command);
    732     mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
     735    sz_res = call_program_and_get_last_line_of_output(command);
    733736    file_len_K = atol(sz_res);
    734737    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     
    786789                    mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    787790                    log_it("command = %s", command);
    788                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     791                    tmp = call_program_and_get_last_line_of_output(command);
    789792                    mr_free(command);
    790793
     
    10591062    mr_free(command);
    10601063
    1061     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
     1064    tmp = call_program_and_get_last_line_of_output("which mondorestore");
    10621065    if (!tmp[0]) {
    10631066        mr_free(tmp);
     
    10891092
    10901093    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    1091 }
    1092 
    1093 
    1094 /**
    1095  * Store the client's NETFS configuration in files to be restored at restore-time.
    1096  * Assumes that @c bkpinfo->media_type = netfs, but does not check for this.
    1097  * @param bkpinfo The backup information structure. Fields used:
    1098  * - @c netfs_mount
    1099  * - @c tmpdir
    1100  */
    1101 void store_netfs_config()
    1102 {
    1103 
    1104     /*@ buffers ******** */
    1105     char *netfs_dev = NULL;
    1106     char *netfs_client_hwaddr = NULL;
    1107     char *command = NULL;
    1108 
    1109     /********
    1110     * If the Network device found above is a bonded device,
    1111     * we need to replace it with an ethN device or the
    1112     * networking will not start during an Network restore.
    1113     *
    1114     * If the Network device in netfs_dev begins with the word "bond", or alb or aft
    1115     * look for the corresponding slave ethN device and copy it to netfs_dev.
    1116     * Using the common MAC address
    1117     ********/
    1118     if (!strncmp(netfs_dev, "bond", 4) || !strncmp(netfs_dev, "alb", 3) || !strncmp(netfs_dev, "aft", 3)) {
    1119         log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    1120         mr_asprintf(command, "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1",netfs_client_hwaddr,netfs_dev);
    1121         mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    1122         mr_free(command);
    1123         log_to_screen("Replacing it with %s\n", netfs_dev);
    1124     }
    1125 
    1126     log_it("Finished storing Network configuration");
    11271094}
    11281095
  • branches/3.2/mondo/src/common/libmondo-files.h

    r3191 r3610  
    3131
    3232void copy_mondo_and_mindi_stuff_to_scratchdir();
    33 void store_netfs_config();
    3433void estimate_noof_media_required(long);
    3534bool is_this_file_compressed(char *);
  • branches/3.2/mondo/src/common/libmondo-fork.c

    r3604 r3610  
    3535 * @param call The program to run.
    3636 * @return The last line of its output.
    37  * @note The returned value points to static storage that will be overwritten with each call.
     37 * @note The returned value points to storage that needs to be freed by the
     38 * caller
    3839 */
    3940char *call_program_and_get_last_line_of_output(char *call)
    4041{
    4142    /*@ buffers ***************************************************** */
    42     static char result[MAX_STR_LEN];
     43    char *result = NULL;
    4344    char *tmp = NULL;
    4445
     
    4647    FILE *fin = NULL;
    4748    char *eng_call = NULL;
    48 
    49     /*@ initialize data ********************************************* */
    50     result[0] = '\0';
    5149
    5250    /*@******************************************************************** */
     
    5755    if ((fin = popen(eng_call, "r"))) {
    5856        while (!feof(fin)) {
    59             mr_getline(tmp, fin);
    60             if (strlen(tmp) > 1) {
    61                 strcpy(result, tmp);
     57            mr_free(result);
     58            mr_getline(result, fin);
     59            if (strlen(result) > 1) {
    6260                log_msg(7, "result = '%s'", result);
    6361            }
    64             mr_free(tmp);
    6562        }
    6663        paranoid_pclose(fin);
     
    6966    }
    7067    mr_free(eng_call);
    71     strip_spaces(result);
     68    mr_strip_spaces(result);
    7269    log_msg(5, "cpaglloo returns '%s'", result);
    7370    return(result);
  • branches/3.2/mondo/src/common/libmondo-raid.c

    r3566 r3610  
    10071007            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
    10081008            mr_asprintf(cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    1009             mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1009            strtmp = call_program_and_get_last_line_of_output(cmd);
    10101010            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
    10111011            mr_free(strtmp);
     
    10141014            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version");
    10151015            mr_asprintf(cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    1016             mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1016            strtmp = call_program_and_get_last_line_of_output(cmd);
    10171017            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
    10181018            mr_free(strtmp);
  • branches/3.2/mondo/src/common/libmondo-stream.c

    r3527 r3610  
    256256int find_tape_device_and_size(char *dev, char *siz)
    257257{
    258     char tmp[MAX_STR_LEN];
     258    char *tmp = NULL;
    259259    char *command = NULL;
    260260    char *cdr_exe = NULL;
     
    269269    }
    270270    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    271     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     271    tmp = call_program_and_get_last_line_of_output(command);
    272272    mr_free(command);
    273273
     
    282282
    283283    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe);
    284     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     284    tmp = call_program_and_get_last_line_of_output(command);
    285285    mr_free(command);
    286286
     
    294294    mr_free(cdr_exe);
    295295
    296     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     296    tmp = call_program_and_get_last_line_of_output(command);
    297297    mr_free(command);
    298298
     
    326326    }
    327327
    328     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     328    tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'");
    329329
    330330    if (mt_says_tape_exists(dev)) {
  • 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
  • branches/3.2/mondo/src/mondorestore/mondo-prep.c

    r3570 r3610  
    154154char *tmp;
    155155char *tmp1 = NULL;
     156char *tmp2 = NULL;
    156157char *incoming;
    157158char *command;
     
    186187#endif
    187188
    188 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "nolvm")) {
     189tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     190if (strstr(tmp, "nolvm")) {
     191    mr_free(tmp);
    189192    return(0);
    190193}
     194mr_free(tmp);
     195
    191196if (!(fin = fopen("/tmp/i-want-my-lvm", "r"))) {
    192197    log_OS_error("/tmp/i-want-my-lvm");
     
    299304            if (lvmversion == 2) {
    300305                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    301                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    302                 free(tmp1);
    303306            } else {
    304307                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    305                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    306                 free(tmp1);
    307308            }
     309            tmp2 =  call_program_and_get_last_line_of_output(tmp1);
     310            strcpy(tmp, tmp2);
     311            mr_free(tmp2);
     312            mr_free(tmp1);
     313
    308314            for (p = tmp; *p != '\0' && !isdigit(*p); p++);
    309315            extents = atol(p);
     
    14821488    // mark relevant partition as bootable
    14831489    mr_asprintf(tmp1,"mr-make-me-bootable /tmp/mountlist.txt %s",drivename);
    1484     call_program_and_get_last_line_of_output(tmp1);
     1490    tmp = call_program_and_get_last_line_of_output(tmp1);
    14851491    mr_free(tmp1);
     1492    mr_free(tmp);
    14861493
    14871494    log_msg(0,"------------------- end of fdisk.log...       ------------------");
  • branches/3.2/mondo/src/mondorestore/mondo-rstr-tools.c

    r3601 r3610  
    695695                strcpy(bkpinfo->prefix,STD_PREFIX);
    696696        }
    697         if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     697        tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     698        if (strstr(tmp1, "pxe")) {
    698699            /* We need to override prefix value in PXE mode as it's
    699700            * already done in start-netfs */
     
    704705            strcpy(bkpinfo->prefix,envtmp1);
    705706        }   
     707        mr_free(tmp1);
    706708    } else if (!strcmp(value, "tape")) {
    707709        bkpinfo->backup_media_type = tape;
     
    832834
    833835read_cfg_var(cfg_file, "please-dont-eject", value);
    834 if (value[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) {
     836tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     837if (value[0] || strstr(tmp1, "donteject")) {
    835838    bkpinfo->please_dont_eject = TRUE;
    836839    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    837840}
     841mr_free(tmp1);
    838842
    839843/* TODO: Read here the boot_* variables */
     
    881885        }
    882886    }
    883     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     887    tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     888    if (strstr(tmp1, "pxe")) {
    884889        /* We need to override values in PXE mode as it's
    885890        * already done in start-netfs */
     
    898903        mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2);
    899904    }
     905    mr_free(tmp1);
    900906} else if (bkpinfo->backup_media_type == iso) {
    901907    /* Patch by Conor Daly 23-june-2004
     
    932938            mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    933939            log_it("command = %s", command);
    934             log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    935             sprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     940            tmp1 = call_program_and_get_last_line_of_output(command);
     941            log_it("res of it = %s", tmp1);
     942            sprintf(iso_mnt, "%s", tmp1);
    936943            mr_free(command);
     944            mr_free(tmp1);
    937945        } else {
    938946            sprintf(iso_mnt, "/tmp/isodir");
     
    20642072    char *cfg_file = NULL;
    20652073    char *tmp = NULL;
     2074    char *tmp1 = NULL;
    20662075    char *mountpt = NULL;
    20672076    char *mountlist_file = NULL;
     
    21772186    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    21782187        log_msg(1, "gcffa --- great! We've got the config file");
    2179         mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2188        tmp1 = call_program_and_get_last_line_of_output("pwd");
     2189        mr_asprintf(tmp, "%s/%s", tmp1, MONDO_CFG_FILE_STUB);
    21802190        mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
    21812191        log_it("%s",command);
     
    21892199        mr_free(command);
    21902200
    2191         mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"), MOUNTLIST_FNAME_STUB, mountlist_file);
     2201        mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);
     2202        mr_free(tmp1);
    21922203        log_it("%s",command);
    21932204        if (extract_mountlist_stub) {
  • branches/3.2/mondo/src/mondorestore/mondorestore.c

    r3564 r3610  
    18761876    log_it("Done loading config file; resizing ML");
    18771877
    1878     mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     1878    tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
    18791879    if (strstr(tmp1, "noresize")) {
    18801880        log_msg(1, "Not resizing mountlist.");
     
    21022102    get_cfg_file_from_archive_or_bust();
    21032103    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    2104 #ifdef __FreeBSD__
    2105     if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "noresize"))
    2106 #else
    2107     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "noresize"))
    2108 #endif
    2109     {
     2104    tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     2105    if (strstr(tmp, "noresize")) {
    21102106        log_msg(2, "Not resizing mountlist.");
    21112107    } else {
    21122108        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    21132109    }
     2110    mr_free(tmp);
     2111
    21142112    flaws_str = evaluate_mountlist(mountlist);
    21152113    if (flaws_str != NULL) {
     
    21382136            twenty_seconds_til_yikes();
    21392137            g_fprep = fopen("/tmp/prep.sh", "w");
    2140             mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     2138            tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
    21412139            if (strstr(tmp1, "nopart")) {
    21422140                log_msg(2, "Not partitioning drives due to 'nopart' option.");
     
    22042202
    22052203  after_the_nuke:
    2206     mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     2204    tmp1 =call_program_and_get_last_line_of_output("cat "CMDLINE);
    22072205    if (retval) {
    22082206        log_to_screen("Errors occurred during the nuke phase.");
     
    25952593
    25962594/* Configure global variables */
    2597 #ifdef __FreeBSD__
    2598     if (strstr
    2599         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    2600          "textonly"))
    2601 #else
    2602     if (strstr
    2603         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    2604          "textonly"))
    2605 #endif
    2606     {
     2595    tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     2596    if (strstr(tmp, "textonly")) {
    26072597        g_text_mode = TRUE;
    26082598        log_msg(1, "TEXTONLY MODE");
     
    26102600        g_text_mode = FALSE;
    26112601    }                           // newt :-)
     2602    mr_free(tmp);
     2603
    26122604    if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
    26132605        fatal_error("Cannot malloc mountlist");
     
    26222614    malloc_libmondo_global_strings();
    26232615
    2624     strcpy(g_mondo_home,
    2625            call_program_and_get_last_line_of_output("which mondorestore"));
     2616    tmp = call_program_and_get_last_line_of_output("which mondorestore");
     2617    strcpy(g_mondo_home, tmp);
     2618        mr_free(tmp);
     2619
    26262620    g_current_media_number = 1; // precaution
    2627 
    26282621    run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE);
    26292622
Note: See TracChangeset for help on using the changeset viewer.