Changeset 2383


Ignore:
Timestamp:
Sep 10, 2009, 2:55:51 AM (9 years ago)
Author:
bruno
Message:

call_program_and_get_last_line_of_output is now allocating memory and returning that string

Location:
branches/2.2.10/mondo/src
Files:
12 edited

Legend:

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

    r2382 r2383  
    539539    if (bkpinfo->exclude_paths) {
    540540        mr_asprintf(tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths);
    541         mr_asprintf(devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp));
     541        devs_to_exclude = call_program_and_get_last_line_of_output(tmp);
    542542        mr_free(tmp);
    543543
     
    626626
    627627#ifdef __FreeBSD__
    628         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/'"));
     628        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    629629        if (!bootdev[0]) {
    630630            mr_free(bootdev);
    631             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     631            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    632632        }
    633633#else
    634634        /* Linux */
    635635#ifdef __IA64__
    636         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].*//'"));
     636        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    637637#else
    638         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     638        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    639639#endif
    640640        if (strstr(bootdev, "/dev/cciss/")) {
    641641            mr_free(bootdev);
    642642#ifdef __IA64__
    643             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     643            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    644644#else
    645             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     645            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    646646#endif
    647647        }
    648648        if (!bootdev[0]) {
    649649            mr_free(bootdev);
    650             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     650            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    651651            if (strstr(bootdev, "/dev/cciss/")) {
    652652                mr_free(bootdev);
    653                 mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     653                bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    654654            }
    655655        }
     
    928928        log_to_screen("Mindi failed to create your boot+data disks.");
    929929        mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log");
    930         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     930        tmp = call_program_and_get_last_line_of_output(command);
    931931        mr_free(command);
    932932
     
    11851185    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11861186
    1187     mr_asprintf(g_serial_string, "%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"));
     1187    g_serial_string = 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");
    11881188    mr_strip_spaces(g_serial_string);
    11891189    mr_strcat(g_serial_string, "...word.");
     
    18921892    mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname);
    18931893    log_msg(1, "command = '%s'", command);
    1894     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1894    tmp = call_program_and_get_last_line_of_output(command);
    18951895    mr_free(command);
    18961896
     
    26602660            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    26612661            mr_free(our_serial_str);
    2662             mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
     2662            our_serial_str = call_program_and_get_last_line_of_output(tmp);
    26632663            mr_free(tmp);
    26642664            // FIXME - should be able to use last_line_of_file(), surely?
     
    28592859        mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    28602860        log_it("command = %s", command);
    2861         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2861        tmp = call_program_and_get_last_line_of_output(command);
    28622862        mr_free(command);
    28632863        log_it("res of it = %s", tmp);
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2382 r2383  
    264264    mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
    265265    log_msg(5, "Running: %s", command);
    266     mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     266    mounted_file_system = call_program_and_get_last_line_of_output(command);
    267267    mr_free(command);
    268268
     
    274274        mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
    275275        log_msg(5, "Running: %s", command);
    276         mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     276        mounted_file_system = call_program_and_get_last_line_of_output(command);
    277277        mr_free(command);
    278278
     
    333333    int c = 0;
    334334    int lastpos = 0;
    335     char VG[MAX_STR_LEN];
     335    char *VG = NULL;
    336336    char *tmp = NULL;
    337337    char *command = NULL;
     
    358358    mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf);
    359359    log_msg(5, "  Executing: %s", command);
    360     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     360    tmp = call_program_and_get_last_line_of_output(command);
    361361    mr_free(command);
    362362
     
    384384    mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    385385    log_msg(4, "Executing: %s", command);
    386     mr_asprintf(partition_list, "%s", call_program_and_get_last_line_of_output(command));
     386    partition_list = call_program_and_get_last_line_of_output(command);
    387387    mr_free(command);
    388388    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
     
    438438          dsf, partitions[i]);
    439439        log_msg(4, "  Running: %s", command);
    440         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     440        tmp = call_program_and_get_last_line_of_output(command);
    441441        mr_free(command);
    442442
     
    451451        /* It's not swap. See if we can find the mount point from the mount command. */
    452452        mr_asprintf(command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    453         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     453        tmp = call_program_and_get_last_line_of_output(command);
    454454        mr_free(command);
    455455
     
    471471        mr_asprintf(command, "parted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
    472472        log_msg(4, "  Running: %s", command);
    473         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     473        tmp = call_program_and_get_last_line_of_output(command);
    474474        mr_free(command);
    475475        if (strlen(tmp)) {
     
    480480                mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    481481                log_msg(4, "  Running: %s", command);
    482                 strcpy(VG, call_program_and_get_last_line_of_output(command));
     482                VG = call_program_and_get_last_line_of_output(command);
    483483                mr_free(command);
    484484                log_msg(4, "  Volume Group: %s", VG);
     
    488488                    mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
    489489                    log_msg(4, "  Running: %s", command);
    490                     mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     490                    mount_list = call_program_and_get_last_line_of_output(command);
    491491                    mr_free(command);
     492
    492493                    log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    493494                    lastpos = 0;
     
    498499                            mr_free(tmp);
    499500                            mr_free(token);
     501                            mr_free(VG);
    500502                            return (1);
    501503                        }
     
    510512                    mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    511513                    log_msg (5, "Running: %s", command);
    512                     mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     514                    mount_list = call_program_and_get_last_line_of_output(command);
    513515                    mr_free(command);
    514516                    log_msg(4, "  Software raid device list: %s", mount_list);
     
    518520                        log_msg (5, "Running: %s", command);
    519521                        mr_free(tmp);
    520                         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     522
     523                        tmp = call_program_and_get_last_line_of_output(command);
    521524                        mr_free(command);
     525
    522526                        log_msg(4, "Number of Software raid device: %s", tmp);
    523527                        if (atoi(tmp)) {
     
    527531                                mr_free(tmp);
    528532                                mr_free(token);
     533                                mr_free(VG);
    529534                                return (1);
    530535                            }
     
    537542                    log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    538543                    mr_free(tmp);
     544                    mr_free(VG);
    539545                    return (1);
    540546                }
    541547                mr_free(tmp);
     548                mr_free(VG);
    542549                continue;
    543550            }
     
    552559        mr_asprintf(command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
    553560        log_msg(4, "  Running: %s", command);
    554         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     561        tmp = call_program_and_get_last_line_of_output(command);
    555562        mr_free(command);
    556563        if (!strlen(tmp)) {
     
    563570        mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    564571        log_msg (5, "  Running: %s", command);
    565         mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     572        mount_list = call_program_and_get_last_line_of_output(command);
    566573        mr_free(command);
    567574        log_msg(4, "  Software raid device list: %s", mount_list);
     
    572579            log_msg(4, "  Running: %s", command);
    573580            mr_free(tmp);
    574             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     581            tmp = call_program_and_get_last_line_of_output(command);
    575582            mr_free(command);
    576583            if (!atoi(tmp)) {
     
    10091016        mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    10101017        mr_free(bkpinfo->isodir);
    1011         mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(tmp1));
     1018        bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp1);
    10121019        mr_free(tmp1);
    10131020
     
    10271034                mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    10281035                mr_free(bkpinfo->isodir);
    1029                 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(tmp1));
     1036                bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp1);
    10301037                mr_free(tmp1);
    10311038
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2382 r2383  
    525525    if (tmp1) {
    526526        mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);
    527         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     527        tmp = call_program_and_get_last_line_of_output(command);
    528528        mr_free(command);
    529529    }
     
    805805
    806806    log_msg(1, "command=%s", command);
    807     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     807    tmp = call_program_and_get_last_line_of_output(command);
    808808    mr_free(command);
    809809
     
    833833    }
    834834
    835     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1"));
     835    tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1");
    836836    log_msg(5, "tmp = '%s'", tmp);
    837837    if (!tmp[0])
    838838        mr_free(tmp);
    839         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    840             );
     839        tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1");
    841840    if (tmp[0]) {
    842841        devno = atoi(tmp) - 1;
     
    10971096    char *mddevice = (char *) malloc(32);
    10981097    char command[MAX_STR_LEN];
     1098    char *tmp = NULL;
    10991099    int vndev = 2;
    1100     if (atoi
    1101         (call_program_and_get_last_line_of_output
    1102          ("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1100    int i = 2;
     1101
     1102    tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate"));
     1103    i = atoi(tmp);
     1104    mr_free(tmp);
     1105
     1106    if (i < 500000) {
    11031107        do {
    11041108            sprintf(mddevice, "vn%ic", vndev++);
     
    11331137{
    11341138    char *command = NULL;
     1139    char *tmp = NULL;
    11351140    int res = 0;
     1141    int i = 0;
    11361142
    11371143    if (strncmp(dname, "/dev/", 5) == 0) {
     
    11391145    }
    11401146
    1141     if (atoi
    1142         (call_program_and_get_last_line_of_output
    1143          ("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1147    tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate"));
     1148    i = atoi(tmp);
     1149    mr_free(tmp);
     1150
     1151    if (i < 500000) {
    11441152        mr_asprintf(command, "vnconfig -d %s", dname);
    11451153    } else {
     
    16531661        /* Initiate bkpinfo netfs_mount path from running environment if not already done */
    16541662        if (bkpinfo->netfs_mount == NULL) {
    1655             mr_asprintf(bkpinfo->netfs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
     1663            bkpinfo->netfs_mount = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1");
    16561664        }
    16571665#ifdef __FreeBSD__
     
    16821690            mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->netfs_mount);
    16831691            mr_free(bkpinfo->isodir);
    1684             mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(command));
     1692            bkpinfo->isodir = call_program_and_get_last_line_of_output(command);
    16851693            mr_free(command);
    16861694
     
    17221730        mr_free(bkpinfo->isodir);
    17231731        if (is_this_device_mounted(bkpinfo->netfs_mount)) {
    1724             mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     1732            bkpinfo->isodir = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1");
    17251733
    17261734        } else {
     
    18271835#ifdef __FreeBSD__
    18281836#define EXAMPLEBD   "/dev/ad0"
    1829         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/'"));
     1837        bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    18301838#else
    18311839#define EXAMPLEBD   "/dev/hda"
    1832         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].*//'"));
     1840        bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    18331841#endif
    18341842        i = which_boot_loader(bkpinfo->boot_device);
     
    18871895        mr_free(tmp);
    18881896// NTFS
    1889         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));
     1897        tmp = call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'");
    18901898        if (strlen(tmp) > 2) {
    18911899            p = popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp);
     
    20302038
    20312039    mr_asprintf(exclude_these_directories,"%s",list_of_NETFS_mounts_only());
    2032     mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));
     2040    exclude_these_devices = call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'");
    20332041    snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices);
    20342042    mr_free(exclude_these_devices);
     
    20512059    static char result_sz[512];
    20522060
    2053     mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));
     2061    exclude_these_directories = call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'");
    20542062    snprintf(result_sz, 511, "%s", exclude_these_directories);
    20552063    mr_free(exclude_these_directories);
     
    21032111
    21042112#ifdef __FreeBSD__
    2105     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2113    tmp = call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'");
    21062114#else
    2107     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x vfat -x ntfs -x ntfs-3g -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 -n | tail -n1 | awk '{print $NF;}'"));
     2115    tmp = call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x vfat -x ntfs -x ntfs-3g -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 -n | tail -n1 | awk '{print $NF;}'");
    21082116#endif
    21092117
     
    21992207    if (g_ISO_restore_mode) {
    22002208        mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'");
    2201         mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
     2209        mountdev = call_program_and_get_last_line_of_output(tmp);
     2210        mr_strcat(mountdev, "/archives/THIS-CD-NUMBER");
    22022211        mr_free(tmp);
    22032212
     
    22522261
    22532262#ifdef __FreeBSD__
    2254     mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"));
     2263    output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1");
    22552264#else
    2256     mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | sed 's/[0-9]//' | sed 's/[0-9]//'"));
     2265    output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | sed 's/[0-9]//' | sed 's/[0-9]//'");
    22572266    if (strstr(output, "/dev/cciss/")) {
    22582267        mr_free(output);
    2259         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | cut -dp -f1"));
     2268        output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | cut -dp -f1");
    22602269    }
    22612270    if (strstr(output, "/dev/md")) {
    22622271        mr_free(output);
    2263         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"));
     2272        output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1");
    22642273    }
    22652274#endif
     
    24992508            log_msg(1, "curr_fname = %s", curr_fname);
    25002509            mr_asprintf(command, "file %s", curr_fname);
    2501             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2510            tmp = call_program_and_get_last_line_of_output(command);
    25022511            mr_free(command);
    25032512            for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; p--);
     
    25502559    mr_free(fdisk);
    25512560
    2552     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2561    tmp = call_program_and_get_last_line_of_output(command);
    25532562    mr_free(command);
    25542563
  • branches/2.2.10/mondo/src/common/libmondo-fifo.c

    r2376 r2383  
    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/2.2.10/mondo/src/common/libmondo-filelist.c

    r2382 r2383  
    860860    char *fname = NULL;
    861861    char *tmp = NULL;
     862    char *tmp1 = NULL;
    862863    int pos_in_fname;
    863864    /*@ int ******************************************************** */
     
    877878    mr_asprintf(tmp, "zcat %s | wc -l", filelist_fname);
    878879    log_msg(6, "tmp = %s", tmp);
    879     lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp));
     880
     881    tmp1 = call_program_and_get_last_line_of_output(tmp);
    880882    mr_free(tmp);
     883
     884    lines_in_filelist = atol(tmp1);
     885    mr_free(tmp1);
    881886
    882887    if (lines_in_filelist < 3) {
     
    13201325    char *new;
    13211326    char *tmp = NULL;
     1327    char *tmp1 = NULL;
    13221328    char *dir = NULL;
    13231329    static int percentage = 0;
     
    13701376
    13711377        mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1372         g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
     1378        tmp1 = call_program_and_get_last_line_of_output(tmp);
    13731379        mr_free(tmp);
     1380
     1381        g_skeleton_entries = 1 + atol(tmp1);
     1382        mr_free(tmp1);
    13741383
    13751384        mr_asprintf(name_of_evalcall_form, "Making catalog of %s", dir);
     
    15331542        }
    15341543        make_hole_for_file(sz_datefile);
    1535         write_one_liner_data_file(sz_datefile,
    1536                                   call_program_and_get_last_line_of_output
    1537                                   ("date +%s"));
     1544        tmp1 = call_program_and_get_last_line_of_output("date +%s");
     1545        write_one_liner_data_file(sz_datefile, tmp1);
     1546        mr_free(tmp1);
    15381547    } else if (lstat(sz_datefile, &statbuf)) {
    15391548        log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");
     
    15601569        }
    15611570        log_msg(1, "Calculating filelist");
    1562         mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     1571        tmp2 = call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'");
    15631572        if (strlen(tmp2) < 1) {
    15641573            mr_asprintf(tmp1," ");
     
    15671576            mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    15681577            mr_free(tmp2);
    1569             mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
     1578            tmp2 = call_program_and_get_last_line_of_output(tmp1);
    15701579            log_msg(2, "Found windows files: %s",tmp2);
    15711580        }
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2382 r2383  
    274274    char *kernel = NULL;;
    275275
    276     mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     276    kernel = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
    277277   
    278278    // If we didn't get anything back, check whether mindi raised a fatal error
    279279    if (!kernel[0]) {
    280280        mr_asprintf(command, "%s", "grep 'Fatal error' /var/log/mindi.log");
    281         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     281        tmp = call_program_and_get_last_line_of_output(command);
    282282        if (strlen(tmp) > 1) {
    283283            popup_and_OK(tmp);
     
    331331    assert_string_is_neither_NULL_nor_zerolength(fname);
    332332    mr_asprintf(command, "which %s 2> /dev/null", fname);
    333     mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     333    output = call_program_and_get_last_line_of_output(command);
    334334    mr_free(command);
    335335    if (output[0] == '\0') {
     
    340340        mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", output);
    341341        mr_free(output);
    342         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     342        output = call_program_and_get_last_line_of_output(command);
    343343        mr_free(command);
    344344    }
     
    346346        mr_asprintf(command, "dirname %s 2> /dev/null", output);
    347347        mr_free(output);
    348         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     348        output = call_program_and_get_last_line_of_output(command);
    349349        mr_free(command);
    350350    }
     
    428428    for (i = NOOF_ERR_LINES - 1; i >= 0 && !strstr(err_log_lines[i], "% Done") && !strstr(err_log_lines[i], "% done"); i--);
    429429    if (i < 0) {
    430         mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    431         mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
     430        mr_asprintf(command, "tail -n3 %s | grep -Fi %% | tail -n1 | awk '{print $0;}'", filename);
     431        lastline = call_program_and_get_last_line_of_output(command);
    432432        mr_free(command);
    433433        if (!lastline[0]) {
     
    722722
    723723    log_it(command);
    724     mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
     724    sz_res = call_program_and_get_last_line_of_output(command);
    725725    file_len_K = atol(sz_res);
    726726    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     
    779779                    mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    780780                    log_it("command = %s", command);
    781                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     781                    tmp = call_program_and_get_last_line_of_output(command);
    782782                    mr_free(command);
    783783
     
    10301030    }
    10311031
    1032     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
     1032    tmp = call_program_and_get_last_line_of_output("which mondorestore");
    10331033    if (!tmp[0]) {
    10341034        mr_free(tmp);
     
    11011101    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    11021102    mr_asprintf(command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    1103     mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
     1103    netfs_dev = call_program_and_get_last_line_of_output(command);
    11041104    mr_free(command);
    11051105
    11061106    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    1107     mr_asprintf(netfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
     1107    netfs_client_ipaddr = call_program_and_get_last_line_of_output(command);
    11081108    mr_free(command);
    11091109
    11101110    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    1111     mr_asprintf(netfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
     1111    netfs_client_netmask = call_program_and_get_last_line_of_output(command);
    11121112    mr_free(command);
    11131113
    11141114    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    1115     mr_asprintf(netfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
     1115    netfs_client_broadcast = call_program_and_get_last_line_of_output(command);
    11161116    mr_free(command);
    11171117
    11181118    mr_asprintf(command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    1119     mr_asprintf(netfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
     1119    netfs_client_defgw = call_program_and_get_last_line_of_output(command);
    11201120    mr_free(command);
    11211121
     
    11361136        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    11371137        mr_asprintf(command, "%s", "ifconfig %s | awk '{print $5}' | head -n1", netfs_dev);
    1138         mr_asprintf(mac_addr, "%s", call_program_and_get_last_line_of_output(command));
     1138        mac_addr = call_program_and_get_last_line_of_output(command);
    11391139        mr_free(command);
    11401140
     
    11431143        mr_free(netfs_dev);
    11441144
    1145         mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
     1145        netfs_dev = call_program_and_get_last_line_of_output(command);
    11461146        mr_free(command);
    11471147
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2382 r2383  
    3737{
    3838    /*@ buffers ***************************************************** */
    39     static char result[512];
    40     char *tmp = NULL;
     39    char *result = NULL;
    4140
    4241    /*@ pointers **************************************************** */
    4342    FILE *fin;
    4443
    45     /*@ initialize data ********************************************* */
    46     result[0] = '\0';
    47 
    4844    /*@******************************************************************** */
    4945
    5046    assert_string_is_neither_NULL_nor_zerolength(call);
    5147    if ((fin = popen(call, "r"))) {
    52         for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
    53             if (strlen(tmp) > 1) {
    54                 strncpy(result, tmp, 511);
    55             }
    56             mr_free(tmp);
    57         }
    58         mr_free(tmp);
     48        for (mr_getline(result, fin); !feof(fin); mr_getline(result, fin));
    5949        paranoid_pclose(fin);
    6050    } else {
    6151        log_OS_error("Unable to popen call");
    6252    }
    63     strip_spaces(result);
    64     return (result);
     53    mr_strip_spaces(result);
     54    return(result);
    6555}
    6656
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2376 r2383  
    265265
    266266    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    267     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     267    tmp = call_program_and_get_last_line_of_output(command);
    268268    mr_free(command);
    269269
     
    277277
    278278    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);
    279     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     279    tmp = call_program_and_get_last_line_of_output(command);
    280280    mr_free(command);
    281281
     
    289289    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' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);
    290290    mr_free(cdr_exe);
    291     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     291    tmp = call_program_and_get_last_line_of_output(command);
    292292    mr_free(command);
    293293
     
    324324    }
    325325
    326     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;};};};'"));
     326    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;};};};'");
    327327
    328328    if (mt_says_tape_exists(dev)) {
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2382 r2383  
    225225    d = 5.2;                    // :-)
    226226#else
    227     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r"));
     227    tmp = call_program_and_get_last_line_of_output("uname -r");
    228228    p = strchr(tmp, '.');
    229229    if (p) {
     
    523523        if (getenv ("SUDO_COMMAND")) {
    524524            mr_asprintf(command, "strings `which growisofs` | grep -c SUDO_COMMAND");
    525             if (!strcmp(call_program_and_get_last_line_of_output(command), "1")) {
     525            tmp = call_program_and_get_last_line_of_output(command);
     526            if (!strcmp(tmp, "1")) {
    526527                mr_free(command);
     528                mr_free(tmp);
    527529                popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    528530                fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    529531            }       
    530532            mr_free(command);
     533            mr_free(tmp);
    531534        }
    532535        log_msg(2, "call_make_iso (DVD res) is ... %s", bkpinfo->call_make_iso);
     
    613616        mr_asprintf(command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir);
    614617        log_it("command = %s", command);
    615         log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    616         mr_asprintf(iso_dev, "%s", call_program_and_get_last_line_of_output(command));
     618        iso_dev = call_program_and_get_last_line_of_output(command);
     619        log_it("res of it = %s", iso_dev);
    617620        mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir);
    618         write_one_liner_data_file(tmp, call_program_and_get_last_line_of_output(command));
     621        write_one_liner_data_file(tmp, iso_dev);
    619622        mr_free(tmp);
    620623        mr_free(command);
     
    624627
    625628        log_it("command = %s", command);
    626         log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    627         mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     629        iso_mnt = call_program_and_get_last_line_of_output(command);
     630        log_it("res of it = %s", iso_mnt);
    628631        mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir);
    629         write_one_liner_data_file(tmp, call_program_and_get_last_line_of_output(command));
     632        write_one_liner_data_file(tmp, iso_mnt);
    630633        mr_free(tmp);
    631634        mr_free(command);
     
    899902
    900903    mr_asprintf(command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", partition);
    901     mr_asprintf(out_sz, "%s", call_program_and_get_last_line_of_output(command));
     904    out_sz = call_program_and_get_last_line_of_output(command);
    902905    mr_free(command);
    903906
     
    941944        run_program_and_log_output("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE);
    942945    }
    943     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
     946    tmp = call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2");
    944947    if (atol(tmp) < 35000) {
    945948        retval++;
     
    10141017
    10151018    run_program_and_log_output("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
    1016     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""));
     1019    tmp = call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\"");
    10171020    if (strcmp("", tmp)) {
    10181021        if (strstr(tmp, "autofs")) {
     
    11041107    } else {
    11051108        mr_asprintf(command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", label, config_file);
    1106         mr_asprintf(value, "%s", call_program_and_get_last_line_of_output(command));
     1109        value = call_program_and_get_last_line_of_output(command);
    11071110        mr_free(command);
    11081111
     
    12321235    mr_asprintf(command, "%s", "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[   ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    12331236    log_msg(4, "Cool. Command = '%s'", command);
    1234     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1237    tmp = call_program_and_get_last_line_of_output(command);
    12351238    mr_free(command);
    12361239
     
    12391242    mr_asprintf(command, "mount | grep -Ew '/boot'");
    12401243    mr_free(tmp);
    1241     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1244    tmp = call_program_and_get_last_line_of_output(command);
    12421245    mr_free(command);
    12431246
     
    14391442 * The command used to start it is saved in @p g_magicdev_command.
    14401443 */
    1441 void stop_magicdev_if_necessary()
    1442 {
    1443     strcpy(g_magicdev_command,
    1444            call_program_and_get_last_line_of_output
    1445            ("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99"));
     1444void stop_magicdev_if_necessary() {
     1445
     1446    char *tmp = NULL;
     1447
     1448    tmp = call_program_and_get_last_line_of_output("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99");
     1449
     1450    strcpy(g_magicdev_command, tmp);
     1451    mr_free(tmp);
     1452
    14461453    if (g_magicdev_command[0]) {
    14471454        log_msg(1, "g_magicdev_command = '%s'", g_magicdev_command);
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2376 r2383  
    336336            if (lvmversion == 2) {
    337337                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    338                 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
     338                tmp = call_program_and_get_last_line_of_output(tmp1);
    339339                mr_free(tmp1);
    340340            } else {
    341341                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    342                 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
     342                tmp = call_program_and_get_last_line_of_output(tmp1);
    343343                mr_free(tmp1);
    344344            }
     
    14141414    char *format = NULL;
    14151415    char *tmp = NULL;
     1416    char *tmp1 = NULL;
    14161417
    14171418    /** end *************************************************************/
     
    15781579    if (pout_to_fdisk) {
    15791580        // mark relevant partition as bootable
    1580         mr_asprintf(tmp, "a\n%s\n", call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy"));
     1581        tmp1 = call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy");
     1582        mr_asprintf(tmp, "a\n%s\n", tmp1);
     1583        mr_free(tmp1);
     1584
    15811585        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    15821586        mr_free(tmp);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2382 r2383  
    756756        }
    757757   
    758         if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
     758        tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     759        if (strstr(tmp, "pxe")) {
    759760            /* We need to override prefix value in PXE mode as it's
    760761            * already done in start-netfs */
     
    766767            mr_asprintf(bkpinfo->prefix, "%s", envtmp1);
    767768        }
     769        mr_free(tmp);
    768770
    769771    } else if (!strcmp(value, "tape")) {
     
    939941
    940942tmp = read_cfg_var(g_mondo_cfg_file, "please-dont-eject");
    941 if (tmp || strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "donteject")) {
     943tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     944if (tmp || strstr(tmp1, "donteject")) {
    942945    bkpinfo->please_dont_eject = TRUE;
    943946    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    944947}
    945948mr_free(tmp);
     949mr_free(tmp1);
    946950
    947951if (bkpinfo->backup_media_type == netfs) {
     
    971975        }
    972976    }
    973     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
     977    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     978    if (strstr(tmp1, "pxe")) {
     979        mr_free(tmp1);
    974980        /* We need to override values in PXE mode as it's
    975981        * already done in start-netfs */
     
    987993        mr_free(bkpinfo->netfs_remote_dir);
    988994        mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2);
    989     }
     995    } else {
     996        mr_free(tmp1);
     997    }
     998
    990999} else if (bkpinfo->backup_media_type == iso) {
    9911000    /* Patch by Conor Daly 23-june-2004
     
    10251034            mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    10261035            log_it("command = %s", command);
    1027             log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    1028             mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     1036            iso_mnt = call_program_and_get_last_line_of_output(command);
     1037            log_it("res of it = %s", iso_mnt);
    10291038            mr_free(command);
    10301039        } else {
     
    21742183    char *mounted_cfgf_path;
    21752184    char *tmp = NULL;
     2185    char *tmp1 = NULL;
    21762186    char *mountpt = NULL;
    21772187    char *ramdisk_fname;
     
    22902300    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    22912301        log_msg(1, "gcffa --- great! We've got the config file");
    2292         mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2302        tmp = call_program_and_get_last_line_of_output("pwd");
     2303        mr_strcat(tmp, "/%s", MONDO_CFG_FILE_STUB);
    22932304        mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
    22942305        log_it("%s",command);
     
    23002311        mr_free(command);
    23012312
    2302         mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),
    2303             MOUNTLIST_FNAME_STUB, mountlist_file);
     2313        tmp1 = call_program_and_get_last_line_of_output("pwd");
     2314        mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);
     2315        mr_free(tmp1);
     2316
    23042317        log_it("%s",command);
    23052318        if (extract_mountlist_stub) {
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2382 r2383  
    470470    log_it("Done loading config file; resizing ML");
    471471
    472     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
     472    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     473    if (strstr(tmp1, "noresize")) {
    473474        log_msg(1, "Not resizing mountlist.");
    474475    } else {
    475476        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    476477    }
     478    mr_free(tmp1);
     479
    477480    for (done = FALSE; !done;) {
    478481        log_it("About to edit mountlist");
     
    750753    int res = 0;
    751754    bool boot_loader_installed = FALSE;
    752   /** malloc **/
    753755    char *tmp = NULL;
     756    char *tmp1 = NULL;
    754757    char *flaws_str = NULL;
    755758
     
    762765    get_cfg_file_from_archive_or_bust();
    763766    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    764     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
     767
     768    tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     769    if (strstr(tmp, "noresize")) {
    765770        log_msg(2, "Not resizing mountlist.");
    766771    } else {
    767772        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    768773    }
     774    mr_free(tmp);
     775
    769776    flaws_str = evaluate_mountlist(mountlist, &res);
    770777    if (!res) {
     
    795802            twenty_seconds_til_yikes();
    796803            g_fprep = fopen("/tmp/prep.sh", "w");
    797             if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "nopart")) {
    798                 log_msg(2,
    799                         "Not partitioning drives due to 'nopart' option.");
     804            tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     805            if (strstr(tmp, "nopart")) {
     806                log_msg(2, "Not partitioning drives due to 'nopart' option.");
    800807                res = 0;
    801808            } else {
    802809                res = partition_everything(mountlist);
    803810                if (res) {
    804                     log_to_screen
    805                         ("Warning. Errors occurred during partitioning.");
     811                    log_to_screen("Warning. Errors occurred during partitioning.");
    806812                    res = 0;
    807813                }
    808814            }
     815            mr_free(tmp);
     816
    809817            retval += res;
    810818            if (!res) {
     
    867875
    868876  after_the_nuke:
     877    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
    869878    if (retval) {
    870879        log_to_screen("Errors occurred during the nuke phase.");
    871     } else if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "RESTORE")) {
    872         log_to_screen
    873             ("PC was restored successfully. Thank you for using Mondo Rescue.");
    874         log_to_screen
    875             ("Please visit our website at http://www.mondorescue.org for more information.");
     880    } else if (tmp1, "RESTORE")) {
     881        log_to_screen("PC was restored successfully. Thank you for using Mondo Rescue.");
     882        log_to_screen("Please visit our website at http://www.mondorescue.org for more information.");
    876883    } else {
    877884        mr_asprintf(tmp,"%s","Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
     
    882889        log_to_screen("Please visit our website at http://www.mondorescue.org for more information.");
    883890    }
     891    mr_free(tmp1);
     892
    884893    g_I_have_just_nuked = TRUE;
    885894    return (retval);
     
    26182627    /* Configure global variables */
    26192628    malloc_libmondo_global_strings();
    2620     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "textonly"))
    2621     {
     2629    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     2630    if (strstr(tmp1, "textonly")) {
    26222631        g_text_mode = TRUE;
    26232632        log_msg(1, "TEXTONLY MODE");
     
    26252634        g_text_mode = FALSE;
    26262635    }                           // newt :-)
     2636    mr_free(tmp1);
    26272637
    26282638    /* Init GUI */
    26292639    setup_newt_stuff();         /* call newtInit and setup screen log */
    26302640
    2631     strcpy(g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore"));
     2641    tmp1 = call_program_and_get_last_line_of_output("which mondorestore");
     2642    strcpy(g_mondo_home, tmp1);
     2643    mr_free(tmp1);
     2644
    26322645    g_current_media_number = 1; // precaution
    26332646
Note: See TracChangeset for help on using the changeset viewer.