xref: /illumos-gate/usr/src/cmd/krb5/kadmin/kclient/kdyndns.c (revision fc910014e8a32a65612105835a10995f2c13d942)
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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <stdio.h>
28 #include <locale.h>
29 #include <netdb.h>
30 #include <smbsrv/libsmbns.h>
31 
32 char *whoami = NULL;
33 
34 static void usage();
35 
36 static
37 void
38 usage()
39 {
40 	fprintf(stderr, gettext("Usage: %s -d fqdn\n"), whoami);
41 	fprintf(stderr,
42 	    gettext("\t-d\tThe fully qualified domain of the client\n"));
43 	exit(1);
44 }
45 
46 int
47 main(int argc, char **argv)
48 {
49 	char c, fqdn[MAXHOSTNAMELEN];
50 	int ret = 0;
51 
52 	(void) setlocale(LC_ALL, "");
53 
54 #if !defined(TEXT_DOMAIN)
55 #define	TEXT_DOMAIN "SYS_TEST"
56 #endif /* TEXT_DOMAIN */
57 
58 	(void) textdomain(TEXT_DOMAIN);
59 
60 	whoami = argv[0];
61 
62 	while ((c = getopt(argc, argv, "d:")) != -1) {
63 		switch (c) {
64 		case 'd':
65 			(void) strncpy(fqdn, optarg, sizeof (fqdn));
66 			break;
67 		default:
68 			usage();
69 			break;
70 		}
71 	}
72 
73 	if (argc != optind)
74 		usage();
75 
76 	/*
77 	 * Update DNS RR for the client using DynDNS.  First it tries the
78 	 * unauthed version then it tries the GSS version.
79 	 */
80 	ret = dyndns_update(fqdn);
81 
82 	return (ret);
83 }
84