|
Lines 42-47
Link Here
|
| 42 |
#include "sshpty.h" |
42 |
#include "sshpty.h" |
| 43 |
#include "packet.h" |
43 |
#include "packet.h" |
| 44 |
#include "buffer.h" |
44 |
#include "buffer.h" |
|
|
45 |
#include "match.h" |
| 45 |
#include "mpaux.h" |
46 |
#include "mpaux.h" |
| 46 |
#include "uidswap.h" |
47 |
#include "uidswap.h" |
| 47 |
#include "compat.h" |
48 |
#include "compat.h" |
|
Lines 793-798
Link Here
|
| 793 |
|
794 |
|
| 794 |
if (!options.use_login) { |
795 |
if (!options.use_login) { |
| 795 |
/* Set basic environment. */ |
796 |
/* Set basic environment. */ |
|
|
797 |
for (i = 0; i < s->num_env; i++) |
| 798 |
child_set_env(&env, &envsize, s->env[i].name, |
| 799 |
s->env[i].val); |
| 800 |
|
| 796 |
child_set_env(&env, &envsize, "USER", pw->pw_name); |
801 |
child_set_env(&env, &envsize, "USER", pw->pw_name); |
| 797 |
child_set_env(&env, &envsize, "LOGNAME", pw->pw_name); |
802 |
child_set_env(&env, &envsize, "LOGNAME", pw->pw_name); |
| 798 |
child_set_env(&env, &envsize, "HOME", pw->pw_dir); |
803 |
child_set_env(&env, &envsize, "HOME", pw->pw_dir); |
|
Lines 1514-1519
Link Here
|
| 1514 |
} |
1519 |
} |
| 1515 |
|
1520 |
|
| 1516 |
static int |
1521 |
static int |
|
|
1522 |
session_env_req(Session *s) |
| 1523 |
{ |
| 1524 |
char *name, *val; |
| 1525 |
u_int name_len, val_len, i; |
| 1526 |
|
| 1527 |
name = packet_get_string(&name_len); |
| 1528 |
val = packet_get_string(&val_len); |
| 1529 |
packet_check_eom(); |
| 1530 |
|
| 1531 |
/* Don't set too many environment variables */ |
| 1532 |
if (s->num_env > 128) { |
| 1533 |
debug2("Ignoring env request %s: too many env vars", name); |
| 1534 |
goto fail; |
| 1535 |
} |
| 1536 |
|
| 1537 |
for (i = 0; i < options.num_accept_env; i++) { |
| 1538 |
if (match_pattern(name, options.accept_env[i])) { |
| 1539 |
debug2("Setting env %d: %s=%s", s->num_env, name, val); |
| 1540 |
s->env = xrealloc(s->env, sizeof(*s->env) * |
| 1541 |
(s->num_env + 1)); |
| 1542 |
s->env[s->num_env].name = name; |
| 1543 |
s->env[s->num_env].val = val; |
| 1544 |
s->num_env++; |
| 1545 |
return (1); |
| 1546 |
} |
| 1547 |
} |
| 1548 |
debug2("Ignoring env request %s: disallowed name", name); |
| 1549 |
|
| 1550 |
fail: |
| 1551 |
xfree(name); |
| 1552 |
xfree(val); |
| 1553 |
return (0); |
| 1554 |
} |
| 1555 |
|
| 1556 |
static int |
| 1517 |
session_auth_agent_req(Session *s) |
1557 |
session_auth_agent_req(Session *s) |
| 1518 |
{ |
1558 |
{ |
| 1519 |
static int called = 0; |
1559 |
static int called = 0; |
|
Lines 1562-1567
Link Here
|
| 1562 |
success = session_subsystem_req(s); |
1602 |
success = session_subsystem_req(s); |
| 1563 |
} else if (strcmp(rtype, "break") == 0) { |
1603 |
} else if (strcmp(rtype, "break") == 0) { |
| 1564 |
success = session_break_req(s); |
1604 |
success = session_break_req(s); |
|
|
1605 |
} else if (strcmp(rtype, "env") == 0) { |
| 1606 |
success = session_env_req(s); |
| 1565 |
} |
1607 |
} |
| 1566 |
} |
1608 |
} |
| 1567 |
if (strcmp(rtype, "window-change") == 0) { |
1609 |
if (strcmp(rtype, "window-change") == 0) { |
|
Lines 1695-1700
Link Here
|
| 1695 |
void |
1737 |
void |
| 1696 |
session_close(Session *s) |
1738 |
session_close(Session *s) |
| 1697 |
{ |
1739 |
{ |
|
|
1740 |
int i; |
| 1741 |
|
| 1698 |
debug("session_close: session %d pid %ld", s->self, (long)s->pid); |
1742 |
debug("session_close: session %d pid %ld", s->self, (long)s->pid); |
| 1699 |
if (s->ttyfd != -1) |
1743 |
if (s->ttyfd != -1) |
| 1700 |
session_pty_cleanup(s); |
1744 |
session_pty_cleanup(s); |
|
Lines 1709-1714
Link Here
|
| 1709 |
if (s->auth_proto) |
1753 |
if (s->auth_proto) |
| 1710 |
xfree(s->auth_proto); |
1754 |
xfree(s->auth_proto); |
| 1711 |
s->used = 0; |
1755 |
s->used = 0; |
|
|
1756 |
for (i = 0; i < s->num_env; i++) { |
| 1757 |
xfree(s->env[i].name); |
| 1758 |
xfree(s->env[i].val); |
| 1759 |
} |
| 1760 |
if (s->env != NULL) |
| 1761 |
xfree(s->env); |
| 1712 |
session_proctitle(s); |
1762 |
session_proctitle(s); |
| 1713 |
} |
1763 |
} |
| 1714 |
|
1764 |
|