- Timestamp:
- Nov 5, 2016, 6:12:23 PM (9 years ago)
- Location:
- branches/3.2/mondo/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-archive.c
r3581 r3610 550 550 551 551 #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/'"); 553 553 if (!bootdev[0]) { 554 554 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/'"); 556 556 } 557 557 #else 558 558 /* Linux */ 559 559 #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].*//'"); 561 561 #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].*//'"); 563 563 #endif 564 564 if (strstr(bootdev, "/dev/cciss/")) { 565 565 mr_free(bootdev); 566 566 #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"); 568 568 #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"); 570 570 #endif 571 571 } 572 572 if (!bootdev[0]) { 573 573 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].*//'"); 575 575 if (strstr(bootdev, "/dev/cciss/")) { 576 576 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"); 578 578 } 579 579 } … … 620 620 if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) { 621 621 /* 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*"); 623 623 if (strstr(tmp, "grub.c") == NULL) { 624 624 mr_free(bootldr_str); 625 625 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?"); 626 626 } 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"); 629 630 if (strcmp(bootldr_ver,"") ==0) { 630 631 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"); 632 633 } 633 634 } else if (bkpinfo->boot_loader == 'E') { … … 881 882 log_to_screen("Mindi failed to create your boot+data disks."); 882 883 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); 884 885 mr_free(command); 885 886 … … 1132 1133 /*@ buffers *********************************** */ 1133 1134 char *command = NULL; 1135 char *tmp = NULL; 1134 1136 char *tmpfile = NULL; 1135 1137 char *data_disks_file = NULL; … … 1138 1140 mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1139 1141 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); 1141 1145 strip_spaces(g_serial_string); 1142 1146 strcat(g_serial_string, "...word."); … … 1839 1843 mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname); 1840 1844 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); 1842 1846 mr_free(command); 1843 1847 … … 2580 2584 mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname); 2581 2585 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); 2583 2587 mr_free(tmp); 2584 2588 // FIXME - should be able to use last_line_of_file(), surely? … … 2764 2768 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 2765 2769 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); 2767 2771 mr_free(command); 2768 2772 log_it("res of it = %s", tmp); -
branches/3.2/mondo/src/common/libmondo-cli.c
r3583 r3610 464 464 mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 465 465 } 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); 467 467 mr_free(tmp1); 468 strncpy(bkpinfo->isodir, tmp2, MAX_STR_LEN / 4); 469 mr_free(tmp2); 468 470 469 471 log_msg(3, "proto = %s", bkpinfo->netfs_proto); … … 511 513 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 512 514 } 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); 514 518 if (strlen(bkpinfo->isodir) < 3) { 515 519 retval++; -
branches/3.2/mondo/src/common/libmondo-devices.c
r3604 r3610 135 135 bool is_this_a_ramdisk = FALSE; 136 136 137 mr_asprintf(tmp, "%s", where_is_root_mounted());137 tmp = where_is_root_mounted(); 138 138 log_msg(0, "root is mounted at %s", tmp); 139 139 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); … … 544 544 if (find_home_of_exe(cdr_exe)) { 545 545 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); 547 547 mr_free(command); 548 548 } … … 550 550 mr_free(tmp); 551 551 mr_free(cdr_exe); 552 return 1;552 return (1); 553 553 } else { 554 554 strcpy(cdrw_device, tmp); … … 754 754 } 755 755 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); 757 757 if (system(tmp) == 0) { 758 758 log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output); … … 847 847 848 848 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); 850 850 mr_free(command); 851 851 … … 883 883 } 884 884 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"); 886 886 log_msg(5, "tmp = '%s'", tmp); 887 887 if (!tmp[0]) { 888 888 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"); 890 890 } 891 891 if (tmp[0]) { … … 1153 1153 { 1154 1154 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; 1157 1158 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) { 1159 1162 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); 1162 1166 if (vndev > 10) { 1167 mr_free(tmp); 1168 mr_free(mddevice); 1169 mr_free(command); 1163 1170 return NULL; 1164 1171 } … … 1166 1173 while (system(command)); 1167 1174 } else { 1168 sprintf(command, "mdconfig -a -t vnode -f %s", fname);1175 mr_asprintf(command, "mdconfig -a -t vnode -f %s", fname); 1169 1176 mddevice = call_program_and_get_last_line_of_output(command); 1170 1177 if (!strstr(mddevice, "md")) { 1178 mr_free(tmp); 1179 mr_free(command); 1180 mr_free(mddevice); 1171 1181 return NULL; 1172 1182 } 1173 1183 } 1184 mr_free(tmp); 1185 mr_free(command); 1174 1186 sprintf(device, "/dev/%s", mddevice); 1187 mr_free(mddevice); 1175 1188 return device; 1176 1189 } … … 1189 1202 { 1190 1203 char *command = NULL; 1204 char *tmp = NULL; 1191 1205 int res = 0; 1192 1206 … … 1195 1209 } 1196 1210 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) { 1198 1213 mr_asprintf(command, "vnconfig -d %s", dname); 1199 1214 } else { 1200 1215 mr_asprintf(command, "mdconfig -d -u %s", dname); 1201 1216 } 1217 mr_free(tmp); 1202 1218 res = system(command); 1203 1219 mr_free(command); … … 1632 1648 mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l"); 1633 1649 log_msg(5, "Running: %s", command); 1634 m r_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); 1635 1651 mr_free(command); 1636 1652 … … 1642 1658 mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i); 1643 1659 log_msg(5, "Running: %s", command); 1644 m r_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); 1645 1661 mr_free(command); 1646 1662 … … 1722 1738 mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf); 1723 1739 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); 1725 1741 mr_free(command); 1726 1742 … … 1748 1764 mr_asprintf(command, "mr-parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf); 1749 1765 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); 1751 1767 mr_free(command); 1752 1768 log_msg(4, "Partition list for %s: %s", dsf, partition_list); … … 1814 1830 mr_asprintf(command, "mr-parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", ndsf, partitions[i]); 1815 1831 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); 1817 1833 mr_free(command); 1818 1834 … … 1828 1844 /* It's not swap. See if we can find the mount point from the mount command. */ 1829 1845 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); 1831 1847 mr_free(command); 1832 1848 … … 1850 1866 mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]); 1851 1867 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); 1853 1869 mr_free(command); 1854 1870 … … 1858 1874 mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]); 1859 1875 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); 1861 1877 mr_free(command); 1862 1878 … … 1867 1883 mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG); 1868 1884 log_msg(5, " Running: %s", command); 1869 m r_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); 1870 1886 mr_free(command); 1871 1887 … … 1891 1907 mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 1892 1908 log_msg (5, "Running: %s", command); 1893 m r_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); 1894 1910 mr_free(command); 1895 1911 log_msg(4, " Software raid device list: %s", mount_list); … … 1899 1915 log_msg (5, "Running: %s", command); 1900 1916 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); 1902 1918 mr_free(command); 1903 1919 log_msg(4, "Number of Software raid device: %s", tmp); … … 1934 1950 mr_asprintf(command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]); 1935 1951 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); 1937 1953 mr_free(command); 1938 1954 … … 1947 1963 mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 1948 1964 log_msg (5, " Running: %s", command); 1949 m r_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); 1950 1966 mr_free(command); 1951 1967 … … 1957 1973 log_msg(4, " Running: %s", command); 1958 1974 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); 1960 1976 mr_free(command); 1961 1977 … … 2196 2212 */ 2197 2213 #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"); 2199 2215 #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"); 2201 2217 #endif 2202 2218 … … 2432 2448 /* Initiate bkpinfo netfs_mount path from running environment if not already done */ 2433 2449 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"); 2435 2451 } 2436 2452 #ifdef __FreeBSD__ … … 2472 2488 } 2473 2489 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); 2475 2493 mr_free(command); 2476 2494 … … 2535 2553 /* Initiate bkpinfo isodir path from running environment if mount already done */ 2536 2554 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); 2538 2558 } else { 2539 2559 // Why netfsdir ? … … 2641 2661 mr_free(bkpinfo->boot_device); 2642 2662 #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/'"); 2644 2664 #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].*//'"); 2646 2666 #endif 2647 2667 i = which_boot_loader(bkpinfo->boot_device); … … 2706 2726 mr_free(tmp); 2707 2727 // 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); 2709 2731 if (strlen(tmp1) > 2) { 2710 2732 if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1, MAX_STR_LEN / 4)) { … … 2884 2906 * Get a |-separated list of NETFS mounts. 2885 2907 * @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 2887 2910 * @bug Even though we only want the mounts, the devices are still checked. 2888 2911 */ … … 2891 2914 char *exclude_these_directories = NULL; 2892 2915 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;}'"); 2894 2917 log_msg(9,"list_of_NETFS_mounts_only returns %s",exclude_these_directories); 2895 2918 return(exclude_these_directories); … … 2988 3011 // log_it("Asking what_number_cd_is_this"); 2989 3012 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); 2993 3016 cd_number = atoi(last_line_of_file(mountdev)); 2994 paranoid_free(mountdev); 2995 paranoid_free(tmp); 3017 mr_free(mountdev); 2996 3018 2997 3019 return (cd_number); … … 3011 3033 } 3012 3034 } 3013 paranoid_free(mountdev);3035 mr_free(mountdev); 3014 3036 3015 3037 cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER")); … … 3021 3043 * Find out what device is mounted as root (/). 3022 3044 * @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 3024 3047 * @bug A bit of a misnomer; it's actually finding out the root device. 3025 3048 * The mountpoint (where it's mounted) will obviously be '/'. … … 3028 3051 3029 3052 /*@ buffers **************** */ 3030 static char tmp[MAX_STR_LEN]; 3031 3053 char *tmp = NULL; 3032 3054 3033 3055 #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"); 3035 3057 #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]//"); 3037 3059 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"); 3039 3062 } 3040 3063 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"); 3042 3066 } 3043 3067 #endif … … 3131 3155 assert(which_device != NULL); 3132 3156 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); 3134 3159 log_it("list_drives_cmd = %s", list_drives_cmd); 3135 3160 mr_free(tmp); 3136 3161 if (!(pdrives = popen(list_drives_cmd, "r"))) { 3137 3162 log_OS_error("Unable to open list of drives"); … … 3276 3301 log_msg(1, "curr_fname = %s", curr_fname); 3277 3302 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); 3279 3304 mr_free(command); 3280 3305 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; … … 3318 3343 char *output = NULL; 3319 3344 char *command = NULL; 3345 3320 3346 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); 3322 3348 mr_free(command); 3323 3349 -
branches/3.2/mondo/src/common/libmondo-fifo.c
r3191 r3610 165 165 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); 166 166 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); 168 168 mr_free(command); 169 169 -
branches/3.2/mondo/src/common/libmondo-filelist.c
r3381 r3610 861 861 mr_asprintf(tmp1, "zcat %s | wc -l", filelist_fname); 862 862 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); 864 866 mr_free(tmp1); 865 867 … … 1302 1304 char *new = NULL; 1303 1305 char *tmp = NULL; 1306 char *tmp2 = NULL; 1304 1307 char *dir = NULL; 1305 1308 static int percentage = 0; … … 1358 1361 1359 1362 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); 1361 1366 mr_free(tmp); 1362 1367 … … 1523 1528 } 1524 1529 make_hole_for_file(sz_datefile); 1525 write_one_liner_data_file(sz_datefile,1526 call_program_and_get_last_line_of_output1527 ("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); 1528 1533 } else if (lstat(sz_datefile, &statbuf)) { 1529 1534 log_msg(2, "Warning - unable to find date of previous backup. Full backup instead."); … … 1550 1555 } 1551 1556 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}'"); 1553 1558 if (strlen(tmp2) < 1) { 1554 1559 mr_asprintf(tmp1," "); … … 1557 1562 mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2); 1558 1563 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); 1560 1565 log_msg(2, "Found windows files: %s",tmp2); 1561 1566 } -
branches/3.2/mondo/src/common/libmondo-files-EXT.h
r3191 r3610 32 32 extern long size_of_all_biggiefiles_K(); 33 33 extern void copy_mondo_and_mindi_stuff_to_scratchdir(); 34 extern void store_netfs_config();35 36 34 37 35 extern void estimate_noof_media_required(long); -
branches/3.2/mondo/src/common/libmondo-files.c
r3430 r3610 276 276 277 277 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); 279 281 } 280 282 // If we didn't get anything back, check whether mindi raised a fatal error 281 283 if (!kernel[0]) { 282 284 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); 284 286 if (strlen(tmp) > 1) { 285 287 popup_and_OK(tmp); … … 334 336 assert_string_is_neither_NULL_nor_zerolength(fname); 335 337 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); 337 339 mr_free(command); 338 340 … … 346 348 mr_free(incoming); 347 349 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); 349 351 mr_free(command); 350 352 } … … 353 355 mr_free(incoming); 354 356 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); 356 359 mr_free(command); 357 360 } … … 435 438 if (i < 0) { 436 439 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); 438 441 mr_free(command); 439 442 if (!lastline[0]) { … … 730 733 731 734 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); 733 736 file_len_K = atol(sz_res); 734 737 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K); … … 786 789 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 787 790 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); 789 792 mr_free(command); 790 793 … … 1059 1062 mr_free(command); 1060 1063 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"); 1062 1065 if (!tmp[0]) { 1063 1066 mr_free(tmp); … … 1089 1092 1090 1093 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_mount1099 * - @c tmpdir1100 */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 the1112 * 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 aft1115 * look for the corresponding slave ethN device and copy it to netfs_dev.1116 * Using the common MAC address1117 ********/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");1127 1094 } 1128 1095 -
branches/3.2/mondo/src/common/libmondo-files.h
r3191 r3610 31 31 32 32 void copy_mondo_and_mindi_stuff_to_scratchdir(); 33 void store_netfs_config();34 33 void estimate_noof_media_required(long); 35 34 bool is_this_file_compressed(char *); -
branches/3.2/mondo/src/common/libmondo-fork.c
r3604 r3610 35 35 * @param call The program to run. 36 36 * @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 38 39 */ 39 40 char *call_program_and_get_last_line_of_output(char *call) 40 41 { 41 42 /*@ buffers ***************************************************** */ 42 static char result[MAX_STR_LEN];43 char *result = NULL; 43 44 char *tmp = NULL; 44 45 … … 46 47 FILE *fin = NULL; 47 48 char *eng_call = NULL; 48 49 /*@ initialize data ********************************************* */50 result[0] = '\0';51 49 52 50 /*@******************************************************************** */ … … 57 55 if ((fin = popen(eng_call, "r"))) { 58 56 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) { 62 60 log_msg(7, "result = '%s'", result); 63 61 } 64 mr_free(tmp);65 62 } 66 63 paranoid_pclose(fin); … … 69 66 } 70 67 mr_free(eng_call); 71 strip_spaces(result);68 mr_strip_spaces(result); 72 69 log_msg(5, "cpaglloo returns '%s'", result); 73 70 return(result); -
branches/3.2/mondo/src/common/libmondo-raid.c
r3566 r3610 1007 1007 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID"); 1008 1008 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); 1010 1010 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1011 1011 mr_free(strtmp); … … 1014 1014 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version"); 1015 1015 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); 1017 1017 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1018 1018 mr_free(strtmp); -
branches/3.2/mondo/src/common/libmondo-stream.c
r3527 r3610 256 256 int find_tape_device_and_size(char *dev, char *siz) 257 257 { 258 char tmp[MAX_STR_LEN];258 char *tmp = NULL; 259 259 char *command = NULL; 260 260 char *cdr_exe = NULL; … … 269 269 } 270 270 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); 272 272 mr_free(command); 273 273 … … 282 282 283 283 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); 285 285 mr_free(command); 286 286 … … 294 294 mr_free(cdr_exe); 295 295 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); 297 297 mr_free(command); 298 298 … … 326 326 } 327 327 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;};};};'"); 329 329 330 330 if (mt_says_tape_exists(dev)) { -
branches/3.2/mondo/src/common/libmondo-tools.c
r3539 r3610 230 230 d = 5.2; // :-) 231 231 #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"); 233 233 p = strchr(tmp, '.'); 234 234 if (p) { … … 452 452 if (getenv ("SUDO_COMMAND")) { 453 453 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); 456 458 popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 457 459 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 458 460 } 459 mr_free( command);461 mr_free(tmp); 460 462 } 461 463 log_msg(2, "call_make_iso (DVD res) is ... %s", bkpinfo->call_make_iso); … … 550 552 mr_asprintf(command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir); 551 553 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); 553 555 log_it("res of it = %s", iso_dev); 554 556 mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir); … … 561 563 562 564 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); 564 566 log_it("res of it = %s", iso_mnt); 565 567 mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir); … … 882 884 883 885 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); 885 887 mr_free(command); 886 888 … … 923 925 run_program_and_log_output("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE); 924 926 } 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"); 926 928 if (atol(tmp) < 35000) { 927 929 retval++; … … 986 988 } 987 989 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)\""); 989 991 if (strcmp("", tmp)) { 990 992 if (strstr(tmp, "autofs")) { … … 1050 1052 /*@ buffer ****************************************************** */ 1051 1053 char *command = NULL; 1054 char *tmp = NULL; 1052 1055 1053 1056 /*@ end vars *************************************************** */ … … 1064 1067 } else { 1065 1068 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); 1067 1071 mr_free(command); 1068 1072 … … 1193 1197 mr_asprintf(command, "%s", "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[ ]/boot[ ]\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1194 1198 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); 1196 1200 mr_free(command); 1197 1201 … … 1201 1205 mr_free(tmp); 1202 1206 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); 1204 1208 mr_free(command); 1205 1209 … … 1398 1402 void stop_magicdev_if_necessary() 1399 1403 { 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); 1401 1408 if (g_magicdev_command[0]) { 1402 1409 log_msg(1, "g_magicdev_command = '%s'", g_magicdev_command); 1403 1410 paranoid_system("killall magicdev"); 1404 1411 } 1412 mr_free(tmp); 1405 1413 } 1406 1414 -
branches/3.2/mondo/src/mondorestore/mondo-prep.c
r3570 r3610 154 154 char *tmp; 155 155 char *tmp1 = NULL; 156 char *tmp2 = NULL; 156 157 char *incoming; 157 158 char *command; … … 186 187 #endif 187 188 188 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "nolvm")) { 189 tmp = call_program_and_get_last_line_of_output("cat "CMDLINE); 190 if (strstr(tmp, "nolvm")) { 191 mr_free(tmp); 189 192 return(0); 190 193 } 194 mr_free(tmp); 195 191 196 if (!(fin = fopen("/tmp/i-want-my-lvm", "r"))) { 192 197 log_OS_error("/tmp/i-want-my-lvm"); … … 299 304 if (lvmversion == 2) { 300 305 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);303 306 } else { 304 307 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);307 308 } 309 tmp2 = call_program_and_get_last_line_of_output(tmp1); 310 strcpy(tmp, tmp2); 311 mr_free(tmp2); 312 mr_free(tmp1); 313 308 314 for (p = tmp; *p != '\0' && !isdigit(*p); p++); 309 315 extents = atol(p); … … 1482 1488 // mark relevant partition as bootable 1483 1489 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); 1485 1491 mr_free(tmp1); 1492 mr_free(tmp); 1486 1493 1487 1494 log_msg(0,"------------------- end of fdisk.log... ------------------"); -
branches/3.2/mondo/src/mondorestore/mondo-rstr-tools.c
r3601 r3610 695 695 strcpy(bkpinfo->prefix,STD_PREFIX); 696 696 } 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")) { 698 699 /* We need to override prefix value in PXE mode as it's 699 700 * already done in start-netfs */ … … 704 705 strcpy(bkpinfo->prefix,envtmp1); 705 706 } 707 mr_free(tmp1); 706 708 } else if (!strcmp(value, "tape")) { 707 709 bkpinfo->backup_media_type = tape; … … 832 834 833 835 read_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")) { 836 tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE); 837 if (value[0] || strstr(tmp1, "donteject")) { 835 838 bkpinfo->please_dont_eject = TRUE; 836 839 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 837 840 } 841 mr_free(tmp1); 838 842 839 843 /* TODO: Read here the boot_* variables */ … … 881 885 } 882 886 } 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")) { 884 889 /* We need to override values in PXE mode as it's 885 890 * already done in start-netfs */ … … 898 903 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2); 899 904 } 905 mr_free(tmp1); 900 906 } else if (bkpinfo->backup_media_type == iso) { 901 907 /* Patch by Conor Daly 23-june-2004 … … 932 938 mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device); 933 939 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); 936 943 mr_free(command); 944 mr_free(tmp1); 937 945 } else { 938 946 sprintf(iso_mnt, "/tmp/isodir"); … … 2064 2072 char *cfg_file = NULL; 2065 2073 char *tmp = NULL; 2074 char *tmp1 = NULL; 2066 2075 char *mountpt = NULL; 2067 2076 char *mountlist_file = NULL; … … 2177 2186 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2178 2187 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); 2180 2190 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file); 2181 2191 log_it("%s",command); … … 2189 2199 mr_free(command); 2190 2200 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); 2192 2203 log_it("%s",command); 2193 2204 if (extract_mountlist_stub) { -
branches/3.2/mondo/src/mondorestore/mondorestore.c
r3564 r3610 1876 1876 log_it("Done loading config file; resizing ML"); 1877 1877 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); 1879 1879 if (strstr(tmp1, "noresize")) { 1880 1880 log_msg(1, "Not resizing mountlist."); … … 2102 2102 get_cfg_file_from_archive_or_bust(); 2103 2103 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")) { 2110 2106 log_msg(2, "Not resizing mountlist."); 2111 2107 } else { 2112 2108 resize_mountlist_proportionately_to_suit_new_drives(mountlist); 2113 2109 } 2110 mr_free(tmp); 2111 2114 2112 flaws_str = evaluate_mountlist(mountlist); 2115 2113 if (flaws_str != NULL) { … … 2138 2136 twenty_seconds_til_yikes(); 2139 2137 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); 2141 2139 if (strstr(tmp1, "nopart")) { 2142 2140 log_msg(2, "Not partitioning drives due to 'nopart' option."); … … 2204 2202 2205 2203 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); 2207 2205 if (retval) { 2208 2206 log_to_screen("Errors occurred during the nuke phase."); … … 2595 2593 2596 2594 /* 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")) { 2607 2597 g_text_mode = TRUE; 2608 2598 log_msg(1, "TEXTONLY MODE"); … … 2610 2600 g_text_mode = FALSE; 2611 2601 } // newt :-) 2602 mr_free(tmp); 2603 2612 2604 if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) { 2613 2605 fatal_error("Cannot malloc mountlist"); … … 2622 2614 malloc_libmondo_global_strings(); 2623 2615 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 2626 2620 g_current_media_number = 1; // precaution 2627 2628 2621 run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE); 2629 2622
Note:
See TracChangeset
for help on using the changeset viewer.