/usr/bin/secpanel is in secpanel 1:0.6.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 | #!/bin/sh
# -*- tcl -*-
# Executing wish #\
exec /usr/bin/wish8.5 "$0" "$@"
#######################################################################
#
# secpanel - Graphical user interface for managing SSH- and
# SFTP-connections
#
# Author: Steffen Leich <steffen.leich _at_ gmail.com>
# http://secpanel.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#######################################################################
set spversion 0.6.0
set libdir "[file dirname [info script]]/../share/secpanel"
# set libdir "$env(HOME)/secpanel_devel/secpanel-0x/lib"
set sshdir "$env(HOME)/.ssh"
global actdirsel;
global questres;
global userres;
proc init {argc argv} {
global env configs tk_version launcher defident libdir agent wins platform
if {! [info exists env(DISPLAY)] || $env(DISPLAY) == ""} {
catch {exec "uname -a"} ver
if {! [regexp -nocase "macintosh" $ver]} {
puts "No valid Xwindow DISPLAY environment or MacOSX platform -> exiting secpanel"
exit
} else {
set platform "macosx"
}
} else {
set platform "linux"
}
set mintcl 8.0
set mintk 8.0
if {[info tclversion]<$mintcl || $tk_version<$mintk} {
puts -nonewline stderr "For running secpanel:\nTcl $mintcl/Tk $mintk minimum versions required. "
puts stderr "You have Tcl [info tclversion]/Tk $tk_version"
exit 1
}
set secpaneldir "$env(HOME)/.secpanel"
if {! [file exists $secpaneldir]} {
file mkdir $secpaneldir
exec chmod 700 $secpaneldir
puts "Created config-dir $secpaneldir (chmod 700)..."
}
if [file exists $secpaneldir/spdata.lck] {
puts "Found protected secpanel data"
# exec $libdir/protect.sh $libdir
exec $libdir/dppw.tcl "de"
}
if {! [file exists $secpaneldir/.runfiles]} {
file mkdir $secpaneldir/.runfiles
}
if {! [file exists $secpaneldir/profiles]} {
file mkdir $secpaneldir/profiles
}
set configfile "$env(HOME)/.secpanel/config"
if {! [file exists $configfile]} {
file copy "$libdir/default.config" "$configfile"
}
source $configfile
initconfigs
array set gshorts {fore foreground back background}
foreach gcolval [array names gshorts] {
if [info exists configs($gcolval)] {
option add *$gshorts($gcolval) $configs($gcolval)
}
}
array set shorts {entfore Entry.foreground entback Entry.background \
listfore Listbox.foreground listback Listbox.background}
foreach colval [array names shorts] {
if [info exists configs($colval)] {
option add *$shorts($colval) $configs($colval)
if {$colval == "listfore"} {
option add *Text.foreground $configs($colval)
}
if {$colval == "listback"} {
option add *Text.background $configs($colval)
}
}
}
set fb ""
set fi ""
if {([info exists configs(sysfonts)] && ($configs(sysfonts) != 1)) || ! [info exists configs(sysfonts)]} {
if [info exists configs(fontbold)] {
if $configs(fontbold) {
set fb "bold"
}
}
if [info exists configs(fontitalic)] {
if $configs(fontitalic) {
set fi "italic"
}
}
if {[info exists configs(fontfam)] && [info exists configs(fontsize)]} {
option add *Font "\"$configs(fontfam)\" $configs(fontsize) $fb $fi"
}
}
set agent 0
}
proc initconfigs {} {
global configs
foreach {bintag binprog} \
{sshbin ssh keygenbin ssh-keygen agentbin ssh-agent \
addbin ssh-add askpassbin ssh-askpass scpbin scp sftpbin Filezilla termver Xterminal-emulator browserbin firefox \
} {
if {! [info exists configs($bintag)]} {
set configs($bintag) $binprog
}
}
if {! [info exists configs(sshver)]} {
set configs(sshver) "OpenSSH"
}
if {! [info exists configs(termver)]} {
set configs(termver) "Xterminal-emulator"
}
if {! [info exists configs(protectdata)]} {
set configs(protectdata) 0
}
}
init $argc $argv
proc browsebin {which} {
global widget
choosefile $widget([set which]ent) "actdirsel" "Open" ""
}
proc manage_remote {mode} {
global widget rfts configs libdir env termtype ramhost ramport ramuser
set usetermver $configs(termver)
set icontag ""
set configs(xtermbin) $termtype([set usetermver]_path)
set titlepar $termtype([set usetermver]_titlepar)
set quotepar $termtype([set usetermver]_quotepar)
set execpar $termtype([set usetermver]_execpar)
if {[info exists termicon] && $termicon} {
set icontag $termtype([set usetermver]_iconpar)
}
# </xterm selection and params>
switch -regexp $mode {
init {
if {[selection own] == $widget(specsites)} {
set actentry [$widget(specsites) get active]
set rmprof [retprof $actentry]
source "$env(HOME)/.secpanel/profiles/$rmprof.profile"
set ramhost $host
set ramport $port
set ramuser $user
} else {
showmessage "No entry selected" ""
return
}
if {[winfo exists .top40]} {
if [showconfirm\
"There is another remote management session. Cancel this former session?"\
.top40] {
manage_remote cancel
} else {
return
}
}
set rfts [clock clicks]
Window show .top40
.top40.lab51 config -text "Remote Account Manager for $title ($ramuser@$ramhost)"
set connstring "$libdir/secpanel_remoteconf.sh $ramhost $ramport $ramuser $configs(scpbin) read $rfts"
set runstring "exec $configs(xtermbin) $execpar $quotepar <CONNFILE> $quotepar"
provrunfile term nobg $connstring $runstring
set shostsfile "$env(HOME)/.secpanel/.runfiles/ram.$rfts/.shosts"
set keysfile "$env(HOME)/.secpanel/.runfiles/ram.$rfts/authorized_keys"
if {[file exists $shostsfile]} {
$widget(remoteshostsfile) insert end [exec cat $shostsfile]
}
if {[file exists $keysfile]} {
$widget(remotekeysfile) insert end [exec cat $keysfile]
}
$widget(remotercfile) insert end "Not yet supported, breaks scp..."
}
cancel {
file delete -force "$env(HOME)/.secpanel/.runfiles/ram.$rfts"
unset rfts
Window destroy .top40
}
write {
if [showconfirm "Really write back remote configuration?" ".top40"] {
set shostsfile [open "$env(HOME)/.secpanel/.runfiles/ram.$rfts/.shosts" w]
puts -nonewline $shostsfile [$widget(remoteshostsfile) get 1.0 end]
close $shostsfile
set keysfile [open "$env(HOME)/.secpanel/.runfiles/ram.$rfts/authorized_keys" w]
puts -nonewline $keysfile [$widget(remotekeysfile) get 1.0 end]
close $keysfile
set connstring "$libdir/secpanel_remoteconf.sh $ramhost $ramport $ramuser $configs(scpbin) write $rfts"
set runstring "exec $configs(xtermbin) $execpar $quotepar <CONNFILE> $quotepar"
provrunfile term bg $connstring $runstring
Window destroy .top40
}
}
}
}
proc save_globals {mode} {
global widget env configs launcher defident wins
set conffile [open "$env(HOME)/.secpanel/config" w]
switch -regexp $mode {
bins {
array set bindefs { \
ssh ssh keygen ssh-keygen agent ssh-agent add ssh-add \
askpass ssh-askpass scp scp browser firefox }
foreach f {ssh keygen agent add askpass scp browser} {
if {[$widget([set f]ent) get] == ""} {
$widget([set f]ent) insert 0 $bindefs($f)
}
puts $conffile "set configs([set f]bin) \"[$widget([set f]ent) get]\""
set configs([set f]bin) [$widget([set f]ent) get]
}
puts $conffile "set configs(sshver) \"$configs(sshver)\""
puts $conffile "set configs(termver) \"$configs(termver)\""
puts $conffile "set configs(sftpbin) \"$configs(sftpbin)\""
if [info exists defident] {
puts $conffile "set defident \"$defident\""
}
puts $conffile "set launcher $launcher"
}
"geom|startsat|color|fonts|scp|agent|chdef|protectdata" {
foreach f {ssh keygen agent add askpass scp browser} {
puts $conffile "set configs([set f]bin) \"$configs([set f]bin)\""
}
puts $conffile "set configs(sshver) \"$configs(sshver)\""
puts $conffile "set configs(termver) \"$configs(termver)\""
puts $conffile "set configs(sftpbin) \"$configs(sftpbin)\""
puts $conffile "set launcher $launcher"
if [info exists defident] {
puts $conffile "set defident \"$defident\""
}
}
}
foreach col {fore back entfore entback listfore listback} {
if [info exists configs($col)] {
puts $conffile "set configs($col) $configs($col)"
}
}
foreach font {fontfam fontsize fontbold fontitalic sysfonts} {
if [info exists configs($font)] {
puts $conffile "set configs($font) \"$configs($font)\""
}
}
if [info exists configs(wingeom)] {
puts $conffile "set configs(wingeom) \"$configs(wingeom)\""
}
if [info exists configs(protectdata)] {
puts $conffile "set configs(protectdata) \"$configs(protectdata)\""
}
foreach w [array names wins] {
puts $conffile "set wins($w) \"$wins($w)\""
}
if [info exists configs(startsat)] {
puts $conffile "set configs(startsat) \"$configs(startsat)\""
}
close $conffile
showstatus "Global configs saved"
}
proc chbutton {var but} {
global fgdef bgdef
if {[set $var]} {
$but config -state disabled
} else {
$but config -state normal
}
}
proc chcol {var button title} {
set ret [colorchoose ".top17" $title]
if {$ret != ""} {
$button config -background $ret
}
}
proc colorchoose {parent title} {
set col [tk_chooseColor -parent $parent -title "secpanel - $title"]
return $col
}
proc fontman {mode} {
global configs
set names .top23.fra36.cpd37.01
set sizes .top23.fra36.cpd38.01
switch -exact $mode {
show {
Window show .top23
set names .top23.fra36.cpd37.01
set sizes .top23.fra36.cpd38.01
foreach f [lsort [font families]] {
$names insert end $f
}
set fs 6
while {$fs <= 60} {
$sizes insert end $fs
incr fs
}
if $configs(fontbold) {
set fb "bold"
} else {
set fb ""
}
if $configs(fontitalic) {
set fi "italic"
} else {
set fi ""
}
if {! $configs(sysfonts)} {
if {[info exists configs(fontfam)] && [info exists configs(fontsize)]} {
set label "$configs(fontfam) $configs(fontsize)"
.top23.lab30 config \
-font "\"$configs(fontfam)\" $configs(fontsize) $fi $fb"
} else {
set label ""
}
.top23.lab30 config -text "$label"
} else {
.top23.lab30 config -text "Using external sysfonts"
}
set fc 0
if [info exists configs(fontfam)] {
foreach fn [$names get 0 end] {
if {$fn =="$configs(fontfam)"} {
$names activate $fc
$names see $fc
}
incr fc
}
}
set sc 0
if [info exists configs(fontsize)] {
foreach fs [$sizes get 0 end] {
if {$fs =="$configs(fontsize)"} {
$sizes activate $sc
$sizes see $sc
}
incr sc
}
}
# activate listenelement in fontfam und size mit richtigen Werten
# font-ex.text mit eingestellten werten
}
save {
set configs(fontfam) [$names get active]
set configs(fontsize) [$sizes get active]
save_globals fonts
Window destroy .top23
}
ul {
if {! $configs(sysfonts)} {
set name [$names get active]
set size [$sizes get active]
if $configs(fontbold) {
set fb "bold"
} else {
set fb ""
}
if $configs(fontitalic) {
set fi "italic"
} else {
set fi ""
}
.top23.lab30 config -text "[$names get active] [$sizes get active]" -font "\"$name\" $size $fi $fb"
} else {
.top23.lab30 config -text "Using external sysfonts"
}
}
}
}
proc colorman {mode} {
global env configs \
foredef backdef entforedef entbackdef listforedef listbackdef
foreach {name widg} {fore 37 back 38 entfore 39 \
entback 40 listfore 41 listback 42} {
set colbut[set name] ".top32.fra33.but[set widg]"
}
set colvals [list fore back entfore entback listfore listback];
switch -exact $mode {
1 {
Window show .top32
foreach colval $colvals {
if [info exists configs($colval)] {
[set colbut[set colval]] configure -background $configs($colval)
} else {
set [set colval]def 1
}
}
}
save {
foreach colval $colvals {
if {! [set [set colval]def]} {
set configs([set colval]) [[set colbut[set colval]] cget -background]
} else {
if [info exists configs([set colval])] {
unset configs([set colval])
}
}
}
Window destroy .top32
save_globals color
}
default {
set col [colorchoose .top32 "Foreground Color"]
if {$col != ""} {
[set colbut[set mode]] config \
-background $col -activebackground $col
return
} else {
return
}
}
}
}
proc showmenu {} {
if [winfo exists .pm1] {
Window destroy .pm1
}
if [winfo exists .pm2] {
Window destroy .pm2
}
menu .pm1 -tearoff 0 -borderwidth 1
.pm1 add command -label "Connect" -command "connect"
.pm1 add command -label "Edit" -command "propconn specsites"
.pm1 add command -label "Delete" -command "delconn"
.pm1 add command -label "Show info" -state "disabled"
.pm1 add command -label "Manage remote account" -command "manage_remote init"
.pm1 add cascade -label "Export as..." -menu .pm1.pm2
.pm1 add separator
.pm1 add command -label "New connection" -command "newconn 1"
menu .pm1.pm2 -tearoff 0 -borderwidth 1
.pm1.pm2 add command -label "Shellscript" -command "export sh" -state "disabled"
.pm1.pm2 add command -label "SSH configfile" -command "export ssh" -state "disabled"
.pm1.pm2 add command -label "GNOME icon" -command "export gnome" -state "disabled"
.pm1.pm2 add command -label "KDE icon" -command "export kde" -state "disabled"
tk_popup .pm1 [winfo pointerx .top17] [winfo pointery .top17]
}
proc historyman {mode "categ {}" "text {}"} {
global env histjob configs wins
switch -exact $mode {
write {
set hf [open "$env(HOME)/.secpanel/history" a]
puts $hf "$categ#[clock seconds]#$text"
close $hf
if [winfo exists .top26] {
historyman print
}
}
show {
Window show .top26
if {[info exists configs(wingeom)] && $configs(wingeom)} {
if [info exists wins(hist)] {
wm geometry ".top26" $wins(hist)
}
}
set histjob 1
historyman print
}
report {
set repdir "$env(HOME)/.secpanel/reports"
if {! [file exists "$repdir"]} {
file mkdir "$repdir"
}
set index [open "$repdir/index.html" w]
puts $index "<!-- generated by secpanel [exec date]-->\n<frameset border=0 frameborder=\"no\" rows=\"10%,90%\">\n<frame src=\"header.html\" name=\"header\">\n<frameset border=0 frameborder=\"no\" cols=\"20%,80%\">\n<frame src=\"panel.html\" name=\"panel\">\n<frame src=\"1.html\" name=\"content\">\n</frameset></frameset>"
close $index
set header [open "$repdir/header.html" w]
puts $header "<font size=\"+2\">Report of Secure Shell actions</font><br>Generated by secpanel [exec date]"
close $header
set panel [open "$repdir/panel.html" w]
puts $panel "<b>Actions</b>\n<HR>\n<a target=\"content\" href=\"1.html\">SSH connect</a><br>\n<a target=\"content\" href=\"2.html\">SFTP connect</a><br>\n<a target=\"content\" href=\"4.html\">Keygen</a><br>\n<a target=\"content\" href=\"5.html\">Keydist</a><br>\n<a target=\"content\" href=\"6.html\">Agent</a><HR>"
close $panel
if {! [file exists "$env(HOME)/.secpanel/history"]} {
showmessage "No history available" .top26
return
}
foreach m {1 2 4 5 6} {
set modef[set m] [open "$repdir/[set m].html" w]
puts [set modef[set m]] "<table border=0 width=\"80%\">\n"
}
set hf [open "$env(HOME)/.secpanel/history" r]
while {[gets $hf line] >= 0} {
set elems [split $line "#"]
set actmode [set modef[lindex $elems 0]]
puts $actmode "<tr><td>[clock format [lindex $elems 1]]<hr noshade></td><td>[lindex $elems 2]<hr noshade></td></tr>\n"
}
foreach m2 {1 2 4 5 6} {
puts [set modef[set m2]] "</table>\n"
close [set modef[set m2]]
}
showmessage "Report for actual history generated in ~/.secpanel/reports/index.html" .top26
exec $configs(browserbin) "file:$env(HOME)/.secpanel/reports/index.html" &
}
print {
set text .top26.cpd27.03
$text delete 1.0 end
if {! [file exists "$env(HOME)/.secpanel/history"]} {
return
}
set hf [open "$env(HOME)/.secpanel/history" r]
while {[gets $hf line] >= 0} {
set elems [split $line "#"]
if {[lindex $elems 0] == $histjob} {
$text insert end "[clock format [lindex $elems 1]] - [lindex $elems 2]\n"
}
}
$text see end
close $hf
}
clear {
if [showconfirm "Really clear the history?\n(Keeping $categ days)" ".top26"] {
if {$categ != "0"} {
set hfile "$env(HOME)/.secpanel/history"
if {! [file exists $hfile]} {
showmessage "No history available" .top26
return
}
set now [clock seconds]
set hf [open "$hfile" r]
while {[gets $hf line] >= 0} {
set elems [split $line "#"]
if {[lindex $elems 1] >= [expr $now - ($categ * 24 * 60 * 60)]} {
lappend kept $line
}
}
close $hf
set hf [open "$hfile" w]
foreach l $kept {
puts $hf $l
}
close $hf
} else {
file delete "$env(HOME)/.secpanel/history"
}
historyman print
} else {
return
}
}
}
}
proc showcomm {mode} {
global widget lfstemp rfstemp
set actline [$widget([set mode]forwards) get active]
if [regsub { -> } $actline : out] {
$widget([set mode]fcomment) config -text [set [set mode]fstemp($out)]
}
}
proc add_forw {mode} {
global widget lfstemp rfstemp
set fhost [$widget([set mode]fhost) get]
set fin [$widget([set mode]fin) get]
set fout [$widget([set mode]fout) get]
set fcomment [$widget([set mode]fcommentent) get]
set lhostname "<TARGET-HOST>"
set rhostname "<LOCAL-HOST>"
if {$fhost == ""} {
set fht [set [set mode]hostname]
} else {
set fht $fhost
}
if {$fin != "" && $fout != ""} {
$widget([set mode]fcomment) config -text ""
foreach an [array names [set mode]fstemp] {
if {$an == "$fin:$fht:$fout"} {
$widget([set mode]fcomment) config -text "Forward exists"
return
}
}
$widget([set mode]forwards) insert end "$fin -> $fht:$fout"
set [set mode]fstemp($fin:$fht:$fout) $fcomment
$widget([set mode]fin) delete 0 end
$widget([set mode]fout) delete 0 end
$widget([set mode]fhost) delete 0 end
$widget([set mode]fcommentent) delete 0 end
focus $widget([set mode]fin)
$widget([set mode]forwards) see end
}
}
proc del_forw {mode} {
global widget lfstemp rfstemp
set lwin .top43
set rwin .top51
if {[selection own] == $widget([set mode]forwards)} {
set actline [$widget([set mode]forwards) get active]
if [regsub { -> } $actline : out] {
unset [set mode]fstemp($out)
$widget([set mode]forwards) delete active
}
} else {
showmessage "No forwarding selected" [set [set mode]win]
}
selection clear
}
proc save_forwards {mode} {
global widget rfs rfstemp lfs lfstemp
set lwin .top43
set rwin .top51
if [info exists [set mode]fs] {
unset [set mode]fs
}
array set [set mode]fs [array get [set mode]fstemp]
if [info exists [set mode]fstemp] {
unset [set mode]fstemp
}
Window destroy [set [set mode]win]
}
proc open_forwardings {mode} {
global widget lfs rfs lfstemp rfstemp
set lwin .top43
set rwin .top51
Window show [set [set mode]win]
$widget([set mode]forwards) delete 0 end
if [info exists [set mode]fstemp] {
unset [set mode]fstemp
}
if [info exists [set mode]fs] {
array set [set mode]fstemp [array get [set mode]fs]
}
foreach fe [array names [set mode]fstemp] {
if [regsub : $fe { -> } out] {
$widget([set mode]forwards) insert end $out
}
}
}
proc changetab {mode} {
global libdir agent widget wins configs
switch -exact $mode {
"small" {
if {! [$widget(specsites) index end] > 0} {
showmessage "No conncections available, please add one..." ""
return
}
wm withdraw .top17
Window show .top27
if {[info exists configs(wingeom)] && $configs(wingeom)} {
if [info exists wins(sat)] {
wm geometry ".top27" $wins(sat)
}
}
.top27.but27 config -image [image create photo -file "$libdir/images/swinback_gr.gif"]
if {$agent == 1 || $agent == "ext"} {
.top27.but27 config -bg green -fg black
} else {
.top27.but27 config -bg red
}
specsiteupdate "ss"
bind .top27 <Destroy> {
changetab big
}
}
"big" {
wm withdraw .top27
destroyfilter .top27
Window show .top17
}
"default" {
foreach f {21 35 44 46} {
if {[grid info .top17.fra[set f]] != ""} {
grid remove .top17.fra[set f]
}
}
array set frames {connect 46 terminal 44 key 35 ssh 21}
grid .top17.fra$frames($mode) -in .top17 \
-column 0 -row 1 -columnspan 1 -rowspan 1 \
-ipadx 2 -ipady 2 -padx 2 -pady 2 -sticky nesw
showstatus ""
}
}
}
proc choosefile {{entry ""} {startdir ""} {mode ""} {task ""}} {
global actdirsel env widget
switch -exact $task {
"identityent" {
set entry $widget(identityent)
set startdir $env(HOME)/.ssh
set mode "Open"
}
"cfgfileent" {
set entry $widget(cfgfileent)
set startdir $env(HOME)/.ssh
set mode "Open"
}
"keygen" {
set entry "$widget(identpath)"
set startdir "$env(HOME)/.ssh"
set mode "Save"
}
"*" {
}
}
if {$startdir == "actdirsel"} {
if [info exists actdirsel] {
set startdir $actdirsel
} else {
set startdir "/usr/"
}
}
set choice [tk_get[set mode]File -initialdir $startdir]
if {$choice != ""} {
$entry delete 0 end
$entry insert 0 $choice
set actdirsel [file dirname $choice]
} else {
return
}
}
proc showmessage_wizard {text} {
global widget
$widget(messageline) config -text "$text"
}
proc distwizard {mode direct} {
global widget key connectionprofiles
switch -exact $mode {
"key" {
switchtab_wizard "key"
update_keylist
$widget(contbutton) config -command "distwizard host f" -text "Continue" -state "active"
$widget(backbutton) config -state "disabled" -command ""
showmessage_wizard ""
}
"host" {
if {$direct == "f"} {
set key [$widget(distkeyentry) get]
if {$key == ""} {
showmessage_wizard "Please choose key!"
return
}
}
switchtab_wizard "host"
$widget(contbutton) config -command "distwizard confirm f" -text "Continue" -state "active"
$widget(backbutton) config -command "distwizard key b" -state "active"
showmessage_wizard ""
}
"confirm" {
if {$direct == "f"} {
if {[selection own] != $widget(distconnlist)} {
showmessage_wizard "Please choose connection!"
return
}
set connections [$widget(distconnlist) curselection]
}
set connectiontitles ""
set connectionprofiles ""
foreach connentry $connections {
set connectiontitles [concat $connectiontitles [$widget(distconnlist) get $connentry]]
lappend connectionprofiles [retprof [$widget(distconnlist) get $connentry]]
}
switchtab_wizard "confirm"
$widget(finishmessage) config -text "Distribute\n$key\nto connection\n[lsort $connectiontitles]"
$widget(contbutton) config -command "distwizard finish f" -text "Distribute key" -state "active"
$widget(backbutton) config -command "distwizard host b" -state "active"
showmessage_wizard ""
}
"finish" {
Window destroy .top53
distkey "\"$key\"" "$connectionprofiles"
}
}
}
proc distkey {key connectionprofiles} {
global env widget libdir configs termtype
set connstring ""
foreach actconn $connectionprofiles {
source "$env(HOME)/.secpanel/profiles/$actconn.profile"
if {$user == "<ASKFORUSER>"} {
set user [askforuser]
if {$user == "#####"} {
return
}
}
set singleactstring "$libdir/spdistkey $host $port $user $key $configs(sshbin)"
set connstring "$connstring $singleactstring"
set connstring "$connstring \n\n\necho ==============================================================\n\n"
historyman write 5 "$key -> $user@$host"
}
set connstring "$connstring echo
echo \"Key-Distribution finished\nPress <Return> to continue\"
read out
exit"
set usetermver $configs(termver)
set icontag ""
set configs(xtermbin) $termtype([set usetermver]_path)
set titlepar $termtype([set usetermver]_titlepar)
set quotepar $termtype([set usetermver]_quotepar)
set execpar $termtype([set usetermver]_execpar)
if {[info exists termicon] && $termicon} {
set icontag $termtype([set usetermver]_iconpar)
}
# </xterm selection and params>
set runstring "exec $configs(xtermbin) $titlepar \"secpanel Key-Distribution\" $execpar $quotepar <CONNFILE> $quotepar"
provrunfile term bg $connstring $runstring
}
proc command_trace {mode "text {}"} {
global env configs wins
set tracetext ".top24.cpd25.03"
set tracefile "$env(HOME)/.secpanel/.runfiles/trace.log"
switch -exact $mode {
"view" {
Window show .top24
if {[info exists configs(wingeom)] && $configs(wingeom)} {
if [info exists wins(trace)] {
wm geometry ".top24" $wins(trace)
}
}
$tracetext delete 1.0 end
if [file exists "$tracefile"] {
set tf [open "$tracefile" r]
while {[gets $tf line] >= 0} {
set elems [split $line "#"]
$tracetext insert end "[clock format [lindex $elems 0]] - [lindex $elems 1]\n"
}
close $tf
} else {
$tracetext insert end "No tracelog available"
}
$tracetext see end
}
"save" {
set tf [open "$tracefile" a]
puts $tf "[clock seconds]#[quote_double_space $text]"
close $tf
if [winfo exists .top24] {
command_trace "view"
}
}
}
}
proc switchtab_wizard {mode} {
global widget
foreach f {key host confirm} {
if {[grid info $widget([set f]frame)] != ""} {
grid remove $widget([set f]frame)
}
}
grid $widget([set mode]frame) -in .top53 -column 0 -row 1 -columnspan 1 -rowspan 1 -ipadx 2 -ipady 2 -padx 2 -pady 2 -sticky nesw
}
proc clear_prmenu {} {
global env widget
$widget(profiles) delete 0 end
foreach prof [lsort [glob -nocomplain "$env(HOME)/.secpanel/profiles/*.profile"]] {
$widget(profiles) insert end "[file rootname [file tail $prof]]"
}
}
proc clear_profiles {} {
global env widget noagentforward x11forward stricthost nopriv lfs rfs \
verbose quiet fork gateway compress algo compressval \
connwait termicon sshverconnect ipverconnect askuserspec noexec
foreach b {noagentforward x11forward stricthost nopriv \
verbose quiet fork gateway compress connwait termicon askuserspec noexec} {
set [set b] 0
}
set algo "default"
set compressval 6
foreach e {profile host command title subsys identity cfgfile user port} {
$widget([set e]ent) delete 0 end
}
if [info exists lfs] {
unset lfs
}
if [info exists rfs] {
unset rfs
}
$widget(userent) insert 0 "$env(USER)"
$widget(portent) insert 0 "22"
set sshverconnect "2"
set ipverconnect "4"
if {[winfo exists .top43]} {
Window destroy .top43
open_forwardings l
}
if {[winfo exists .top51]} {
Window destroy .top51
open_forwardings r
}
}
proc provrunfile {term bg connstring runstring} {
global env platform libdir
if {$bg=="bg"} {
set bgtag "&"
} else {
set bgtag ""
}
if {$term == "term"} {
set cf "$env(HOME)/.secpanel/.runfiles/runproc.[clock clicks]"
set connfile [open $cf w]
puts $connfile "#!/bin/sh\n"
puts $connfile $connstring
if {$bg == "nobg"} {
puts $connfile "\necho \"secpanel: Cleaning up handling data for this operation...\";\nrm -f $cf"
}
close $connfile
exec chmod +x $cf
set cfr "$cf-run"
set crfile [open "$cfr" w]
puts $crfile [regsub {<CONNFILE>} $runstring $cf]
close $crfile
exec chmod +x $cfr
exec $cfr $bgtag
} else {
set cfr "$env(HOME)/.secpanel/.runfiles/runproc.[clock clicks]-run"
set crfile [open "$cfr" w]
puts $crfile "$runstring $connstring"
close $crfile
exec chmod +x $cfr
exec $cfr $bgtag
}
}
proc connect_sftp {} {
global widget env configs libdir
if {! [$widget(specsites) index end] > 0} {
showmessage "No connections available, please use \"New\"" ""
return
}
if {[selection own] != $widget(specsites)} {
showmessage "Please select connection" .top17
return
}
set connsel [$widget(specsites) curselection]
set connstring ""
foreach connselentry $connsel {
set actconn [retprof [$widget(specsites) get $connselentry]]
source "$env(HOME)/.secpanel/profiles/$actconn.profile"
if {$user == "<ASKFORUSER>"} {
set user [askforuser]
if {$user == "#####"} {
return
}
}
switch -exact $configs(sftpbin) {
"Filezilla" {
set runstring "filezilla -l interactive "
}
"GNOME-Nautilus" {
set runstring "nautilus "
}
"KDE-Konqueror" {
set runstring "konqueror "
}
}
set connstring "sftp://$user@$host:$port"
command_trace save "$runstring$connstring"
provrunfile noterm bg "" $runstring$connstring
historyman write 2 "$connstring"
}
}
proc multiconnect {mode} {
global widget env configs libdir
if {! [$widget(specsites) index end] > 0} {
showmessage "No connections available, please use \"New\"" ""
return
}
if {[selection own] != $widget(specsites)} {
showmessage "Please select connection" .top17
return
}
set connsel [$widget(specsites) curselection]
set connstring ""
foreach connselentry $connsel {
set actconn [retprof [$widget(specsites) get $connselentry]]
source "$env(HOME)/.secpanel/profiles/$actconn.profile"
if {$user == "<ASKFORUSER>"} {
set user [askforuser]
if {$user == "#####"} {
return
}
}
switch -exact $mode {
"multixterm" {
set connstring "$connstring $user@$host:$port"
}
"cssh" {
set connstring "$connstring $user@$host:$port"
}
}
}
switch -exact $mode {
"multixterm" {
set runstring "multixterm -xc \"ssh %n\""
}
"cssh" {
set runstring "cssh"
}
}
command_trace save "$runstring $connstring"
provrunfile noterm bg $connstring $runstring
}
proc connect {{cm ""}} {
global widget env configs libdir termtype
set sshverconnect 1
if {$cm == "ss"} {
set connsel 1
} else {
if {! [$widget(specsites) index end] > 0} {
showmessage "No connections available, please use \"New\"" ""
return
}
if {[selection own] != $widget(specsites)} {
showmessage "Please select connection" .top17
return
}
set connsel [$widget(specsites) curselection]
}
foreach connselentry $connsel {
if {$cm == "ss"} {
set actconn [retprof [$widget(sspecsites).sspecmenu entrycget active -label]]
} else {
set actconn [retprof [$widget(specsites) get $connselentry]]
}
source "$env(HOME)/.secpanel/profiles/$actconn.profile"
if {$user == "<ASKFORUSER>"} {
set user [askforuser]
if {$user == "#####"} {
return
}
}
if {[array size lfs] > 0} {
foreach lf [array names lfs] {
if {[regsub {<TARGET-HOST>} [lindex [split $lf :] 1] $host th]} {
append lf_tag " -L [lindex [split $lf :] 0]:$th:[lindex [split $lf :] 2] "
} else {
append lf_tag " -L [lindex [split $lf :] 0]:[lindex [split $lf :] 1]:[lindex [split $lf :] 2] "
}
}
} else {
set lf_tag " "
}
set localhost [info hostname]
if {[array size rfs] > 0} {
foreach rf [array names rfs] {
if {[regsub {<LOCAL-HOST>} [lindex [split $rf :] 1] $localhost lh]} {
append rf_tag " -R [lindex [split $rf :] 0]:$lh:[lindex [split $rf :] 2] "
} else {
append rf_tag " -R [lindex [split $rf :] 0]:[lindex [split $rf :] 1]:[lindex [split $rf :] 2] "
}
}
} else {
set rf_tag " "
}
if {$user != ""} {
set user_tag "-l $user "
} else {
set user_tag " "
}
if {$port == 22 || $port == ""} {
set port_tag " "
} else {
set port_tag "-p $port "
}
if {$algo != "default" || $algo == ""} {
set algo_tag "-c $algo "
} else {
set algo_tag " "
}
if {$identity != ""} {
set ident_tag "-i $identity "
} else {
set ident_tag " "
}
if {[info exists cfgfile] && $cfgfile != ""} {
set cfgfile_tag "-F $cfgfile "
} else {
set cfgfile_tag " "
}
if {[info exists noagentforward] && $noagentforward} {
set noagentforward_tag "-a "
} else {
set noagentforward_tag "-A "
}
if {$command != "" && ([info exists noexec] && ! $noexec) && \
([info exists subsys] && $subsys == "")} {
set command_tag "$command"
} elseif {[info exists subsys] && $subsys != ""} {
set command_tag "-s $subsys"
} else {
set command_tag ""
}
if $compress {
# openssh
if {$configs(sshver) == "OpenSSH"} {
set compressval_tag "-o \'CompressionLevel [set compressval]\' "
} else {
set compressval_tag "-o CompressionLevel=$compressval "
}
} else {
set compressval_tag " "
}
array set bools {
"x11forward" "-x" \
"stricthost" "-o StrictHostKeyChecking=yes" \
"nopriv" "-P" \
"verbose" "-v" \
"quiet" "-q" \
"fork" "-f" \
"gateway" "-g" \
"compress" "-C" \
"noexec" "-N"
}
# foreach f [array names $bools]
foreach f {x11forward stricthost nopriv verbose \
quiet fork gateway compress noexec} {
if {[info exists $f] && [set $f]} {
set [set f]_tag "$bools($f) "
} else {
set [set f]_tag " "
}
}
if [info exists sshverconnect] {
set sshvertag "-[set sshverconnect] "
}
if [info exists ipverconnect] {
set ipvertag "-[set ipverconnect] "
} else {
set ipvertag " "
}
# openssh
if {$configs(sshver) == "OpenSSH"} {
if {[info exists x11forward] && ! $x11forward} {
set x11forward_tag "-X "
}
if {[info exists noexec] && $noexec} {
set noexec_tag "-N "
}
}
set usetermver $configs(termver)
set icontag ""
set configs(xtermbin) $termtype([set usetermver]_path)
set titlepar $termtype([set usetermver]_titlepar)
set quotepar $termtype([set usetermver]_quotepar)
set execpar $termtype([set usetermver]_execpar)
if {[info exists termicon] && $termicon} {
set icontag $termtype([set usetermver]_iconpar)
}
# </xterm selection and params>
set waittag ""
set woption ""
if {[info exists connwait] && $connwait } {
set waittag "$libdir/secpanel.wait"
set woption "\'"
}
set connstring "$configs(sshbin) $user_tag \
$noagentforward_tag $x11forward_tag $noexec_tag $stricthost_tag $sshvertag \
$ipvertag $port_tag $algo_tag \
$ident_tag $cfgfile_tag $nopriv_tag $verbose_tag $quiet_tag \
$fork_tag $gateway_tag $compress_tag $compressval_tag \
$lf_tag $rf_tag $host $command_tag"
set runstring "exec $configs(xtermbin) $icontag $titlepar \"SSH Connection - $title\" \
$execpar $quotepar $waittag $woption <CONNFILE> $woption $quotepar"
provrunfile term bg $connstring $runstring
historyman write 1 "$title"
command_trace save "$connstring"
}
}
proc showconfirm {text parent} {
global questres
if {$parent == ""} {
set p .top17
} else {
set p $parent
}
set old [focus]
Window show .top18
set xcoord [expr [winfo rootx $p] + ([winfo width $p] / 2) - ([winfo width .top18] / 2)]
set ycoord [expr [winfo rooty $p] + ([winfo height $p] / 2) - ([winfo height .top18] / 2)]
wm geometry .top18 +$xcoord+$ycoord
.top18.mes19 config -text "$text"
tkwait visibility .top18
focus .top18
grab .top18
tkwait variable questres
grab release .top18
focus $old
Window destroy .top18
if {$questres} {
return 1
} else {
return 0
}
}
proc getuser {} {
global widget userres
set userres [$widget(askeduser) get]
}
proc askforuser {"mode c"} {
global userres widget
set old [focus]
Window show .top21
if {$mode == "md"} {
wm title .top21 "secpanel - Make dir"
.top21.fra22.mes23 config -text "Enter name of new directory:"
.top21.but26 config -text "Make dir"
}
if {$mode == "protectdata"} {
wm title .top21 "secpanel - Give password for secpanel data protection"
.top21.fra22.mes23 config -text "Enter name of new directory:"
.top21.but26 config -text "Make dir"
}
tkwait visibility .top21
focus $widget(askeduser)
grab .top21
tkwait variable userres
grab release .top21
focus $old
Window destroy .top21
return $userres
}
proc quote_space {in} {
regsub -all " " $in "\\ " out
return $out
}
proc quote_double_space {in} {
regsub -all " +" $in " " out
return $out
}
proc showmessage {text parent} {
if {$parent == ""} {
set p .top17
} else {
set p $parent
}
Window show .top22
.top22.mes23 config -text $text
set xcoord [expr [winfo rootx $p] + ([winfo width $p] / 2) - ([winfo width .top22] / 2)]
set ycoord [expr [winfo rooty $p] + ([winfo height $p] / 2) - ([winfo height .top22] / 2)]
wm geometry .top22 +$xcoord+$ycoord
focus .top22
grab .top22
tkwait window .top22
}
proc check_sources {mode} {
global configs
switch -exact $mode {
ssh {
}
sp {
exec $configs(browserbin) "http://secpanel.net/?sp_check" &
}
}
}
proc delconn {} {
global widget env
if {[selection own] == $widget(specsites)} {
set actentry [$widget(specsites) get active]
set delprof [retprof $actentry]
if {[showconfirm "Delete $actentry?" ""] == 1} {
file delete "$env(HOME)/.secpanel/profiles/$delprof.profile"
specsiteupdate
clear_prmenu
selection clear
} else {
return
}
} else {
showmessage "No entry selected" ""
}
}
proc delete_profile {} {
global env widget
set act [$widget(profileent) get]
if {$act == ""} {
showmessage "To delete a profile first load it" ""
return
}
if {[showconfirm "Delete $act?" ""] == 1} {
file delete "$env(HOME)/.secpanel/profiles/$act.profile"
clear_prmenu
clear_profiles
specsiteupdate
}
}
proc hostkey {mode} {
global env widget configs hostkeytype
set khfile "$env(HOME)/.ssh/known_hosts"
catch {exec $configs(keygenbin) -h} ver
if [regexp -nocase "F hostname Find hostname" $ver] {
set hostkeytype "hashed"
} else {
set hostkeytype "clear"
}
switch -exact $mode {
edit {
Window show .top50
$widget(knownhosts) delete 0 end
if { ! [file exists $khfile]} {
showmessage "No $khfile found" ""
return
}
if {$hostkeytype=="hashed"} {
# handle new hashed hostkey format
set profiles [glob -nocomplain "$env(HOME)/.secpanel/profiles/*.profile"]
foreach prof [lsort $profiles] {
source $prof
catch {exec $configs(keygenbin) -F $host} ver
if [regexp -nocase "found" $ver] {
$widget(knownhosts) insert end $host
}
}
return
# end of handling hashed hostkeys
} else {
set hosts [open $khfile r]
while {[gets $hosts line] >= 0} {
lappend hl [lindex [split $line] 0]
}
if {[file size $khfile] > 0} {
foreach h [lsort $hl] {
$widget(knownhosts) insert end $h
}
}
close $hosts
return
}
}
view {
keygen info host
}
export {
if {[selection own] != $widget(knownhosts)} {
showmessage "No hostkey selected!" ".top50"
return
}
set actk [$widget(knownhosts) get active]
set hkf [tk_getSaveFile -initialdir "$env(HOME)"]
if {$hkf == ""} {
return
} else {
set hkfout [open "$hkf" w]
set hosts [open $khfile r]
while {[gets $hosts line] >= 0} {
set kparts [split $line]
if {[lindex $kparts 0] == $actk} {
puts $hkfout $line
break
}
}
close $hosts
close $hkfout
return
}
}
delete {
if {[selection own] != $widget(knownhosts)} {
showmessage "No hostkey selected!" ".top50"
return
}
set actk [$widget(knownhosts) get active]
if {[showconfirm "Delete $actk?" ".top50"] == 1} {
if {$hostkeytype=="hashed"} {
# handle deletion of hashed hostkeys
if [catch {exec $configs(keygenbin) -R $actk} err] {
showmessage $err ""
}
# end handling deletion of hashed hostkeys
} else {
if [file exists $khfile] {
set hosts [open $khfile r]
# read lines
while {[gets $hosts line] >= 0} {
lappend klines $line
}
close $hosts
# write lines
set hosts [open $khfile w]
foreach line $klines {
set kparts [split $line]
if {[lindex $kparts 0] != $actk} {
puts $hosts $line
}
}
close $hosts
}
}
hostkey edit
selection clear
} else {
return
}
}
}
}
proc insprot {nr mode} {
global widget
$widget([set mode]fout) delete 0 end
$widget([set mode]fout) insert 0 $nr
}
proc keygen {mode "in_keytype {}"} {
global env widget configs pwtextmode libdir nopass passintext kf keytype termtype
set usetermver $configs(termver)
set icontag ""
set configs(xtermbin) $termtype([set usetermver]_path)
set titlepar $termtype([set usetermver]_titlepar)
set quotepar $termtype([set usetermver]_quotepar)
set execpar $termtype([set usetermver]_execpar)
if {[info exists termicon] && $termicon} {
set icontag $termtype([set usetermver]_iconpar)
}
# </xterm selection and params>
switch -exact $mode {
gen {
# comment
if {[.top52.fra18.ent24 get] == ""} {
set commtag " "
} else {
set commtag "-C '[.top52.fra18.ent24 get]' "
}
# file
array set ktfiles {"SSH1 RSA1" "identity" "SSH2 RSA" "id_rsa" "SSH2 DSA" "id_dsa"}
set ktfile $ktfiles($keytype)
set identfile "[$widget(identpath) get]"
if {$identfile == ""} {
set identfile "$env(HOME)/.ssh/$ktfile"
}
set filetag "-f $identfile "
if [file exists $identfile] {
if [showconfirm "$identfile exists. Overwrite?" .top52] {
file delete $identfile
} else {
return
}
}
# pass
if {$nopass} {
set passtag "-N \"\""
} elseif {$passintext} {
set passtag " "
} elseif {[.top52.fra18.ent29 get] == ""} {
showmessage "Please enter the password for the new key!" .top52
return
} else {
if {[.top52.fra18.ent29 get] == [.top52.fra18.ent25 get]} {
set passtag "-N [.top52.fra18.ent29 get] "
} else {
showmessage "Password and repeated password are not the same!" .top52
return
}
}
# type
array set ktshorts {"SSH1 RSA1" "rsa1" "SSH2 RSA" "rsa" "SSH2 DSA" "dsa"}
set typetag "-t $ktshorts($keytype) "
set connstring "$configs(keygenbin) $filetag $passtag $typetag $commtag"
if {$passintext} {
set kgstringt "$configs(keygenbin) $filetag $typetag $commtag"
} else {
set kgstringt "$configs(keygenbin) $filetag -N ***** $typetag $commtag"
}
set runstring "exec $configs(xtermbin) $titlepar \"secpanel ssh-keygen\" \
$execpar $quotepar $libdir/secpanel.wait <CONNFILE> $quotepar"
command_trace save "$kgstringt"
historyman write 4 "$identfile"
provrunfile term nobg $connstring $runstring
update_keylist
keygen clear
}
"clear" {
foreach ke {.top52.fra18.ent24 .top52.fra18.ent29 .top52.fra18.ent29 .top52.fra18.ent25} {
[set ke] delete 0 end
}
$widget(identpath) delete 0 end
set keytype "SSH2 DSA"
set nopass 0
set passintext 0
set pwtextmode 0
}
0 {
set keytype "SSH2 DSA"
Window show .top52
.top52.fra18.but27 configure -image [image create photo -file $libdir/images/folder.gif]
update_keylist
}
1 {
if {[selection own] != $widget(keylist)} {
showmessage "No key selected!" .top52
return
}
set kf "$env(HOME)/.ssh/[$widget(keylist) get active]"
if [set pwtextmode] {
set connstring "$configs(keygenbin) -p -f $kf"
set runstring "exec $configs(xtermbin) $titlepar \"secpanel - \
change password for $kf\" \
$execpar $quotepar $libdir/secpanel.wait <CONNFILE> $quotepar"
provrunfile term bg $connstring $runstring
} else {
Window show .top20
$widget(proplabel) config -text $kf
}
}
chpwd {
set oldp [.top20.fra21.ent26 get]
set newp1 [.top20.fra21.ent30 get]
set newp2 [.top20.fra21.ent31 get]
if {$newp1 != $newp2} {
showmessage "New password and repeated new password don't match" ""
return
}
set chpwdstr "$configs(keygenbin) -p -f $kf -P ***** -N *****"
if [catch {exec $configs(keygenbin) -p -f $kf -P $oldp -N $newp1} err] {
showmessage $err ""
return
}
Window destroy .top20
command_trace save "$chpwdstr"
}
info {
if {$in_keytype != "host"} {
if {[$widget(keylist) index end] == 0} {
return
}
if {[selection own] != $widget(keylist)} {
showmessage "No key selected!" .top52
return
}
set actk [$widget(keylist) get active]
set actkfile "$env(HOME)/.ssh/$actk"
if {! [file exists "$actkfile"]} {
showmessage "Keyfile not found" .top52
return
}
} else {
set khfile "$env(HOME)/.ssh/known_hosts"
if {[$widget(knownhosts) index end] == 0} {
return
}
set actk [$widget(knownhosts) get active]
if [file exists $khfile] {
if {[file size $khfile] > 0} {
set hosts [open $khfile r]
while {[gets $hosts line] >= 0} {
set kparts [split $line]
if {[lindex $kparts 0] == $actk} {
set fname "$env(HOME)/.secpanel/.runfiles/hkview.[clock clicks]"
set af [open "$fname" w]
puts $af $line
close $af
set actkfile "$fname"
}
}
close $hosts
} else {
showmessage "Keyfile empty" .top50
return
}
} else {
showmessage "Keyfile not found" .top50
return
}
}
set fptext ".top19.tex17"
set bbtext ".top19.tex18"
if [file exists "$actkfile"] {
Window show .top19
if {$in_keytype != "host"} {
set kt "user key"
} else {
set kt "host key"
}
.top19.fra22.lab23 config -text "Keyfile: $actkfile"
.top19.fra22.lab24 config -text "Keytype: $kt"
$fptext config -state normal
$bbtext config -state normal
$fptext delete 1.0 end
$bbtext delete 1.0 end
$fptext insert end "[exec $configs(keygenbin) -l -f $actkfile]"
$bbtext insert end "[exec $configs(keygenbin) -B -f $actkfile]"
$fptext config -state disabled
$bbtext config -state disabled
return
} else {
showmessage "Couldn't find the public key for this identity!" .top52
return
}
}
del {
if {[selection own] != $widget(keylist)} {
showmessage "No key selected!" .top52
return
}
if [showconfirm "Really delete [$widget(keylist) get active]?" .top52] {
file delete -force "$env(HOME)/.ssh/[$widget(keylist) get active]"
file delete -force "$env(HOME)/.ssh/[$widget(keylist) get active].pub"
update_keylist
}
}
chpath {
choosefile "" "" "" keygen
}
dist {
Window show .top53
specsiteupdate
distwizard key f
}
}
}
proc update_keylist {} {
global widget env
if [winfo exists .top52] {
$widget(keylist) delete 0 end
}
if [winfo exists .top53] {
$widget(distkeylist) delete 0 end
}
set keyfiles [glob -nocomplain "$env(HOME)/.ssh/*.pub"]
foreach kf [lsort $keyfiles] {
if [winfo exists .top52] {
$widget(keylist) insert end [file rootname [file tail $kf]]
}
if [winfo exists .top53] {
$widget(distkeylist) insert end [file rootname [file tail $kf]]
}
}
}
proc load_profile {mode} {
global env widget noagentforward x11forward stricthost nopriv \
verbose quiet fork gateway compress algo \
compressval lfs rfs connwait termicon sshverconnect \
ipverconnect askuserspec noexec
foreach var {noagentforward x11forward stricthost nopriv \
verbose quiet fork gateway compress algo \
compressval lfs rfs connwait termicon askuserspec noexec} {
if [info exists [set var]] {
unset $var
}
}
foreach rvar {sshverconnect ipverconnect} {
if [info exists [set rvar]] {
unset $rvar
}
}
if {! [info exists sshverconnect]} {
set sshverconnect "2"
}
if {! [info exists ipverconnect]} {
set ipverconnect "4"
}
if {$mode == "ssh"} {
set profile [$widget(profiles) get active]
} elseif {$mode == "specsites"} {
set profile [retprof [$widget(specsites) get active]]
}
source $env(HOME)/.secpanel/profiles/$profile.profile
foreach f {title host user port command subsys identity cfgfile profile} {
$widget([set f]ent) delete 0 end
if [info exists $f] {
$widget([set f]ent) insert 0 [set $f]
}
}
if {! [array exists lfs] && $lfs != ""} {
set lfsnew [set lfs]
unset lfs
foreach listelem $lfsnew {
array set lfs \
"[lindex [split $listelem :] 0]:<TARGET-HOST>:[lindex [split $listelem :] 1] \
{Local forward vom old Version of secpanel}"
}
}
if {[winfo exists .top43]} {
open_forwardings l
}
if {[winfo exists .top51]} {
open_forwardings r
}
}
proc manage_agent {mode "m run"} {
global env widget configs launcher defident agent wins
switch -exact $mode {
"launch" {
if {[info exists env(SSH_AGENT_PID)] && [info exists env(SSH_AUTH_SOCK)]} {
if {[showconfirm "There seems to be another SSH-Agent. Start anyway?" ""] == 0} {
return
}
}
# Start ssh-agent and read envs
if {! [file exists "$configs(agentbin)"] && [catch {exec which "$configs(agentbin)"}]} {
showmessage "Can't find SSH-Agent ($configs(agentbin))\nCheck configration!" ".top17"
changetab terminal
return error
}
set agentout [open "| $configs(agentbin) -c" r]
while {[gets $agentout line] >= 0} {
if [string match "setenv SSH*" $line] {
set env([lindex [split $line] 1]) \
[string trimright [lindex [split $line] 2] \;]
}
}
close $agentout
$widget(statusagent) config -text "Agent active" -bg green -fg black
$widget(idents) delete 0 end
wm title .top17 "secpanel - Agent active"
set agent 1
command_trace save "$configs(agentbin) -c"
historyman write 6 "Launching agent"
}
"kill" {
if {$m == "end" && ! $launcher && $agent == "ext"} {
return
} elseif {$m == "end" && $launcher && $agent != "ext"} {
catch {exec $configs(agentbin) -k} killerr
unset env(SSH_AGENT_PID)
unset env(SSH_AUTH_SOCK)
historyman write 6 "Stopping agent"
} elseif {$m == "end" && $launcher && $agent == "ext"} {
return
} else {
if [info exists env(SSH_AGENT_PID)] {
if {$agent == "ext"} {
showmessage "Will not kill external agent!" .top17
return
}
if {[showconfirm "Kill SSH-agent?" ""] == 1} {
exec $configs(agentbin) -k
unset env(SSH_AGENT_PID)
unset env(SSH_AUTH_SOCK)
$widget(statusagent) config -text "No Agent" -bg red
wm title .top17 "secpanel - No Agent"
$widget(idents) delete 0 end
set agent 0
command_trace save "$configs(agentbin) -k"
historyman write 6 "Stopping agent"
if [winfo exists .top33] {
destroyfilter .top33
}
} else {
return
}
} else {
showmessage "No agent running" .top17
}
}
}
"info" {
if {[info exists env(SSH_AGENT_PID)] && [info exists env(SSH_AUTH_SOCK)]} {
Window show .top33
if {[info exists configs(wingeom)] && $configs(wingeom)} {
if [info exists wins(agentinfo)] {
wm geometry ".top33" $wins(agentinfo)
}
}
.top33.fra34.lab38 config -text $env(SSH_AUTH_SOCK)
.top33.fra34.lab39 config -text $env(SSH_AGENT_PID)
catch {exec $configs(addbin) -l} err
command_trace save "$configs(addbin) -l"
set text .top33.cpd36.03
$text delete 1.0 end
$text insert end "Fingerprints of keys contained by the running agent:\n\n"
$text insert end $err
} else {
showmessage "No agent running or\nagent environment not clean" .top17
}
}
"chdef" {
set defident [tk_getOpenFile -initialdir "$env(HOME)/.ssh/"]
if {$defident != ""} {
save_globals chdef
historyman write 6 "Setting default identity to $defident"
}
}
"rmdef" {
set defident ""
save_globals chdef
historyman write 6 "Removing default identity"
}
"addident" {
if {! [info exists env(SSH_AGENT_PID)]} {
showmessage "No agent running" .top17
return
}
if {($m == "start")} {
if { $launcher && [info exists defident] && $defident != ""} {
showstatus "Adding default identity"
update idletasks
set fname $defident
} else {
set fname ""
}
} else {
showstatus "Adding identity"
update idletasks
set fname [tk_getOpenFile -initialdir "$env(HOME)/.ssh/"]
}
if {$fname != ""} {
# openssh
if {$configs(sshver) == "OpenSSH"} {
set env(SSH_ASKPASS) $configs(askpassbin)
}
catch {exec $configs(addbin) $fname < /dev/null} err
command_trace save "$configs(addbin) $fname < /dev/null"
if [string match "*No such file*" $err] {
showmessage "Can't find your askpass program-\nCheck configuration!" .top17
return
}
if [string match "Bad key file*" $err] {
showmessage "Bad key file" .top17
return
}
set found 0
foreach ent [$widget(idents) get 0 end] {
if {$ent == $fname} {
set found 1
break
}
}
if {! $found} {
$widget(idents) insert end $fname
}
if [winfo exists .top33] {
manage_agent "info"
}
showstatus ""
historyman write 6 "Adding identity $fname"
} else {
showstatus ""
return
}
}
"remident" {
if {! [info exists env(SSH_AGENT_PID)]} {
showmessage "No agent running" .top17
return
}
if {[selection own] != $widget(idents)} {
showmessage "No Identity selected" ""
return
} else {
catch {exec $configs(addbin) -d [$widget(idents) get active]}
$widget(idents) delete active
selection clear
command_trace save "$configs(addbin) -d [$widget(idents) get active]"
historyman write 6 "Removing identity [$widget(idents) get active]"
if [winfo exists .top33] {
manage_agent "info"
}
}
}
}
}
proc newconn {state} {
changetab ssh
clear_profiles
}
proc propconn {mode} {
global widget
if {[selection own] != $widget([set mode])} {
showmessage "Please select connection" .top17
return
}
if {[$widget([set mode]) index end] > 0} {
changetab ssh
load_profile $mode
} else {
showmessage "No conncections available, please use \"New\"" ""
return
}
}
proc retprof {tit} {
global env
foreach f [glob -nocomplain "$env(HOME)/.secpanel/profiles/*.profile"] {
source $f
if {$title == $tit} {
return "[file rootname [file tail $f]]"
}
unset lfs
}
}
proc save_profile {} {
global env widget noagentforward x11forward stricthost nopriv verbose \
quiet fork gateway compress algo compressval lfs rfs \
connwait termicon sshverconnect ipverconnect askuserspec noexec
set prname [$widget(profileent) get]
if {$prname == ""} {
showmessage "Enter a name for the profile" ""
return
}
set title [$widget(titleent) get]
set host [$widget(hostent) get]
set user [$widget(userent) get]
if {[info exists askuserspec] && $askuserspec} {
set user "<ASKFORUSER>"
}
set port [$widget(portent) get]
set command [$widget(commandent) get]
set subsys [$widget(subsysent) get]
if {$title == "" || $host == ""} {
showmessage "You must enter at least host and title" ""
return
}
if {$subsys != "" && ($command != "" || $noexec)} {
showmessage "The subsys-entry will be used later (has higher priority)" .top17
}
set identity [$widget(identityent) get]
set cfgfile [$widget(cfgfileent) get]
set prfile [open "$env(HOME)/.secpanel/profiles/$prname.profile" w]
puts $prfile "#\n# secpanel-Profile\n# Do not edit, use secpanel instead\n#"
foreach ent {title host user port command subsys identity cfgfile} {
puts $prfile "set [set ent] \"[set $ent]\""
}
foreach bool {noagentforward x11forward stricthost nopriv verbose \
quiet fork gateway compress connwait termicon askuserspec noexec} {
if [info exists [set bool]] {
if [set $bool] {
puts $prfile "set [set bool] \"[set $bool]\""
} else {
puts $prfile "set [set bool] \"[set $bool]\""
}
}
}
foreach sel {algo compressval} {
puts $prfile "set [set sel] \"[set $sel]\""
}
puts $prfile "set sshverconnect \"[set sshverconnect]\""
puts $prfile "set ipverconnect \"[set ipverconnect]\""
if [info exists lfs] {
puts $prfile "array set lfs {[array get lfs]}"
} else {
puts $prfile "array set lfs {}"
}
if [info exists rfs] {
puts $prfile "array set rfs {[array get rfs]}"
} else {
puts $prfile "array set rfs {}"
}
close $prfile
specsiteupdate
clear_prmenu
clear_profiles
}
proc seldistkey {} {
global env widget
set ftypes {
{{Public keys} {.pub}}
{{All files} *}
}
$widget(distkeyentry) delete 0 end
$widget(distkeyentry) insert 0 \
[tk_getOpenFile -initialdir "$env(HOME)/.ssh" -filetypes $ftypes]
}
proc specsiteupdate {{mode ""}} {
global widget env
$widget(specsites) delete 0 end
if [winfo exists $widget(distconnlist)] {
$widget(distconnlist) delete 0 end
}
set profiles [glob -nocomplain "$env(HOME)/.secpanel/profiles/*.profile"]
if {$mode == "ss"} {
if {! [winfo exists $widget(sspecsites).sspecmenu]} {
menu $widget(sspecsites).sspecmenu -tearoff 0 -border 1
$widget(sspecsites) config -menu $widget(sspecsites).sspecmenu
} else {
$widget(sspecsites).sspecmenu delete 0 end
}
}
foreach prof [lsort $profiles] {
source $prof
$widget(specsites) insert end $title
if [winfo exists $widget(distconnlist)] {
$widget(distconnlist) insert end $title
}
if {$mode == "ss"} {
$widget(sspecsites).sspecmenu add command -label "$title" -command "connect ss"
}
unset lfs
}
}
proc about {} {
global libdir spversion
Window show .top25
.top25.fra26.lab21 config -text "secpanel $spversion"
}
proc showstatus {text} {
global widget
$widget(status) config -text $text
update idletasks
}
proc do_firstinit {lv} {
global libdir spversion env
source $libdir/convert_history.tcl
source $libdir/convert_profile.tcl
}
proc do_exit {} {
global env wins libdir configs
foreach f [glob -nocomplain "$env(HOME)/.secpanel/.runfiles/*"] {
file delete -force $f
}
if {[info exists env(SSH_AGENT_PID)] && [info exists env(SSH_AUTH_SOCK)]} {
manage_agent kill "end"
}
foreach {winn winnr} {base .top17 trace .top24 sat .top27 agentinfo .top33 hist .top26} {
if [winfo exists $winnr] {
set wins($winn) [wm geometry $winnr]
}
}
save_globals "geom"
# spdata
if [set configs(protectdata)] {
exec $libdir/dppw.tcl "en"
}
destroyfilter .top17
exit
}
proc destroyfilter {win} {
global wins
foreach {winn winnr} {base .top17 trace .top24 sat .top27 agentinfo .top33 hist .top26} {
if {$win == $winnr} {
set wins($winn) [wm geometry $win]
}
}
Window destroy $win
}
proc main {argc argv} {
global widget env configs libdir spversion launcher agent termtype
wm protocol .top17 WM_DELETE_WINDOW do_exit
# bind .top17 <Destroy> {
# do_exit
# }
foreach f {ssh keygen agent add askpass scp browser} {
$widget([set f]ent) insert 0 "$configs([set f]bin)"
}
foreach b {connects profiles keys configs sscreen} {
$widget([set b]but) config -border 2 -relief groove -image \
[image create photo -file $libdir/images/[set b]_gr.gif]
}
foreach {sftptag sftpprog} {
"KDE-Konqueror" konqueror
"GNOME-Nautilus" nautilus
"Filezilla" filezilla
} {
if {! [catch {exec which "$sftpprog"}]} {
.top17.fra44.fra19.fra30.men34.m add radiobutton \
-value "$sftptag" -variable "configs(sftpbin)" -label "$sftptag"
} else {
.top17.fra44.fra19.fra30.men34.m add radiobutton \
-value "$sftpprog" -variable "configs(sftpbin)" -label "$sftptag (not found)" \
-state "disabled"
}
}
source "$libdir/termdefs.txt"
foreach k [array names termtype] {
if [string match "*_path" $k] {
set termname [string replace $k [string first "_" $k] end]
set termpath $termtype($k)
if {! [catch {exec which "$termpath"}]} {
.top17.fra44.fra19.fra32.men35.01 add radiobutton \
-value "$termname" -variable "configs(termver)" -label "$termname"
} else {
.top17.fra44.fra19.fra32.men35.01 add radiobutton \
-value "$termname" -variable "configs(termver)" -label "$termname (not found)" \
-state "disabled"
}
}
}
set lv 0
if [file exists "$env(HOME)/.secpanel/.init"] {
set vf [open "$env(HOME)/.secpanel/.init" r]
set lv [read $vf]
if {[string equal $spversion $lv] != 1} {
do_firstinit $lv
exec echo -n $spversion > $env(HOME)/.secpanel/.init
}
close $vf
} else {
exec echo -n $spversion > $env(HOME)/.secpanel/.init
}
menu .mc1 -tearoff 0 -borderwidth 1
if {! [catch {exec which "cssh"}]} {
.mc1 add command -label "ClusterSSH" -command "multiconnect cssh"
} else {
.mc1 add command -label "ClusterSSH (not found)" -command "multiconnect cssh" -state "disabled"
}
if {! [catch {exec which "multixterm"}]} {
.mc1 add command -label "Multi Xterm" -command "multiconnect multixterm"
} else {
.mc1 add command -label "Multi Xterm (not found)" -command "multiconnect multixterm" -state "disabled"
}
if {[catch {exec which "filezilla"}] && [catch {exec which "nautilus"}] && [catch {exec which "konqueror"}]
} {
.top17.fra46.fra26.fra29.fra36.but34 configure -state "disabled"
}
bind .top17.fra46.fra26.fra29.fra36.but38 <Button> {
tk_popup .mc1 [winfo pointerx .top17] [winfo pointery .top17]
}
clear_prmenu
clear_profiles
specsiteupdate
if {[info exists env(SSH_AGENT_PID)] && [info exists env(SSH_AUTH_SOCK)]} {
$widget(statusagent) config -text "Agent active (external)" -bg green -fg black
wm title .top17 "secpanel - Agent active (external)"
historyman write 6 "Accepted external agent"
set initagentout [open "| ssh-add -L" r]
while {[gets $initagentout line] >= 0} {
if [string match "The agent has no identities*" $line] {
continue
}
$widget(idents) insert end [lindex [split $line] 2]
}
set agent "ext"
} else {
$widget(statusagent) config -text "No Agent" -bg red
wm title .top17 "secpanel - No agent"
}
if {$launcher} {
if {[manage_agent launch] != "error"} {
manage_agent addident "start"
}
}
if {[info exists configs(startsat)] && $configs(startsat)} {
changetab small
}
}
source $libdir/gui.tcl
if {[info exists configs(wingeom)] && $configs(wingeom)} {
if [info exists wins(base)] {
wm geometry ".top17" $wins(base)
}
}
foreach b {.top17.fra44.fra19.fra20.but23 .top17.fra44.fra19.fra26.03 \
.top17.fra44.fra19.fra27.03 .top17.fra44.fra19.fra28.03 \
.top17.fra44.fra19.fra29.03 \
.top17.fra44.fra19.fra34.but34 .top17.fra21.fra24.but22 \
.top17.fra21.fra24.but23 .top17.fra44.fra19.fra18.03 \
} {
$b configure -image [image create photo -file $libdir/images/folder.gif]
}
main $argc $argv
|