1 /* $NetBSD: postconf_other.c,v 1.2 2017/02/14 01:16:46 christos Exp $ */ 2 3 /*++ 4 /* NAME 5 /* postconf_other 3 6 /* SUMMARY 7 /* support for miscellaneous information categories 8 /* SYNOPSIS 9 /* #include <postconf.h> 10 /* 11 /* void pcf_show_maps() 12 /* 13 /* void pcf_show_locks() 14 /* 15 /* void pcf_show_sasl(mode) 16 /* int mode; 17 /* 18 /* void pcf_show_tls(what) 19 /* const char *what; 20 /* DESCRIPTION 21 /* pcf_show_maps() lists the available map (lookup table) 22 /* types. 23 /* 24 /* pcf_show_locks() lists the available mailbox lock types. 25 /* 26 /* pcf_show_sasl() shows the available SASL authentication 27 /* plugin types. 28 /* 29 /* pcf_show_tls() reports the "compile-version" or "run-version" 30 /* of the TLS library, or the supported public-key algorithms. 31 /* 32 /* Arguments: 33 /* .IP mode 34 /* Show server information if the PCF_SHOW_SASL_SERV flag is 35 /* set, otherwise show client information. 36 /* .IP what 37 /* One of the literals "compile-version", "run-version" or 38 /* "public-key-algorithms". 39 /* DIAGNOSTICS 40 /* Problems are reported to the standard error stream. 41 /* LICENSE 42 /* .ad 43 /* .fi 44 /* The Secure Mailer license must be distributed with this software. 45 /* AUTHOR(S) 46 /* Wietse Venema 47 /* IBM T.J. Watson Research 48 /* P.O. Box 704 49 /* Yorktown Heights, NY 10598, USA 50 /* 51 /* Wietse Venema 52 /* Google, Inc. 53 /* 111 8th Avenue 54 /* New York, NY 10011, USA 55 /*--*/ 56 57 /* System library. */ 58 59 #include <sys_defs.h> 60 61 /* Utility library. */ 62 63 #include <vstream.h> 64 #include <argv.h> 65 #include <dict.h> 66 #include <msg.h> 67 68 /* Global library. */ 69 70 #include <mbox_conf.h> 71 72 /* XSASL library. */ 73 74 #include <xsasl.h> 75 76 /* TLS library. */ 77 78 #include <tls.h> 79 80 /* Application-specific. */ 81 82 #include <postconf.h> 83 84 /* pcf_show_maps - show available maps */ 85 86 void pcf_show_maps(void) 87 { 88 ARGV *maps_argv; 89 int i; 90 91 maps_argv = dict_mapnames(); 92 for (i = 0; i < maps_argv->argc; i++) 93 vstream_printf("%s\n", maps_argv->argv[i]); 94 argv_free(maps_argv); 95 } 96 97 /* pcf_show_locks - show available mailbox locking methods */ 98 99 void pcf_show_locks(void) 100 { 101 ARGV *locks_argv; 102 int i; 103 104 locks_argv = mbox_lock_names(); 105 for (i = 0; i < locks_argv->argc; i++) 106 vstream_printf("%s\n", locks_argv->argv[i]); 107 argv_free(locks_argv); 108 } 109 110 /* pcf_show_sasl - show SASL plug-in types */ 111 112 void pcf_show_sasl(int what) 113 { 114 ARGV *sasl_argv; 115 int i; 116 117 sasl_argv = (what & PCF_SHOW_SASL_SERV) ? xsasl_server_types() : 118 xsasl_client_types(); 119 for (i = 0; i < sasl_argv->argc; i++) 120 vstream_printf("%s\n", sasl_argv->argv[i]); 121 argv_free(sasl_argv); 122 } 123 124 /* pcf_show_tls - show TLS support */ 125 126 void pcf_show_tls(const char *what) 127 { 128 #ifdef USE_TLS 129 if (strcmp(what, "compile-version") == 0) 130 vstream_printf("%s\n", tls_compile_version()); 131 else if (strcmp(what, "run-version") == 0) 132 vstream_printf("%s\n", tls_run_version()); 133 else if (strcmp(what, "public-key-algorithms") == 0) { 134 const char **cpp; 135 136 for (cpp = tls_pkey_algorithms(); *cpp; cpp++) 137 vstream_printf("%s\n", *cpp); 138 } else { 139 msg_warn("unknown 'postconf -T' mode: %s", what); 140 exit(1); 141 } 142 #endif /* USE_TLS */ 143 } 144