list.c (78527) | list.c (90926) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1997 - 2001 Kungliga Tekniska H�gskolan | 2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan |
3 * (Royal Institute of Technology, Stockholm, Sweden). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include "ktutil_locl.h" 35 | 3 * (Royal Institute of Technology, Stockholm, Sweden). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include "ktutil_locl.h" 35 |
36RCSID("$Id: list.c,v 1.8 2001/05/11 00:54:01 assar Exp $"); | 36RCSID("$Id: list.c,v 1.10 2002/01/30 10:12:21 joda Exp $"); |
37 38static int help_flag; 39static int list_keys; 40static int list_timestamp; 41 42static struct getargs args[] = { 43 { "help", 'h', arg_flag, &help_flag }, 44 { "keys", 0, arg_flag, &list_keys, "show key value" }, --- 21 unchanged lines hidden (view full) --- 66 struct key_info *ki, **kie = &ki, *kp; 67 68 int max_version = sizeof("Vno") - 1; 69 int max_etype = sizeof("Type") - 1; 70 int max_principal = sizeof("Principal") - 1; 71 int max_timestamp = sizeof("Date") - 1; 72 int max_key = sizeof("Key") - 1; 73 | 37 38static int help_flag; 39static int list_keys; 40static int list_timestamp; 41 42static struct getargs args[] = { 43 { "help", 'h', arg_flag, &help_flag }, 44 { "keys", 0, arg_flag, &list_keys, "show key value" }, --- 21 unchanged lines hidden (view full) --- 66 struct key_info *ki, **kie = &ki, *kp; 67 68 int max_version = sizeof("Vno") - 1; 69 int max_etype = sizeof("Type") - 1; 70 int max_principal = sizeof("Principal") - 1; 71 int max_timestamp = sizeof("Date") - 1; 72 int max_key = sizeof("Key") - 1; 73 |
74 /* XXX specialcase the ANY type */ 75 if(strncasecmp(keytab_string, "ANY:", 4) == 0) { 76 int flag = 0; 77 char buf[1024]; 78 keytab_string += 4; 79 while (strsep_copy((const char**)&keytab_string, ",", 80 buf, sizeof(buf)) != -1) { 81 if(flag) 82 printf("\n"); 83 do_list(buf); 84 flag = 1; 85 } 86 return 0; 87 } 88 |
|
74 ret = krb5_kt_resolve(context, keytab_string, &keytab); 75 if (ret) { 76 krb5_warn(context, ret, "resolving keytab %s", keytab_string); 77 return 0; 78 } 79 80 ret = krb5_kt_start_seq_get(context, keytab, &cursor); 81 if(ret){ --- 35 unchanged lines hidden (view full) --- 117 if(list_keys) { 118 int i; 119 kp->key = malloc(2 * entry.keyblock.keyvalue.length + 1); 120 for(i = 0; i < entry.keyblock.keyvalue.length; i++) 121 snprintf(kp->key + 2 * i, 3, "%02x", 122 ((unsigned char*)entry.keyblock.keyvalue.data)[i]); 123 CHECK_MAX(key); 124 } | 89 ret = krb5_kt_resolve(context, keytab_string, &keytab); 90 if (ret) { 91 krb5_warn(context, ret, "resolving keytab %s", keytab_string); 92 return 0; 93 } 94 95 ret = krb5_kt_start_seq_get(context, keytab, &cursor); 96 if(ret){ --- 35 unchanged lines hidden (view full) --- 132 if(list_keys) { 133 int i; 134 kp->key = malloc(2 * entry.keyblock.keyvalue.length + 1); 135 for(i = 0; i < entry.keyblock.keyvalue.length; i++) 136 snprintf(kp->key + 2 * i, 3, "%02x", 137 ((unsigned char*)entry.keyblock.keyvalue.data)[i]); 138 CHECK_MAX(key); 139 } |
125 kp->next = NULL; | |
126 *kie = kp; 127 kie = &kp->next; 128 krb5_kt_free_entry(context, &entry); 129 } | 140 *kie = kp; 141 kie = &kp->next; 142 krb5_kt_free_entry(context, &entry); 143 } |
144 *kie = NULL; /* termiate list */ |
|
130 ret = krb5_kt_end_seq_get(context, keytab, &cursor); 131 132 printf("%-*s %-*s %-*s", max_version, "Vno", 133 max_etype, "Type", 134 max_principal, "Principal"); 135 if(list_timestamp) 136 printf(" %-*s", max_timestamp, "Date"); 137 if(list_keys) --- 27 unchanged lines hidden (view full) --- 165out: 166 krb5_kt_close(context, keytab); 167 return 0; 168} 169 170int 171kt_list(int argc, char **argv) 172{ | 145 ret = krb5_kt_end_seq_get(context, keytab, &cursor); 146 147 printf("%-*s %-*s %-*s", max_version, "Vno", 148 max_etype, "Type", 149 max_principal, "Principal"); 150 if(list_timestamp) 151 printf(" %-*s", max_timestamp, "Date"); 152 if(list_keys) --- 27 unchanged lines hidden (view full) --- 180out: 181 krb5_kt_close(context, keytab); 182 return 0; 183} 184 185int 186kt_list(int argc, char **argv) 187{ |
188 krb5_error_code ret; |
|
173 int optind = 0; | 189 int optind = 0; |
190 char kt[1024]; |
|
174 175 if(verbose_flag) 176 list_timestamp = 1; 177 178 if(getarg(args, num_args, argc, argv, &optind)){ 179 arg_printusage(args, num_args, "ktutil list", ""); 180 return 1; 181 } 182 if(help_flag){ 183 arg_printusage(args, num_args, "ktutil list", ""); 184 return 0; 185 } 186 187 if (keytab_string == NULL) { | 191 192 if(verbose_flag) 193 list_timestamp = 1; 194 195 if(getarg(args, num_args, argc, argv, &optind)){ 196 arg_printusage(args, num_args, "ktutil list", ""); 197 return 1; 198 } 199 if(help_flag){ 200 arg_printusage(args, num_args, "ktutil list", ""); 201 return 0; 202 } 203 204 if (keytab_string == NULL) { |
188 do_list("FILE:/etc/krb5.keytab"); 189#ifdef KRB4 190 printf ("\n"); 191 do_list("krb4:/etc/srvtab"); 192#endif 193 } else { 194 do_list(keytab_string); | 205 if((ret = krb5_kt_default_name(context, kt, sizeof(kt))) != 0) { 206 krb5_warn(context, ret, "getting default keytab name"); 207 return 0; 208 } 209 keytab_string = kt; |
195 } | 210 } |
211 do_list(keytab_string); |
|
196 return 0; 197} | 212 return 0; 213} |