version 1.317, 2018/07/11 18:53:29 |
version 1.318, 2018/09/21 12:46:22 |
|
|
const char *xauth_path, u_int trusted, u_int timeout, |
const char *xauth_path, u_int trusted, u_int timeout, |
char **_proto, char **_data) |
char **_proto, char **_data) |
{ |
{ |
char cmd[1024], line[512], xdisplay[512]; |
char *cmd, line[512], xdisplay[512]; |
char xauthfile[PATH_MAX], xauthdir[PATH_MAX]; |
char xauthfile[PATH_MAX], xauthdir[PATH_MAX]; |
static char proto[512], data[512]; |
static char proto[512], data[512]; |
FILE *f; |
FILE *f; |
|
|
return -1; |
return -1; |
} |
} |
|
|
if (timeout >= UINT_MAX - X11_TIMEOUT_SLACK) |
if (timeout == 0) { |
x11_timeout_real = UINT_MAX; |
/* auth doesn't time out */ |
else |
xasprintf(&cmd, "%s -f %s generate %s %s " |
x11_timeout_real = timeout + X11_TIMEOUT_SLACK; |
"untrusted 2>%s", |
if ((r = snprintf(cmd, sizeof(cmd), |
xauth_path, xauthfile, display, |
"%s -f %s generate %s " SSH_X11_PROTO |
SSH_X11_PROTO, _PATH_DEVNULL); |
" untrusted timeout %u 2>" _PATH_DEVNULL, |
} else { |
xauth_path, xauthfile, display, |
/* Add some slack to requested expiry */ |
x11_timeout_real)) < 0 || |
if (timeout < UINT_MAX - X11_TIMEOUT_SLACK) |
(size_t)r >= sizeof(cmd)) |
x11_timeout_real = timeout + |
fatal("%s: cmd too long", __func__); |
X11_TIMEOUT_SLACK; |
|
else { |
|
/* Don't overflow on long timeouts */ |
|
x11_timeout_real = UINT_MAX; |
|
} |
|
xasprintf(&cmd, "%s -f %s generate %s %s " |
|
"untrusted timeout %u 2>%s", |
|
xauth_path, xauthfile, display, |
|
SSH_X11_PROTO, x11_timeout_real, |
|
_PATH_DEVNULL); |
|
} |
debug2("%s: %s", __func__, cmd); |
debug2("%s: %s", __func__, cmd); |
if (x11_refuse_time == 0) { |
|
|
if (timeout != 0 && x11_refuse_time == 0) { |
now = monotime() + 1; |
now = monotime() + 1; |
if (UINT_MAX - timeout < now) |
if (UINT_MAX - timeout < now) |
x11_refuse_time = UINT_MAX; |
x11_refuse_time = UINT_MAX; |
|
|
} |
} |
if (system(cmd) == 0) |
if (system(cmd) == 0) |
generated = 1; |
generated = 1; |
|
free(cmd); |
} |
} |
|
|
/* |
/* |
|
|
* above. |
* above. |
*/ |
*/ |
if (trusted || generated) { |
if (trusted || generated) { |
snprintf(cmd, sizeof(cmd), |
xasprintf(&cmd, |
"%s %s%s list %s 2>" _PATH_DEVNULL, |
"%s %s%s list %s 2>" _PATH_DEVNULL, |
xauth_path, |
xauth_path, |
generated ? "-f " : "" , |
generated ? "-f " : "" , |
|
|
got_data = 1; |
got_data = 1; |
if (f) |
if (f) |
pclose(f); |
pclose(f); |
|
free(cmd); |
} |
} |
} |
} |
|
|