1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #include <netinet/in.h> /* struct sockaddr_in */ 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <sys/types.h> 30 #include <sys/socket.h> 31 #include <libscf.h> 32 #include <inet/kssl/kssl.h> 33 #include "kssladm.h" 34 35 void 36 usage_delete(boolean_t do_print) 37 { 38 if (do_print) 39 (void) fprintf(stderr, "Usage:\n"); 40 (void) fprintf(stderr, 41 "kssladm delete [-v] [<server_address>] <server_port>\n"); 42 } 43 44 int 45 do_delete(int argc, char *argv[]) 46 { 47 struct sockaddr_in6 server_addr; 48 char c; 49 char *port, *addr; 50 int pcnt; 51 52 if (argc < 3) { 53 goto err; 54 } 55 56 argc -= 1; 57 argv += 1; 58 59 while ((c = getopt(argc, argv, "v")) != -1) { 60 switch (c) { 61 case 'v': 62 verbose = B_TRUE; 63 break; 64 default: 65 goto err; 66 } 67 } 68 69 pcnt = argc - optind; 70 if (pcnt == 1) { 71 port = argv[optind]; 72 addr = NULL; 73 } else if (pcnt == 2) { 74 addr = argv[optind]; 75 port = argv[optind + 1]; 76 } 77 78 if (parse_and_set_addr(addr, port, &server_addr) < 0) { 79 goto err; 80 } 81 82 if (kssl_send_command((char *)&server_addr, KSSL_DELETE_ENTRY) < 0) { 83 perror("Error deleting entry"); 84 return (FAILURE); 85 } 86 87 if (verbose) 88 (void) printf("Successfully loaded cert and key\n"); 89 90 return (SUCCESS); 91 92 err: 93 usage_delete(B_TRUE); 94 return (SMF_EXIT_ERR_CONFIG); 95 } 96