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) {}
106 int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
107 { assert(!"only here to satisfy notional call from backend_socket_log"); }
110 * Short description of parameters.
112 static void usage(void)
114 printf("Pageant: SSH agent\n");
116 printf("Usage: pageant <lifetime> [key files]\n");
117 printf(" pageant [key files] --exec <command> [args]\n");
118 printf(" pageant -a [key files]\n");
119 printf(" pageant -d [key identifiers]\n");
120 printf(" pageant --public [key identifiers]\n");
121 printf(" pageant --public-openssh [key identifiers]\n");
122 printf(" pageant -l\n");
123 printf(" pageant -D\n");
124 printf("Lifetime options, for running Pageant as an agent:\n");
125 printf(" -X run with the lifetime of the X server\n");
126 printf(" -T run with the lifetime of the controlling tty\n");
127 printf(" --permanent run permanently\n");
128 printf(" --debug run in debugging mode, without forking\n");
129 printf(" --exec <command> run with the lifetime of that command\n");
130 printf("Client options, for talking to an existing agent:\n");
131 printf(" -a add key(s) to the existing agent\n");
132 printf(" -l list currently loaded key fingerprints and comments\n");
133 printf(" --public print public keys in RFC 4716 format\n");
134 printf(" --public-openssh print public keys in OpenSSH format\n");
135 printf(" -d delete key(s) from the agent\n");
136 printf(" -D delete all keys from the agent\n");
137 printf("Other options:\n");
138 printf(" -v verbose mode (in agent mode)\n");
142 static void version(void)
144 printf("pageant: %s\n", ver);
148 void keylist_update(void)
150 /* Nothing needs doing in Unix Pageant */
153 #define PAGEANT_DIR_PREFIX "/tmp/pageant"
155 const char *const appname = "Pageant";
157 static int time_to_die = FALSE;
159 /* Stub functions to permit linking against x11fwd.c. These never get
160 * used, because in LIFE_X11 mode we connect to the X server using a
161 * straightforward Socket and don't try to create an ersatz SSH
163 int sshfwd_write(struct ssh_channel *c, char *data, int len) { return 0; }
164 void sshfwd_write_eof(struct ssh_channel *c) { }
165 void sshfwd_unclean_close(struct ssh_channel *c, const char *err) { }
166 void sshfwd_unthrottle(struct ssh_channel *c, int bufsize) {}
167 Conf *sshfwd_get_conf(struct ssh_channel *c) { return NULL; }
168 void sshfwd_x11_sharing_handover(struct ssh_channel *c,
169 void *share_cs, void *share_chan,
170 const char *peer_addr, int peer_port,
171 int endian, int protomajor, int protominor,
172 const void *initial_data, int initial_len) {}
173 void sshfwd_x11_is_local(struct ssh_channel *c) {}
176 * These functions are part of the plug for our connection to the X
177 * display, so they do get called. They needn't actually do anything,
178 * except that x11_closing has to signal back to the main loop that
179 * it's time to terminate.
181 static void x11_log(Plug p, int type, SockAddr addr, int port,
182 const char *error_msg, int error_code) {}
183 static int x11_receive(Plug plug, int urgent, char *data, int len) {return 0;}
184 static void x11_sent(Plug plug, int bufsize) {}
185 static int x11_closing(Plug plug, const char *error_msg, int error_code,
191 struct X11Connection {
192 const struct plug_function_table *fn;
196 void pageant_print_env(int pid)
198 printf("SSH_AUTH_SOCK=%s; export SSH_AUTH_SOCK;\n"
199 "SSH_AGENT_PID=%d; export SSH_AGENT_PID;\n",
200 socketname, (int)pid);
203 void pageant_fork_and_print_env(int retain_tty)
209 } else if (pid != 0) {
210 pageant_print_env(pid);
215 * Having forked off, we now daemonise ourselves as best we can.
216 * It's good practice in general to setsid() ourself out of any
217 * process group we didn't want to be part of, and to chdir("/")
218 * to avoid holding any directories open that we don't need in
219 * case someone wants to umount them; also, we should definitely
220 * close standard output (because it will very likely be pointing
221 * at a pipe from which some parent process is trying to read our
222 * environment variable dump, so if we hold open another copy of
223 * it then that process will never finish reading). We close
224 * standard input too on general principles, but not standard
225 * error, since we might need to shout a panicky error message
228 if (chdir("/") < 0) {
229 /* should there be an error condition, nothing we can do about
235 /* Get out of our previous process group, to avoid being
236 * blasted by passing signals. But keep our controlling tty,
237 * so we can keep checking to see if we still have one. */
240 /* Do that, but also leave our entire session and detach from
241 * the controlling tty (if any). */
248 void sigchld(int signum)
250 if (write(signalpipe[1], "x", 1) <= 0)
251 /* not much we can do about it */;
254 #define TTY_LIFE_POLL_INTERVAL (TICKSPERSEC * 30)
255 void *dummy_timer_ctx;
256 static void tty_life_timer(void *ctx, unsigned long now)
258 schedule_timer(TTY_LIFE_POLL_INTERVAL, tty_life_timer, &dummy_timer_ctx);
265 KEYACT_CLIENT_DEL_ALL,
267 KEYACT_CLIENT_PUBLIC_OPENSSH,
270 struct cmdline_key_action {
271 struct cmdline_key_action *next;
273 const char *filename;
276 int is_agent_action(keyact action)
278 return action == KEYACT_AGENT_LOAD;
281 struct cmdline_key_action *keyact_head = NULL, *keyact_tail = NULL;
283 void add_keyact(keyact action, const char *filename)
285 struct cmdline_key_action *a = snew(struct cmdline_key_action);
287 a->filename = filename;
290 keyact_tail->next = a;
296 int have_controlling_tty(void)
298 int fd = open("/dev/tty", O_RDONLY);
300 if (errno != ENXIO) {
301 perror("/dev/tty: open");
311 char **exec_args = NULL;
313 LIFE_UNSPEC, LIFE_X11, LIFE_TTY, LIFE_DEBUG, LIFE_PERM, LIFE_EXEC
314 } life = LIFE_UNSPEC;
315 const char *display = NULL;
317 static char *askpass(const char *comment)
319 if (have_controlling_tty()) {
321 prompts_t *p = new_prompts(NULL);
322 p->to_server = FALSE;
323 p->name = dupstr("Pageant passphrase prompt");
325 dupprintf("Enter passphrase to load key '%s': ", comment),
327 ret = console_get_userpass_input(p, NULL, 0);
331 perror("pageant: unable to read passphrase");
335 char *passphrase = dupstr(p->prompts[0]->result);
339 } else if (display) {
340 char *prompt, *passphrase;
344 char *gtk_askpass_main(const char *display, const char *wintitle,
345 const char *prompt, int *success);
347 prompt = dupprintf("Enter passphrase to load key '%s': ", comment);
348 passphrase = gtk_askpass_main(display,
349 "Pageant passphrase prompt",
353 /* return value is error message */
354 fprintf(stderr, "%s\n", passphrase);
360 fprintf(stderr, "no way to read a passphrase without tty or "
366 static int unix_add_keyfile(const char *filename_str)
368 Filename *filename = filename_from_str(filename_str);
375 * Try without a passphrase.
377 status = pageant_add_keyfile(filename, NULL, &err);
378 if (status == PAGEANT_ACTION_OK) {
380 } else if (status == PAGEANT_ACTION_FAILURE) {
381 fprintf(stderr, "pageant: %s: %s\n", filename_str, err);
387 * And now try prompting for a passphrase.
390 char *passphrase = askpass(err);
396 status = pageant_add_keyfile(filename, passphrase, &err);
398 smemclr(passphrase, strlen(passphrase));
402 if (status == PAGEANT_ACTION_OK) {
404 } else if (status == PAGEANT_ACTION_FAILURE) {
405 fprintf(stderr, "pageant: %s: %s\n", filename_str, err);
413 filename_free(filename);
417 void key_list_callback(void *ctx, const char *fingerprint,
418 const char *comment, struct pageant_pubkey *key)
420 printf("%s %s\n", fingerprint, comment);
423 struct key_find_ctx {
425 int match_fp, match_comment;
426 struct pageant_pubkey *found;
430 int match_fingerprint_string(const char *string, const char *fingerprint)
434 /* Find the hash in the fingerprint string. It'll be the word at the end. */
435 hash = strrchr(fingerprint, ' ');
439 /* Now see if the search string is a prefix of the full hash,
440 * neglecting colons and case differences. */
442 while (*string == ':') string++;
443 while (*hash == ':') hash++;
446 if (tolower((unsigned char)*string) != tolower((unsigned char)*hash))
453 void key_find_callback(void *vctx, const char *fingerprint,
454 const char *comment, struct pageant_pubkey *key)
456 struct key_find_ctx *ctx = (struct key_find_ctx *)vctx;
458 if ((ctx->match_comment && !strcmp(ctx->string, comment)) ||
459 (ctx->match_fp && match_fingerprint_string(ctx->string, fingerprint)))
462 ctx->found = pageant_pubkey_copy(key);
467 struct pageant_pubkey *find_key(const char *string, char **retstr)
469 struct key_find_ctx actx, *ctx = &actx;
470 struct pageant_pubkey key_in, *key_ret;
471 int try_file = TRUE, try_fp = TRUE, try_comment = TRUE;
472 int file_errors = FALSE;
475 * Trim off disambiguating prefixes telling us how to interpret
476 * the provided string.
478 if (!strncmp(string, "file:", 5)) {
480 try_fp = try_comment = FALSE;
481 file_errors = TRUE; /* also report failure to load the file */
482 } else if (!strncmp(string, "comment:", 8)) {
484 try_file = try_fp = FALSE;
485 } else if (!strncmp(string, "fp:", 3)) {
487 try_file = try_comment = FALSE;
488 } else if (!strncmp(string, "fingerprint:", 12)) {
490 try_file = try_comment = FALSE;
494 * Try interpreting the string as a key file name.
497 Filename *fn = filename_from_str(string);
498 int keytype = key_type(fn);
499 if (keytype == SSH_KEYTYPE_SSH1 ||
500 keytype == SSH_KEYTYPE_SSH1_PUBLIC) {
503 if (!rsakey_pubblob(fn, &key_in.blob, &key_in.bloblen,
506 *retstr = dupprintf("unable to load file '%s': %s",
514 * If we've successfully loaded the file, stop here - we
515 * already have a key blob and need not go to the agent to
518 key_in.ssh_version = 1;
519 key_ret = pageant_pubkey_copy(&key_in);
523 } else if (keytype == SSH_KEYTYPE_SSH2 ||
524 keytype == SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 ||
525 keytype == SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH) {
528 if ((key_in.blob = ssh2_userkey_loadpub(fn, NULL,
530 NULL, &error)) == NULL) {
532 *retstr = dupprintf("unable to load file '%s': %s",
540 * If we've successfully loaded the file, stop here - we
541 * already have a key blob and need not go to the agent to
544 key_in.ssh_version = 2;
545 key_ret = pageant_pubkey_copy(&key_in);
551 *retstr = dupprintf("unable to load key file '%s': %s",
552 string, key_type_to_str(keytype));
561 * Failing that, go through the keys in the agent, and match
562 * against fingerprints and comments as appropriate.
564 ctx->string = string;
565 ctx->match_fp = try_fp;
566 ctx->match_comment = try_comment;
569 if (pageant_enum_keys(key_find_callback, ctx, retstr) ==
570 PAGEANT_ACTION_FAILURE)
573 if (ctx->nfound == 0) {
574 *retstr = dupstr("no key matched");
577 } else if (ctx->nfound > 1) {
578 *retstr = dupstr("multiple keys matched");
580 pageant_pubkey_free(ctx->found);
588 void run_client(void)
590 const struct cmdline_key_action *act;
591 struct pageant_pubkey *key;
595 if (!agent_exists()) {
596 fprintf(stderr, "pageant: no agent running to talk to\n");
600 for (act = keyact_head; act; act = act->next) {
601 switch (act->action) {
602 case KEYACT_CLIENT_ADD:
603 if (!unix_add_keyfile(act->filename))
606 case KEYACT_CLIENT_LIST:
607 if (pageant_enum_keys(key_list_callback, NULL, &retstr) ==
608 PAGEANT_ACTION_FAILURE) {
609 fprintf(stderr, "pageant: listing keys: %s\n", retstr);
614 case KEYACT_CLIENT_DEL:
616 if (!(key = find_key(act->filename, &retstr)) ||
617 pageant_delete_key(key, &retstr) == PAGEANT_ACTION_FAILURE) {
618 fprintf(stderr, "pageant: deleting key '%s': %s\n",
619 act->filename, retstr);
624 pageant_pubkey_free(key);
626 case KEYACT_CLIENT_PUBLIC_OPENSSH:
627 case KEYACT_CLIENT_PUBLIC:
629 if (!(key = find_key(act->filename, &retstr))) {
630 fprintf(stderr, "pageant: finding key '%s': %s\n",
631 act->filename, retstr);
635 FILE *fp = stdout; /* FIXME: add a -o option? */
637 if (key->ssh_version == 1) {
639 memset(&rkey, 0, sizeof(rkey));
640 rkey.comment = dupstr(key->comment);
641 makekey(key->blob, key->bloblen, &rkey, NULL, 0);
642 ssh1_write_pubkey(fp, &rkey);
645 ssh2_write_pubkey(fp, key->comment, key->blob,key->bloblen,
646 (act->action == KEYACT_CLIENT_PUBLIC ?
647 SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 :
648 SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH));
650 pageant_pubkey_free(key);
653 case KEYACT_CLIENT_DEL_ALL:
654 if (pageant_delete_all_keys(&retstr) == PAGEANT_ACTION_FAILURE) {
655 fprintf(stderr, "pageant: deleting all keys: %s\n", retstr);
661 assert(0 && "Invalid client action found");
672 char *username, *socketdir;
673 struct pageant_listen_state *pl;
678 int i, fdcount, fdsize, fdstate;
679 int termination_pid = -1;
682 const struct cmdline_key_action *act;
685 fdcount = fdsize = 0;
690 * Start by loading any keys provided on the command line.
692 for (act = keyact_head; act; act = act->next) {
693 assert(act->action == KEYACT_AGENT_LOAD);
694 if (!unix_add_keyfile(act->filename))
701 * Set up a listening socket and run Pageant on it.
703 username = get_username();
704 socketdir = dupprintf("%s.%s", PAGEANT_DIR_PREFIX, username);
706 assert(*socketdir == '/');
707 if ((err = make_dir_and_check_ours(socketdir)) != NULL) {
708 fprintf(stderr, "pageant: %s: %s\n", socketdir, err);
711 socketname = dupprintf("%s/pageant.%d", socketdir, (int)getpid());
712 pl = pageant_listener_new();
713 sock = new_unix_listener(unix_sock_addr(socketname), (Plug)pl);
714 if ((err = sk_socket_error(sock)) != NULL) {
715 fprintf(stderr, "pageant: %s: %s\n", socketname, err);
718 pageant_listener_got_socket(pl, sock);
721 conf_set_int(conf, CONF_proxy_type, PROXY_NONE);
724 * Lifetime preparations.
726 signalpipe[0] = signalpipe[1] = -1;
727 if (life == LIFE_X11) {
728 struct X11Display *disp;
732 struct X11Connection *conn;
734 static const struct plug_function_table fn_table = {
743 fprintf(stderr, "pageant: no DISPLAY for -X mode\n");
746 disp = x11_setup_display(display, conf);
748 conn = snew(struct X11Connection);
749 conn->fn = &fn_table;
750 s = new_connection(sk_addr_dup(disp->addr),
751 disp->realhost, disp->port,
752 0, 1, 0, 0, (Plug)conn, conf);
753 if ((err = sk_socket_error(s)) != NULL) {
754 fprintf(stderr, "pageant: unable to connect to X server: %s", err);
757 greeting = x11_make_greeting('B', 11, 0, disp->localauthproto,
759 disp->localauthdatalen,
760 NULL, 0, &greetinglen);
761 sk_write(s, greeting, greetinglen);
762 smemclr(greeting, greetinglen);
765 pageant_fork_and_print_env(FALSE);
766 } else if (life == LIFE_TTY) {
767 schedule_timer(TTY_LIFE_POLL_INTERVAL,
768 tty_life_timer, &dummy_timer_ctx);
769 pageant_fork_and_print_env(TRUE);
770 } else if (life == LIFE_PERM) {
771 pageant_fork_and_print_env(FALSE);
772 } else if (life == LIFE_DEBUG) {
773 pageant_print_env(getpid());
774 pageant_logfp = stdout;
775 } else if (life == LIFE_EXEC) {
781 * Set up the pipe we'll use to tell us about SIGCHLD.
783 if (pipe(signalpipe) < 0) {
787 putty_signal(SIGCHLD, sigchld);
793 } else if (pid == 0) {
794 setenv("SSH_AUTH_SOCK", socketname, TRUE);
795 setenv("SSH_AGENT_PID", dupprintf("%d", (int)agentpid), TRUE);
796 execvp(exec_args[0], exec_args);
800 termination_pid = pid;
805 * Now we've decided on our logging arrangements, pass them on to
808 pageant_listener_set_logfn(pl, NULL, pageant_logfp ? pageant_log : NULL);
810 now = GETTICKCOUNT();
812 while (!time_to_die) {
813 fd_set rset, wset, xset;
824 if (signalpipe[0] >= 0) {
825 FD_SET_MAX(signalpipe[0], maxfd, rset);
828 /* Count the currently active fds. */
830 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
831 fd = next_fd(&fdstate, &rwx)) i++;
833 /* Expand the fdlist buffer if necessary. */
836 fdlist = sresize(fdlist, fdsize, int);
840 * Add all currently open fds to the select sets, and store
841 * them in fdlist as well.
844 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
845 fd = next_fd(&fdstate, &rwx)) {
846 fdlist[fdcount++] = fd;
848 FD_SET_MAX(fd, maxfd, rset);
850 FD_SET_MAX(fd, maxfd, wset);
852 FD_SET_MAX(fd, maxfd, xset);
855 if (toplevel_callback_pending()) {
859 ret = select(maxfd, &rset, &wset, &xset, &tv);
860 } else if (run_timers(now, &next)) {
866 now = GETTICKCOUNT();
867 if (now - then > next - then)
871 tv.tv_sec = ticks / 1000;
872 tv.tv_usec = ticks % 1000 * 1000;
873 ret = select(maxfd, &rset, &wset, &xset, &tv);
877 now = GETTICKCOUNT();
879 ret = select(maxfd, &rset, &wset, &xset, NULL);
882 if (ret < 0 && errno == EINTR)
890 if (life == LIFE_TTY) {
892 * Every time we wake up (whether it was due to tty_timer
893 * elapsing or for any other reason), poll to see if we
894 * still have a controlling terminal. If we don't, then
895 * our containing tty session has ended, so it's time to
896 * clean up and leave.
898 if (!have_controlling_tty()) {
904 for (i = 0; i < fdcount; i++) {
907 * We must process exceptional notifications before
908 * ordinary readability ones, or we may go straight
909 * past the urgent marker.
911 if (FD_ISSET(fd, &xset))
912 select_result(fd, 4);
913 if (FD_ISSET(fd, &rset))
914 select_result(fd, 1);
915 if (FD_ISSET(fd, &wset))
916 select_result(fd, 2);
919 if (signalpipe[0] >= 0 && FD_ISSET(signalpipe[0], &rset)) {
921 if (read(signalpipe[0], c, 1) <= 0)
923 /* ignore its value; it'll be `x' */
927 pid = waitpid(-1, &status, WNOHANG);
930 if (pid == termination_pid)
935 run_toplevel_callbacks();
939 * When we come here, we're terminating, and should clean up our
940 * Unix socket file if possible.
942 if (unlink(socketname) < 0) {
943 fprintf(stderr, "pageant: %s: %s\n", socketname, strerror(errno));
948 int main(int argc, char **argv)
950 int doing_opts = TRUE;
951 keyact curr_keyact = KEYACT_AGENT_LOAD;
954 * Process the command line.
958 if (*p == '-' && doing_opts) {
959 if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
961 } else if (!strcmp(p, "--help")) {
964 } else if (!strcmp(p, "-v")) {
965 pageant_logfp = stderr;
966 } else if (!strcmp(p, "-a")) {
967 curr_keyact = KEYACT_CLIENT_ADD;
968 } else if (!strcmp(p, "-d")) {
969 curr_keyact = KEYACT_CLIENT_DEL;
970 } else if (!strcmp(p, "-D")) {
971 add_keyact(KEYACT_CLIENT_DEL_ALL, NULL);
972 } else if (!strcmp(p, "-l")) {
973 add_keyact(KEYACT_CLIENT_LIST, NULL);
974 } else if (!strcmp(p, "--public")) {
975 curr_keyact = KEYACT_CLIENT_PUBLIC;
976 } else if (!strcmp(p, "--public-openssh")) {
977 curr_keyact = KEYACT_CLIENT_PUBLIC_OPENSSH;
978 } else if (!strcmp(p, "-X")) {
980 } else if (!strcmp(p, "-T")) {
982 } else if (!strcmp(p, "--debug")) {
984 } else if (!strcmp(p, "--permanent")) {
986 } else if (!strcmp(p, "--exec")) {
988 /* Now all subsequent arguments go to the exec command. */
991 argc = 0; /* force end of option processing */
993 fprintf(stderr, "pageant: expected a command "
997 } else if (!strcmp(p, "--")) {
1002 * Non-option arguments (apart from those after --exec,
1003 * which are treated specially above) are interpreted as
1004 * the names of private key files to either add or delete
1007 add_keyact(curr_keyact, p);
1011 if (life == LIFE_EXEC && !exec_args) {
1012 fprintf(stderr, "pageant: expected a command with --exec\n");
1017 * Block SIGPIPE, so that we'll get EPIPE individually on
1018 * particular network connections that go wrong.
1020 putty_signal(SIGPIPE, SIG_IGN);
1026 display = getenv("DISPLAY");
1027 if (display && !*display)
1032 * Now distinguish our two main running modes. Either we're
1033 * actually starting up an agent, in which case we should have a
1034 * lifetime mode, and no key actions of KEYACT_CLIENT_* type; or
1035 * else we're contacting an existing agent to add or remove keys,
1036 * in which case we should have no lifetime mode, and no key
1037 * actions of KEYACT_AGENT_* type.
1040 int has_agent_actions = FALSE;
1041 int has_client_actions = FALSE;
1042 int has_lifetime = FALSE;
1043 const struct cmdline_key_action *act;
1045 for (act = keyact_head; act; act = act->next) {
1046 if (is_agent_action(act->action))
1047 has_agent_actions = TRUE;
1049 has_client_actions = TRUE;
1051 if (life != LIFE_UNSPEC)
1052 has_lifetime = TRUE;
1054 if (has_lifetime && has_client_actions) {
1055 fprintf(stderr, "pageant: client key actions (-a, -d, -D, -l, -L)"
1056 " do not go with an agent lifetime option\n");
1059 if (!has_lifetime && has_agent_actions) {
1060 fprintf(stderr, "pageant: expected an agent lifetime option with"
1061 " bare key file arguments\n");
1064 if (!has_lifetime && !has_client_actions) {
1065 fprintf(stderr, "pageant: expected an agent lifetime option"
1066 " or a client key action\n");
1072 } else if (has_client_actions) {