| 62 |
62 |
| 63 typedef enum { |
63 typedef enum { |
| 64 PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ |
64 PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ |
| 65 PURPLE_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ |
65 PURPLE_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ |
| 66 PURPLE_ZEPHYR_TZC, /* tzc executable proxy */ |
66 PURPLE_ZEPHYR_TZC, /* tzc executable proxy */ |
| 67 PURPLE_ZEPHYR_INTERGALACTIC_KRB4, /* Kerberized ZEPH0.3 */ |
67 PURPLE_ZEPHYR_INTERGALACTIC_KRB4 /* Kerberized ZEPH0.3 */ |
| 68 } zephyr_connection_type; |
68 } zephyr_connection_type; |
| 69 |
69 |
| 70 struct _zephyr_account { |
70 struct _zephyr_account { |
| 71 PurpleAccount* account; |
71 PurpleAccount* account; |
| 72 char *username; |
72 char *username; |
| 1628 if (pid == 0) { |
1628 if (pid == 0) { |
| 1629 unsigned int i=0; |
1629 unsigned int i=0; |
| 1630 gboolean found_ps = FALSE; |
1630 gboolean found_ps = FALSE; |
| 1631 gchar ** tzc_cmd_array = g_strsplit(purple_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0); |
1631 gchar ** tzc_cmd_array = g_strsplit(purple_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0); |
| 1632 if (close(1) == -1) { |
1632 if (close(1) == -1) { |
| 1633 purple_debug_error("zephyr", "stdout couldn't be closed. dying\n"); |
|
| 1634 exit(-1); |
1633 exit(-1); |
| 1635 } |
1634 } |
| 1636 if (dup2(zephyr->fromtzc[1], 1) == -1) { |
1635 if (dup2(zephyr->fromtzc[1], 1) == -1) { |
| 1637 purple_debug_error("zephyr", "dup2 of stdout failed \n"); |
|
| 1638 exit(-1); |
1636 exit(-1); |
| 1639 } |
1637 } |
| 1640 if (close(zephyr->fromtzc[1]) == -1) { |
1638 if (close(zephyr->fromtzc[1]) == -1) { |
| 1641 purple_debug_error("zephyr", "closing of piped stdout failed\n"); |
|
| 1642 exit(-1); |
1639 exit(-1); |
| 1643 } |
1640 } |
| 1644 if (close(0) == -1) { |
1641 if (close(0) == -1) { |
| 1645 purple_debug_error("zephyr", "stdin couldn't be closed. dying\n"); |
|
| 1646 exit(-1); |
1642 exit(-1); |
| 1647 } |
1643 } |
| 1648 if (dup2(zephyr->totzc[0], 0) == -1) { |
1644 if (dup2(zephyr->totzc[0], 0) == -1) { |
| 1649 purple_debug_error("zephyr", "dup2 of stdin failed \n"); |
|
| 1650 exit(-1); |
1645 exit(-1); |
| 1651 } |
1646 } |
| 1652 if (close(zephyr->totzc[0]) == -1) { |
1647 if (close(zephyr->totzc[0]) == -1) { |
| 1653 purple_debug_error("zephyr", "closing of piped stdin failed\n"); |
|
| 1654 exit(-1); |
1648 exit(-1); |
| 1655 } |
1649 } |
| 1656 /* tzc_command should really be of the form |
1650 /* tzc_command should really be of the form |
| 1657 path/to/tzc -e %s |
1651 path/to/tzc -e %s |
| 1658 or |
1652 or |
| 1699 tv.tv_sec = 10; |
1694 tv.tv_sec = 10; |
| 1700 tv.tv_usec = 0; |
1695 tv.tv_usec = 0; |
| 1701 |
1696 |
| 1702 purple_debug_info("zephyr", "about to read from tzc\n"); |
1697 purple_debug_info("zephyr", "about to read from tzc\n"); |
| 1703 |
1698 |
| 1704 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); |
1699 if (waitpid(pid, NULL, WNOHANG) == 0) { /* Only select if tzc is still running */ |
| |
1700 purple_debug_info("zephyr", "about to read from tzc\n"); |
| |
1701 select_status = select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); |
| |
1702 } |
| |
1703 else { |
| |
1704 purple_debug_info("zephyr", "tzc exited early\n"); |
| |
1705 select_status = -1; |
| |
1706 } |
| 1705 |
1707 |
| 1706 FD_ZERO(&rfds); |
1708 FD_ZERO(&rfds); |
| 1707 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
1709 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
| 1708 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { |
1710 while (select_status > 0 && |
| |
1711 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) { |
| 1709 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); |
1712 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); |
| 1710 bufcur++; |
1713 bufcur++; |
| 1711 if ((bufcur - buf) > (bufsize - 1)) { |
1714 if ((bufcur - buf) > (bufsize - 1)) { |
| 1712 if ((buf = realloc(buf, bufsize * 2)) == NULL) { |
1715 if ((buf = realloc(buf, bufsize * 2)) == NULL) { |
| 1713 exit(-1); |
1716 exit(-1); |