2 * Unix Pageant, more or less similar to ssh-agent.
12 #include <sys/types.h>
17 #define PUTTY_DO_GLOBALS /* actually _define_ globals */
23 SockAddr unix_sock_addr(const char *path);
24 Socket new_unix_listener(SockAddr listenaddr, Plug plug);
26 void fatalbox(const char *p, ...)
29 fprintf(stderr, "FATAL ERROR: ");
31 vfprintf(stderr, p, ap);
36 void modalfatalbox(const char *p, ...)
39 fprintf(stderr, "FATAL ERROR: ");
41 vfprintf(stderr, p, ap);
46 void nonfatal(const char *p, ...)
49 fprintf(stderr, "ERROR: ");
51 vfprintf(stderr, p, ap);
55 void connection_fatal(void *frontend, const char *p, ...)
58 fprintf(stderr, "FATAL ERROR: ");
60 vfprintf(stderr, p, ap);
65 void cmdline_error(const char *p, ...)
68 fprintf(stderr, "pageant: ");
70 vfprintf(stderr, p, ap);
76 FILE *pageant_logfp = NULL;
77 void pageant_log(void *ctx, const char *fmt, va_list ap)
82 fprintf(pageant_logfp, "pageant: ");
83 vfprintf(pageant_logfp, fmt, ap);
84 fprintf(pageant_logfp, "\n");
88 * In Pageant our selects are synchronous, so these functions are
91 uxsel_id *uxsel_input_add(int fd, int rwx) { return NULL; }
92 void uxsel_input_remove(uxsel_id *id) { }
97 void random_save_seed(void) {}
98 void random_destroy_seed(void) {}
99 void noise_ultralight(unsigned long data) {}
100 char *platform_default_s(const char *name) { return NULL; }
101 int platform_default_i(const char *name, int def) { return def; }
102 FontSpec *platform_default_fontspec(const char *name) { return fontspec_new(""); }
103 Filename *platform_default_filename(const char *name) { return filename_from_str(""); }
104 char *x_get_default(const char *key) { return NULL; }
105 void log_eventlog(void *handle, const char *event) {}
108 * Short description of parameters.
110 static void usage(void)
112 printf("Pageant: SSH agent\n");
114 printf("Usage: pageant <lifetime> [key files]\n");
115 printf(" pageant [key files] --exec <command> [args]\n");
116 printf(" pageant -a [key files]\n");
117 printf(" pageant -d [key identifiers]\n");
118 printf(" pageant --public [key identifiers]\n");
119 printf(" pageant --public-openssh [key identifiers]\n");
120 printf(" pageant -l\n");
121 printf(" pageant -D\n");
122 printf("Lifetime options, for running Pageant as an agent:\n");
123 printf(" -X run with the lifetime of the X server\n");
124 printf(" -T run with the lifetime of the controlling tty\n");
125 printf(" --permanent run permanently\n");
126 printf(" --debug run in debugging mode, without forking\n");
127 printf(" --exec <command> run with the lifetime of that command\n");
128 printf("Client options, for talking to an existing agent:\n");
129 printf(" -a add key(s) to the existing agent\n");
130 printf(" -l list currently loaded key fingerprints and comments\n");
131 printf(" --public print public keys in RFC 4716 format\n");
132 printf(" --public-openssh print public keys in OpenSSH format\n");
133 printf(" -d delete key(s) from the agent\n");
134 printf(" -D delete all keys from the agent\n");
135 printf("Other options:\n");
136 printf(" -v verbose mode (in agent mode)\n");
140 static void version(void)
142 printf("pageant: %s\n", ver);
146 void keylist_update(void)
148 /* Nothing needs doing in Unix Pageant */
151 #define PAGEANT_DIR_PREFIX "/tmp/pageant"
153 const char *const appname = "Pageant";
155 static int time_to_die = FALSE;
157 /* Stub functions to permit linking against x11fwd.c. These never get
158 * used, because in LIFE_X11 mode we connect to the X server using a
159 * straightforward Socket and don't try to create an ersatz SSH
161 int sshfwd_write(struct ssh_channel *c, char *data, int len) { return 0; }
162 void sshfwd_write_eof(struct ssh_channel *c) { }
163 void sshfwd_unclean_close(struct ssh_channel *c, const char *err) { }
164 void sshfwd_unthrottle(struct ssh_channel *c, int bufsize) {}
165 Conf *sshfwd_get_conf(struct ssh_channel *c) { return NULL; }
166 void sshfwd_x11_sharing_handover(struct ssh_channel *c,
167 void *share_cs, void *share_chan,
168 const char *peer_addr, int peer_port,
169 int endian, int protomajor, int protominor,
170 const void *initial_data, int initial_len) {}
171 void sshfwd_x11_is_local(struct ssh_channel *c) {}
174 * These functions are part of the plug for our connection to the X
175 * display, so they do get called. They needn't actually do anything,
176 * except that x11_closing has to signal back to the main loop that
177 * it's time to terminate.
179 static void x11_log(Plug p, int type, SockAddr addr, int port,
180 const char *error_msg, int error_code) {}
181 static int x11_receive(Plug plug, int urgent, char *data, int len) {return 0;}
182 static void x11_sent(Plug plug, int bufsize) {}
183 static int x11_closing(Plug plug, const char *error_msg, int error_code,
189 struct X11Connection {
190 const struct plug_function_table *fn;
194 void pageant_print_env(int pid)
196 printf("SSH_AUTH_SOCK=%s; export SSH_AUTH_SOCK;\n"
197 "SSH_AGENT_PID=%d; export SSH_AGENT_PID;\n",
198 socketname, (int)pid);
201 void pageant_fork_and_print_env(int retain_tty)
207 } else if (pid != 0) {
208 pageant_print_env(pid);
213 * Having forked off, we now daemonise ourselves as best we can.
214 * It's good practice in general to setsid() ourself out of any
215 * process group we didn't want to be part of, and to chdir("/")
216 * to avoid holding any directories open that we don't need in
217 * case someone wants to umount them; also, we should definitely
218 * close standard output (because it will very likely be pointing
219 * at a pipe from which some parent process is trying to read our
220 * environment variable dump, so if we hold open another copy of
221 * it then that process will never finish reading). We close
222 * standard input too on general principles, but not standard
223 * error, since we might need to shout a panicky error message
226 if (chdir("/") < 0) {
227 /* should there be an error condition, nothing we can do about
233 /* Get out of our previous process group, to avoid being
234 * blasted by passing signals. But keep our controlling tty,
235 * so we can keep checking to see if we still have one. */
238 /* Do that, but also leave our entire session and detach from
239 * the controlling tty (if any). */
246 void sigchld(int signum)
248 if (write(signalpipe[1], "x", 1) <= 0)
249 /* not much we can do about it */;
252 #define TTY_LIFE_POLL_INTERVAL (TICKSPERSEC * 30)
253 void *dummy_timer_ctx;
254 static void tty_life_timer(void *ctx, unsigned long now)
256 schedule_timer(TTY_LIFE_POLL_INTERVAL, tty_life_timer, &dummy_timer_ctx);
263 KEYACT_CLIENT_DEL_ALL,
265 KEYACT_CLIENT_PUBLIC_OPENSSH,
268 struct cmdline_key_action {
269 struct cmdline_key_action *next;
271 const char *filename;
274 int is_agent_action(keyact action)
276 return action == KEYACT_AGENT_LOAD;
279 struct cmdline_key_action *keyact_head = NULL, *keyact_tail = NULL;
281 void add_keyact(keyact action, const char *filename)
283 struct cmdline_key_action *a = snew(struct cmdline_key_action);
285 a->filename = filename;
288 keyact_tail->next = a;
294 int have_controlling_tty(void)
296 int fd = open("/dev/tty", O_RDONLY);
298 if (errno != ENXIO) {
299 perror("/dev/tty: open");
309 char **exec_args = NULL;
311 LIFE_UNSPEC, LIFE_X11, LIFE_TTY, LIFE_DEBUG, LIFE_PERM, LIFE_EXEC
312 } life = LIFE_UNSPEC;
313 const char *display = NULL;
315 static char *askpass(const char *comment)
317 if (have_controlling_tty()) {
319 prompts_t *p = new_prompts(NULL);
320 p->to_server = FALSE;
321 p->name = dupstr("Pageant passphrase prompt");
323 dupprintf("Enter passphrase to load key '%s': ", comment),
325 ret = console_get_userpass_input(p, NULL, 0);
329 perror("pageant: unable to read passphrase");
333 char *passphrase = dupstr(p->prompts[0]->result);
337 } else if (display) {
338 char *prompt, *passphrase;
342 char *gtk_askpass_main(const char *display, const char *wintitle,
343 const char *prompt, int *success);
345 prompt = dupprintf("Enter passphrase to load key '%s': ", comment);
346 passphrase = gtk_askpass_main(display,
347 "Pageant passphrase prompt",
351 /* return value is error message */
352 fprintf(stderr, "%s\n", passphrase);
358 fprintf(stderr, "no way to read a passphrase without tty or "
364 static int unix_add_keyfile(const char *filename_str)
366 Filename *filename = filename_from_str(filename_str);
373 * Try without a passphrase.
375 status = pageant_add_keyfile(filename, NULL, &err);
376 if (status == PAGEANT_ACTION_OK) {
378 } else if (status == PAGEANT_ACTION_FAILURE) {
379 fprintf(stderr, "pageant: %s: %s\n", filename_str, err);
385 * And now try prompting for a passphrase.
388 char *passphrase = askpass(err);
394 status = pageant_add_keyfile(filename, passphrase, &err);
396 smemclr(passphrase, strlen(passphrase));
400 if (status == PAGEANT_ACTION_OK) {
402 } else if (status == PAGEANT_ACTION_FAILURE) {
403 fprintf(stderr, "pageant: %s: %s\n", filename_str, err);
411 filename_free(filename);
415 void key_list_callback(void *ctx, const char *fingerprint,
416 const char *comment, struct pageant_pubkey *key)
418 printf("%s %s\n", fingerprint, comment);
421 struct key_find_ctx {
423 int match_fp, match_comment;
424 struct pageant_pubkey *found;
428 int match_fingerprint_string(const char *string, const char *fingerprint)
432 /* Find the hash in the fingerprint string. It'll be the word at the end. */
433 hash = strrchr(fingerprint, ' ');
437 /* Now see if the search string is a prefix of the full hash,
438 * neglecting colons and case differences. */
440 while (*string == ':') string++;
441 while (*hash == ':') hash++;
444 if (tolower((unsigned char)*string) != tolower((unsigned char)*hash))
451 void key_find_callback(void *vctx, const char *fingerprint,
452 const char *comment, struct pageant_pubkey *key)
454 struct key_find_ctx *ctx = (struct key_find_ctx *)vctx;
456 if ((ctx->match_comment && !strcmp(ctx->string, comment)) ||
457 (ctx->match_fp && match_fingerprint_string(ctx->string, fingerprint)))
460 ctx->found = pageant_pubkey_copy(key);
465 struct pageant_pubkey *find_key(const char *string, char **retstr)
467 struct key_find_ctx actx, *ctx = &actx;
468 struct pageant_pubkey key_in, *key_ret;
469 int try_file = TRUE, try_fp = TRUE, try_comment = TRUE;
470 int file_errors = FALSE;
473 * Trim off disambiguating prefixes telling us how to interpret
474 * the provided string.
476 if (!strncmp(string, "file:", 5)) {
478 try_fp = try_comment = FALSE;
479 file_errors = TRUE; /* also report failure to load the file */
480 } else if (!strncmp(string, "comment:", 8)) {
482 try_file = try_fp = FALSE;
483 } else if (!strncmp(string, "fp:", 3)) {
485 try_file = try_comment = FALSE;
486 } else if (!strncmp(string, "fingerprint:", 12)) {
488 try_file = try_comment = FALSE;
492 * Try interpreting the string as a key file name.
495 Filename *fn = filename_from_str(string);
496 int keytype = key_type(fn);
497 if (keytype == SSH_KEYTYPE_SSH1 ||
498 keytype == SSH_KEYTYPE_SSH1_PUBLIC) {
501 if (!rsakey_pubblob(fn, &key_in.blob, &key_in.bloblen,
504 *retstr = dupprintf("unable to load file '%s': %s",
512 * If we've successfully loaded the file, stop here - we
513 * already have a key blob and need not go to the agent to
516 key_in.ssh_version = 1;
517 key_ret = pageant_pubkey_copy(&key_in);
521 } else if (keytype == SSH_KEYTYPE_SSH2 ||
522 keytype == SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 ||
523 keytype == SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH) {
526 if ((key_in.blob = ssh2_userkey_loadpub(fn, NULL,
528 NULL, &error)) == NULL) {
530 *retstr = dupprintf("unable to load file '%s': %s",
538 * If we've successfully loaded the file, stop here - we
539 * already have a key blob and need not go to the agent to
542 key_in.ssh_version = 2;
543 key_ret = pageant_pubkey_copy(&key_in);
549 *retstr = dupprintf("unable to load key file '%s': %s",
550 string, key_type_to_str(keytype));
559 * Failing that, go through the keys in the agent, and match
560 * against fingerprints and comments as appropriate.
562 ctx->string = string;
563 ctx->match_fp = try_fp;
564 ctx->match_comment = try_comment;
567 if (pageant_enum_keys(key_find_callback, ctx, retstr) ==
568 PAGEANT_ACTION_FAILURE)
571 if (ctx->nfound == 0) {
572 *retstr = dupstr("no key matched");
575 } else if (ctx->nfound > 1) {
576 *retstr = dupstr("multiple keys matched");
578 pageant_pubkey_free(ctx->found);
586 void run_client(void)
588 const struct cmdline_key_action *act;
589 struct pageant_pubkey *key;
593 if (!agent_exists()) {
594 fprintf(stderr, "pageant: no agent running to talk to\n");
598 for (act = keyact_head; act; act = act->next) {
599 switch (act->action) {
600 case KEYACT_CLIENT_ADD:
601 if (!unix_add_keyfile(act->filename))
604 case KEYACT_CLIENT_LIST:
605 if (pageant_enum_keys(key_list_callback, NULL, &retstr) ==
606 PAGEANT_ACTION_FAILURE) {
607 fprintf(stderr, "pageant: listing keys: %s\n", retstr);
612 case KEYACT_CLIENT_DEL:
614 if (!(key = find_key(act->filename, &retstr)) ||
615 pageant_delete_key(key, &retstr) == PAGEANT_ACTION_FAILURE) {
616 fprintf(stderr, "pageant: deleting key '%s': %s\n",
617 act->filename, retstr);
622 pageant_pubkey_free(key);
624 case KEYACT_CLIENT_PUBLIC_OPENSSH:
625 case KEYACT_CLIENT_PUBLIC:
627 if (!(key = find_key(act->filename, &retstr))) {
628 fprintf(stderr, "pageant: finding key '%s': %s\n",
629 act->filename, retstr);
633 FILE *fp = stdout; /* FIXME: add a -o option? */
635 if (key->ssh_version == 1) {
637 memset(&rkey, 0, sizeof(rkey));
638 rkey.comment = dupstr(key->comment);
639 makekey(key->blob, key->bloblen, &rkey, NULL, 0);
640 ssh1_write_pubkey(fp, &rkey);
643 ssh2_write_pubkey(fp, key->comment, key->blob,key->bloblen,
644 (act->action == KEYACT_CLIENT_PUBLIC ?
645 SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 :
646 SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH));
648 pageant_pubkey_free(key);
651 case KEYACT_CLIENT_DEL_ALL:
652 if (pageant_delete_all_keys(&retstr) == PAGEANT_ACTION_FAILURE) {
653 fprintf(stderr, "pageant: deleting all keys: %s\n", retstr);
659 assert(0 && "Invalid client action found");
670 char *username, *socketdir;
671 struct pageant_listen_state *pl;
676 int i, fdcount, fdsize, fdstate;
677 int termination_pid = -1;
680 const struct cmdline_key_action *act;
683 fdcount = fdsize = 0;
688 * Start by loading any keys provided on the command line.
690 for (act = keyact_head; act; act = act->next) {
691 assert(act->action == KEYACT_AGENT_LOAD);
692 if (!unix_add_keyfile(act->filename))
699 * Set up a listening socket and run Pageant on it.
701 username = get_username();
702 socketdir = dupprintf("%s.%s", PAGEANT_DIR_PREFIX, username);
704 assert(*socketdir == '/');
705 if ((err = make_dir_and_check_ours(socketdir)) != NULL) {
706 fprintf(stderr, "pageant: %s: %s\n", socketdir, err);
709 socketname = dupprintf("%s/pageant.%d", socketdir, (int)getpid());
710 pl = pageant_listener_new();
711 sock = new_unix_listener(unix_sock_addr(socketname), (Plug)pl);
712 if ((err = sk_socket_error(sock)) != NULL) {
713 fprintf(stderr, "pageant: %s: %s\n", socketname, err);
716 pageant_listener_got_socket(pl, sock);
719 conf_set_int(conf, CONF_proxy_type, PROXY_NONE);
722 * Lifetime preparations.
724 signalpipe[0] = signalpipe[1] = -1;
725 if (life == LIFE_X11) {
726 struct X11Display *disp;
730 struct X11Connection *conn;
732 static const struct plug_function_table fn_table = {
741 fprintf(stderr, "pageant: no DISPLAY for -X mode\n");
744 disp = x11_setup_display(display, conf);
746 conn = snew(struct X11Connection);
747 conn->fn = &fn_table;
748 s = new_connection(sk_addr_dup(disp->addr),
749 disp->realhost, disp->port,
750 0, 1, 0, 0, (Plug)conn, conf);
751 if ((err = sk_socket_error(s)) != NULL) {
752 fprintf(stderr, "pageant: unable to connect to X server: %s", err);
755 greeting = x11_make_greeting('B', 11, 0, disp->localauthproto,
757 disp->localauthdatalen,
758 NULL, 0, &greetinglen);
759 sk_write(s, greeting, greetinglen);
760 smemclr(greeting, greetinglen);
763 pageant_fork_and_print_env(FALSE);
764 } else if (life == LIFE_TTY) {
765 schedule_timer(TTY_LIFE_POLL_INTERVAL,
766 tty_life_timer, &dummy_timer_ctx);
767 pageant_fork_and_print_env(TRUE);
768 } else if (life == LIFE_PERM) {
769 pageant_fork_and_print_env(FALSE);
770 } else if (life == LIFE_DEBUG) {
771 pageant_print_env(getpid());
772 pageant_logfp = stdout;
773 } else if (life == LIFE_EXEC) {
779 * Set up the pipe we'll use to tell us about SIGCHLD.
781 if (pipe(signalpipe) < 0) {
785 putty_signal(SIGCHLD, sigchld);
791 } else if (pid == 0) {
792 setenv("SSH_AUTH_SOCK", socketname, TRUE);
793 setenv("SSH_AGENT_PID", dupprintf("%d", (int)agentpid), TRUE);
794 execvp(exec_args[0], exec_args);
798 termination_pid = pid;
803 * Now we've decided on our logging arrangements, pass them on to
806 pageant_listener_set_logfn(pl, NULL, pageant_logfp ? pageant_log : NULL);
808 now = GETTICKCOUNT();
810 while (!time_to_die) {
811 fd_set rset, wset, xset;
822 if (signalpipe[0] >= 0) {
823 FD_SET_MAX(signalpipe[0], maxfd, rset);
826 /* Count the currently active fds. */
828 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
829 fd = next_fd(&fdstate, &rwx)) i++;
831 /* Expand the fdlist buffer if necessary. */
834 fdlist = sresize(fdlist, fdsize, int);
838 * Add all currently open fds to the select sets, and store
839 * them in fdlist as well.
842 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
843 fd = next_fd(&fdstate, &rwx)) {
844 fdlist[fdcount++] = fd;
846 FD_SET_MAX(fd, maxfd, rset);
848 FD_SET_MAX(fd, maxfd, wset);
850 FD_SET_MAX(fd, maxfd, xset);
853 if (toplevel_callback_pending()) {
857 ret = select(maxfd, &rset, &wset, &xset, &tv);
858 } else if (run_timers(now, &next)) {
864 now = GETTICKCOUNT();
865 if (now - then > next - then)
869 tv.tv_sec = ticks / 1000;
870 tv.tv_usec = ticks % 1000 * 1000;
871 ret = select(maxfd, &rset, &wset, &xset, &tv);
875 now = GETTICKCOUNT();
877 ret = select(maxfd, &rset, &wset, &xset, NULL);
880 if (ret < 0 && errno == EINTR)
888 if (life == LIFE_TTY) {
890 * Every time we wake up (whether it was due to tty_timer
891 * elapsing or for any other reason), poll to see if we
892 * still have a controlling terminal. If we don't, then
893 * our containing tty session has ended, so it's time to
894 * clean up and leave.
896 if (!have_controlling_tty()) {
902 for (i = 0; i < fdcount; i++) {
905 * We must process exceptional notifications before
906 * ordinary readability ones, or we may go straight
907 * past the urgent marker.
909 if (FD_ISSET(fd, &xset))
910 select_result(fd, 4);
911 if (FD_ISSET(fd, &rset))
912 select_result(fd, 1);
913 if (FD_ISSET(fd, &wset))
914 select_result(fd, 2);
917 if (signalpipe[0] >= 0 && FD_ISSET(signalpipe[0], &rset)) {
919 if (read(signalpipe[0], c, 1) <= 0)
921 /* ignore its value; it'll be `x' */
925 pid = waitpid(-1, &status, WNOHANG);
928 if (pid == termination_pid)
933 run_toplevel_callbacks();
937 * When we come here, we're terminating, and should clean up our
938 * Unix socket file if possible.
940 if (unlink(socketname) < 0) {
941 fprintf(stderr, "pageant: %s: %s\n", socketname, strerror(errno));
946 int main(int argc, char **argv)
948 int doing_opts = TRUE;
949 keyact curr_keyact = KEYACT_AGENT_LOAD;
952 * Process the command line.
956 if (*p == '-' && doing_opts) {
957 if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
959 } else if (!strcmp(p, "--help")) {
962 } else if (!strcmp(p, "-v")) {
963 pageant_logfp = stderr;
964 } else if (!strcmp(p, "-a")) {
965 curr_keyact = KEYACT_CLIENT_ADD;
966 } else if (!strcmp(p, "-d")) {
967 curr_keyact = KEYACT_CLIENT_DEL;
968 } else if (!strcmp(p, "-D")) {
969 add_keyact(KEYACT_CLIENT_DEL_ALL, NULL);
970 } else if (!strcmp(p, "-l")) {
971 add_keyact(KEYACT_CLIENT_LIST, NULL);
972 } else if (!strcmp(p, "--public")) {
973 curr_keyact = KEYACT_CLIENT_PUBLIC;
974 } else if (!strcmp(p, "--public-openssh")) {
975 curr_keyact = KEYACT_CLIENT_PUBLIC_OPENSSH;
976 } else if (!strcmp(p, "-X")) {
978 } else if (!strcmp(p, "-T")) {
980 } else if (!strcmp(p, "--debug")) {
982 } else if (!strcmp(p, "--permanent")) {
984 } else if (!strcmp(p, "--exec")) {
986 /* Now all subsequent arguments go to the exec command. */
989 argc = 0; /* force end of option processing */
991 fprintf(stderr, "pageant: expected a command "
995 } else if (!strcmp(p, "--")) {
1000 * Non-option arguments (apart from those after --exec,
1001 * which are treated specially above) are interpreted as
1002 * the names of private key files to either add or delete
1005 add_keyact(curr_keyact, p);
1009 if (life == LIFE_EXEC && !exec_args) {
1010 fprintf(stderr, "pageant: expected a command with --exec\n");
1015 * Block SIGPIPE, so that we'll get EPIPE individually on
1016 * particular network connections that go wrong.
1018 putty_signal(SIGPIPE, SIG_IGN);
1024 display = getenv("DISPLAY");
1025 if (display && !*display)
1030 * Now distinguish our two main running modes. Either we're
1031 * actually starting up an agent, in which case we should have a
1032 * lifetime mode, and no key actions of KEYACT_CLIENT_* type; or
1033 * else we're contacting an existing agent to add or remove keys,
1034 * in which case we should have no lifetime mode, and no key
1035 * actions of KEYACT_AGENT_* type.
1038 int has_agent_actions = FALSE;
1039 int has_client_actions = FALSE;
1040 int has_lifetime = FALSE;
1041 const struct cmdline_key_action *act;
1043 for (act = keyact_head; act; act = act->next) {
1044 if (is_agent_action(act->action))
1045 has_agent_actions = TRUE;
1047 has_client_actions = TRUE;
1049 if (life != LIFE_UNSPEC)
1050 has_lifetime = TRUE;
1052 if (has_lifetime && has_client_actions) {
1053 fprintf(stderr, "pageant: client key actions (-a, -d, -D, -l, -L)"
1054 " do not go with an agent lifetime option\n");
1057 if (!has_lifetime && has_agent_actions) {
1058 fprintf(stderr, "pageant: expected an agent lifetime option with"
1059 " bare key file arguments\n");
1062 if (!has_lifetime && !has_client_actions) {
1063 fprintf(stderr, "pageant: expected an agent lifetime option"
1064 " or a client key action\n");
1070 } else if (has_client_actions) {